:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --line: #dde3e9;
  --line-strong: #c4ced8;
  --text: #16212e;
  --muted: #5e6b7a;
  --accent: #1f5f8b;
  --accent-soft: #eaf2f8;
  --green: #1a7a4c;
  --green-soft: #e8f5ee;
  --amber: #946000;
  --amber-soft: #fff4e2;
  --red: #b3261e;
  --red-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 48, 0.05), 0 8px 22px rgba(16, 32, 48, 0.04);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.screen-loading {
  display: grid;
  place-items: center;
  min-height: 60vh;
  color: var(--muted);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.logo {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.5px;
}

.header-title { flex: 1; min-width: 0; }
.header-title h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: 0.2px; }
.header-title p { margin: 0; color: var(--muted); font-size: 13px; }

.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.icon-button svg { width: 21px; height: 21px; }

.badge-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
}

main {
  width: min(100%, 880px);
  margin: 0 auto;
  padding: 22px 16px calc(100px + env(safe-area-inset-bottom));
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 0 16px;
}
.section-head h2 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.3px; }
.section-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card.highlight { border-color: var(--accent); }
.card.success { border-color: #a9d5bd; }

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.card-title h3 { margin: 0; font-size: 16px; font-weight: 650; }
.card-title small { color: var(--muted); font-size: 13px; }

.muted { color: var(--muted); }
.tiny { font-size: 13px; }
.strong { font-weight: 650; }
.right { text-align: right; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack > * + * { margin-top: 10px; }

.balls { display: flex; flex-wrap: wrap; gap: 8px; }
.ball {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-weight: 650;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.ball.hit { background: var(--green); border-color: var(--green); color: #fff; }
.ball.extra { background: var(--accent-soft); border-color: #9dc2da; color: var(--accent); }
.ball.extra.hit { background: var(--accent); border-color: var(--accent); color: #fff; }

.modality { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.modality:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.modality-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.modality-head h4 { margin: 0; font-size: 15px; font-weight: 650; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.tag.green { color: var(--green); border-color: #a9d5bd; background: var(--green-soft); }
.tag.amber { color: var(--amber); border-color: #ecd5a6; background: var(--amber-soft); }
.tag.red { color: var(--red); border-color: #f0c4c0; background: var(--red-soft); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #1a5278; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--red); border-color: #f0c4c0; }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: 13px; }
.btn.block { width: 100%; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 14px; font-weight: 600; }
.field input[type="text"],
.field input[type="password"],
.field input[type="date"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 64px; resize: vertical; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 14px;
  cursor: pointer;
}
.check input { accent-color: var(--accent); width: 17px; height: 17px; }

.number-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.number-grid button {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 650;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.number-grid button:hover { border-color: var(--accent); }
.number-grid button.selected { background: var(--accent); border-color: var(--accent); color: #fff; }

.play-card .play-name { font-weight: 650; font-size: 17px; }
.play-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.prize-group { border-top: 1px solid var(--line); padding: 12px 0; }
.prize-group:first-of-type { border-top: 0; padding-top: 0; }
.prize-group summary { display: flex; align-items: center; gap: 10px; }
.table-wrap { overflow-x: auto; }
.prize-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.prize-table th,
.prize-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.prize-table th { color: var(--muted); font-size: 12px; font-weight: 600; }
.prize-table tbody tr:last-child td { border-bottom: 0; }
.prize-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.check-draw { border-top: 1px solid var(--line); padding: 10px 0; }
.check-draw:first-of-type { border-top: 0; padding-top: 0; }
.check-draw summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.check-draw-title { font-weight: 600; }
.check-draw-body { padding-top: 10px; }
.check-draw-body .modality:first-of-type { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 6px; }

.notification {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.notification.unread { border-left: 3px solid var(--accent); }
.notification-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 8px; flex: none; }
.notification-title { font-weight: 650; font-size: 15px; }
.notification-body { color: var(--muted); font-size: 14px; margin-top: 3px; }
.notification time { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; }

.empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.bottom-nav button.active { color: var(--accent); }
.bottom-nav svg { width: 21px; height: 21px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
  background: rgba(16, 28, 40, 0.45);
}
.modal {
  width: min(100%, 620px);
  max-height: 92vh;
  overflow-y: auto;
  padding: 20px 18px calc(22px + env(safe-area-inset-bottom));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
}
.modal h2 { margin: 0 0 16px; font-size: 19px; font-weight: 650; }

.login-screen {
  width: min(100%, 420px);
  margin: 10vh auto 0;
  padding: 0 16px;
  text-align: center;
}
.login-screen .logo { width: 60px; height: 60px; margin: 0 auto 16px; font-size: 26px; border-radius: 12px; }
.login-screen h1 { margin: 0 0 6px; font-size: 22px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(94px + env(safe-area-inset-bottom));
  z-index: 80;
  transform: translateX(-50%) translateY(16px);
  max-width: min(92vw, 460px);
  padding: 11px 16px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  box-shadow: 0 8px 24px rgba(16, 32, 48, 0.2);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--red); }

details summary { cursor: pointer; font-weight: 600; font-size: 15px; }
details[open] summary { margin-bottom: 14px; }

@media (min-width: 760px) {
  .bottom-nav { grid-template-columns: repeat(5, minmax(0, 132px)); justify-content: center; }
  .bottom-nav button { flex-direction: row; gap: 8px; font-size: 13px; padding: 10px 12px; }
  .modal-backdrop { place-items: center; padding: 20px; }
  .modal { border-radius: 12px; }
  .number-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); }
}
