/* ============================================================
   LIVE Round — design system
   ============================================================ */
:root {
  /* Brand */
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-tint: #eff4ff;
  --brand-ring: rgba(37, 99, 235, 0.35);

  /* Semantic */
  --green: #16a34a;
  --green-tint: #e9f9ef;
  --red: #dc2626;
  --red-tint: #fdecec;
  --amber: #d97706;
  --amber-tint: #fef4e6;

  /* Neutrals */
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e6e9ef;
  --line-strong: #d4d9e2;
  --bg: #f4f6fa;
  --panel: #f8fafc;
  --paper: #ffffff;

  /* Shape & depth */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.16);

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Tahoma, "Noto Sans Thai", Arial, sans-serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: clamp(0px, 3vw, 40px) 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, #eaf0fb 0%, rgba(234, 240, 251, 0) 60%),
    var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3 {
  margin: 0 0 8px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

a {
  color: var(--brand);
}

/* ============================================================
   Shell & layout
   ============================================================ */
.shell {
  width: min(100%, 1140px);
  margin: 0 auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.with-sidebar {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  align-items: stretch;
}

.content {
  padding: clamp(20px, 3.4vw, 40px);
}

.admin-content {
  padding: clamp(22px, 3.4vw, 44px);
  min-width: 0;
}

/* ============================================================
   Top navigation
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px clamp(14px, 2.4vw, 26px);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
}

.topbar::-webkit-scrollbar {
  height: 0;
}

.topbar button {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14.5px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  transition: background 0.15s, color 0.15s;
}

.topbar button:hover {
  background: var(--brand-tint);
  color: var(--brand-strong);
}

.topbar .active {
  color: var(--brand-strong);
  background: var(--brand-tint);
}

.topbar .active::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand);
}

/* legacy pipe separators — not needed in the modern nav */
.separator {
  display: none;
}

.gear {
  margin-left: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 20px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, background 0.15s;
}

.gear:hover {
  background: var(--panel);
  transform: rotate(30deg);
}

.lang-select {
  min-width: 120px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--paper);
  font-weight: 600;
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
}

.lang-select:focus-visible {
  outline: 3px solid var(--brand-ring);
  outline-offset: 1px;
}

/* ============================================================
   Balance / credit cards
   ============================================================ */
.credit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

.balance-box {
  display: flex;
  align-items: stretch;
  flex: 1 1 260px;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.balance-box span:first-child {
  display: grid;
  place-items: center;
  min-width: 128px;
  padding: 0 18px;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.balance-box .credit {
  background: linear-gradient(135deg, #16a34a, #15803d);
}

.balance-box .outstanding {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.balance-box em {
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 10px 20px;
  font-style: normal;
  font-size: 14px;
  color: var(--muted);
}

/* ============================================================
   LIVE header
   ============================================================ */
.live-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.live-title {
  position: relative;
  padding-left: 22px;
}

.live-title h1 {
  font-size: clamp(26px, 4vw, 34px);
}

.live-title h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}

.live-title::before {
  position: absolute;
  top: 10px;
  left: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55);
  animation: livePulse 1.8s ease-out infinite;
  content: "";
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
  70% { box-shadow: 0 0 0 12px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.countdown {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--red-tint);
  color: var(--red);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Bet category cards
   ============================================================ */
.section-card {
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  color: #fff;
  font-weight: 700;
  font-size: 15.5px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
}

.section-card.blue .section-title {
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
}

.section-card.green .section-title {
  background: linear-gradient(135deg, #16a34a, #15803d);
}

.section-card.red .section-title {
  background: linear-gradient(135deg, #e11d48, #be123c);
}

.section-title span:last-child {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.subhead,
.bet-grid-head {
  display: grid;
  background: var(--panel);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 13.5px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.subhead > div,
.bet-grid-head > div {
  padding: 10px 8px;
}

.subhead {
  grid-template-columns: 1fr 1fr;
}

.bet-grid-head {
  grid-template-columns: repeat(4, 1fr);
}

.bet-columns,
.weight-columns {
  display: grid;
}

.bet-columns {
  grid-template-columns: 1fr 1fr;
}

.weight-columns {
  grid-template-columns: repeat(4, 1fr);
}

.bet-cell {
  padding: 14px 18px;
  border-right: 1px solid var(--line);
  border-top: 1px solid var(--line);
  white-space: pre-line;
  line-height: 1.7;
  font-size: 14px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.subhead + .bet-columns .bet-cell {
  border-top: 0;
}

.bet-cell:last-child {
  border-right: 0;
}

/* ============================================================
   Buttons
   ============================================================ */
.action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 132px;
  padding: 12px 22px;
  border: 0;
  border-radius: var(--r-md);
  color: #fff;
  background: var(--brand);
  font-weight: 600;
  font-size: 15px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.06s ease, box-shadow 0.15s, background 0.15s, filter 0.15s;
}

.btn:hover {
  background: var(--brand-strong);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: 3px solid var(--brand-ring);
  outline-offset: 2px;
}

.btn.green {
  background: var(--green);
}
.btn.green:hover {
  background: #15803d;
}

.btn.red {
  background: var(--red);
}
.btn.red:hover {
  background: #b91c1c;
}

.btn.gray {
  color: var(--ink-soft);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}
.btn.gray:hover {
  background: #eef1f6;
}

/* ============================================================
   Forms — bet & admin
   ============================================================ */
.form-page {
  max-width: 920px;
  margin: 0 auto;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 24px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
}

.meta-row .active {
  color: var(--brand-strong);
}

.meta-row .bad {
  color: var(--red);
}

.bet-form {
  display: grid;
  gap: 26px;
}

.bet-line {
  display: grid;
  grid-template-columns: 30px minmax(180px, 320px) minmax(200px, 1fr);
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.bet-line label {
  display: grid;
  gap: 10px;
}

.bet-line strong {
  font-size: 14.5px;
  color: var(--ink);
}

.check {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid var(--brand);
  border-radius: 7px;
  color: #fff;
  background: var(--brand);
  font-size: 16px;
  font-weight: 700;
}

.check:empty {
  background: var(--paper);
}

.pill-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(95px, 1fr));
  gap: 10px;
}

.pill {
  min-height: 52px;
  padding: 10px 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--paper);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}

.pill:hover {
  border-color: var(--brand);
  color: var(--brand-strong);
}

.pill.selected {
  border-color: var(--brand);
  background: var(--brand-tint);
  color: var(--brand-strong);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.pill.gray {
  color: var(--muted);
  background: var(--panel);
  border-style: dashed;
}

.input {
  width: 100%;
  min-height: 50px;
  padding: 12px 18px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--paper);
  text-align: center;
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.input::placeholder {
  color: var(--muted);
  font-style: normal;
}

select.input {
  text-align: left;
}

.round-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(92px, 1fr));
  gap: 10px;
  margin: 24px 0;
}

.round-grid .pill {
  min-height: 48px;
  font-size: 15px;
}

.notes {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.8;
  padding: 14px 16px;
  border-left: 3px solid var(--line-strong);
  background: var(--panel);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  font-size: 14px;
}

.table th {
  padding: 13px 12px;
  color: var(--ink-soft);
  background: var(--panel);
  font-weight: 700;
  text-align: center;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 13px 12px;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover td {
  background: var(--brand-tint);
}

.ok {
  color: var(--green);
  font-weight: 700;
}

.bad {
  color: var(--red);
  font-weight: 700;
}

.wait {
  color: var(--amber);
  font-weight: 700;
}

/* ============================================================
   History / tickets
   ============================================================ */
.history-item {
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.history-item header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-soft);
}

.ticket {
  margin-top: 16px;
  padding: 16px 20px;
  border-radius: var(--r-md);
  background: var(--panel);
  border: 1px dashed var(--line-strong);
  line-height: 1.9;
  font-size: 14px;
}

/* ============================================================
   Stats
   ============================================================ */
.stats-list {
  max-width: 760px;
  margin: 0 auto;
}

.stats-title {
  margin: 8px 0 22px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
}

.stats-list .subhead {
  border-radius: var(--r-md) var(--r-md) 0 0;
  border: 1px solid var(--line);
}

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 12px 0;
  font-size: 16px;
  text-align: center;
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}

.stats-row:nth-child(even) {
  background: var(--panel);
}

.stats-row:last-child {
  border-radius: 0 0 var(--r-md) var(--r-md);
}

/* ============================================================
   Admin sidebar
   ============================================================ */
.sidebar {
  padding: 24px 16px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.sidebar h3 {
  margin: 0 8px 18px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.sidebar strong {
  display: block;
  margin: 18px 8px 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar button {
  display: block;
  width: 100%;
  margin: 2px 0;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  text-align: left;
  font-size: 14px;
  color: var(--ink-soft);
  transition: background 0.15s, color 0.15s;
}

.sidebar button:hover {
  background: #eef1f6;
  color: var(--ink);
}

.sidebar button.active {
  background: var(--brand-tint);
  color: var(--brand-strong);
  font-weight: 700;
  box-shadow: inset 2px 0 0 var(--brand);
}

/* Emergency group accent */
.sidebar strong:last-of-type {
  color: var(--red);
}

.admin-title {
  margin-bottom: 24px;
  font-size: clamp(22px, 3.2vw, 30px);
  font-weight: 700;
}

.admin-form {
  max-width: 760px;
}

.admin-form h3 {
  margin: 26px 0 12px;
  font-size: 15px;
  color: var(--ink);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.field {
  display: grid;
  grid-template-columns: 220px minmax(220px, 360px);
  align-items: center;
  gap: 18px;
  margin: 12px 0;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink-soft);
}

/* ============================================================
   Reports
   ============================================================ */
.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
  max-width: 680px;
}

.summary-box {
  padding: 20px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: var(--r-md);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-soft);
}

.summary-box.red {
  border-left-color: var(--red);
}

.summary-box.blue {
  border-left-color: var(--brand);
  grid-column: 1 / -1;
}

/* ============================================================
   Closed round / winner
   ============================================================ */
.closed {
  max-width: 540px;
  margin: 20px auto;
  text-align: center;
}

.winner-box {
  margin: 24px auto;
  padding: 32px;
  border-radius: var(--r-xl);
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  box-shadow: var(--shadow-md);
}

.winner-box .input {
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
}

/* ============================================================
   Toast & install prompt
   ============================================================ */
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  padding: 14px 20px;
  border-radius: var(--r-md);
  color: #fff;
  background: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.install-cta {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 40;
  padding: 11px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
}

.install-cta:hover {
  background: var(--brand-strong);
}

.install-cta[hidden] {
  display: none;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 860px) {
  .with-sidebar {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  body {
    padding: 0;
  }

  .shell {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .live-head,
  .meta-row {
    flex-direction: column;
    align-items: stretch;
  }

  .bet-line,
  .field {
    grid-template-columns: 1fr;
  }

  .bet-line .check {
    display: none;
  }

  .round-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .weight-columns,
  .bet-grid-head {
    grid-template-columns: repeat(2, 1fr);
  }

  .report-grid,
  .history-item header {
    grid-template-columns: 1fr;
  }

  .action-row .btn {
    flex: 1 1 auto;
  }
}

@media (max-width: 460px) {
  .bet-columns {
    grid-template-columns: 1fr;
  }

  .bet-cell {
    border-right: 0;
  }

  .round-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.btn.selected {
  outline: 3px solid var(--brand-ring);
  outline-offset: 2px;
  filter: saturate(1.15);
}

/* ============================================================
   Auth — login screen & session controls
   ============================================================ */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 384px);
  display: grid;
  gap: 14px;
  padding: 32px 28px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}

.auth-card h1 {
  margin: 0;
  font-size: 24px;
}

.auth-sub {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 14px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--brand-strong);
}

.auth-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--red);
}

.auth-field {
  display: grid;
  gap: 6px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.auth-field .input {
  text-align: left;
  min-height: 46px;
}

.auth-error {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--red-tint);
  color: var(--red);
  font-size: 13.5px;
  font-weight: 600;
}

.auth-error[hidden] {
  display: none;
}

.topbar-logout {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
}

.topbar-logout:hover {
  background: var(--red-tint);
  color: var(--red);
}

.sidebar-exit {
  display: block;
  width: 100%;
  margin: 6px 0 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--paper);
  text-align: left;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.sidebar-exit:hover {
  background: var(--brand-tint);
  color: var(--brand-strong);
}

.sidebar-exit.logout {
  margin-top: 18px;
  color: var(--red);
}

.sidebar-exit.logout:hover {
  background: var(--red-tint);
  color: var(--red);
}
