  :root {
    --bg: #0b1220;
    --panel: #131c30;
    --panel-2: #1a2542;
    --border: #243154;
    --text: #eef2ff;
    --muted: #8ea0c9;
    --accent: #4f8cff;
    --accent-2: #6ee7b7;
    --danger: #ff6b6b;
    --warn: #ffb86b;
    --ok: #6ee7b7;
    --tap: 48px;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; height: 100%; }
  body { min-height: 100dvh; height: 100dvh; }
  button { font: inherit; color: inherit; }
  input[type="text"], input[type="number"] {
    background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 12px; font-size: 16px; width: 100%;
  }
  input:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  /* App shell */
  .app { display: flex; flex-direction: column; min-height: 100dvh; height: 100dvh; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--panel);
    position: sticky; top: 0; z-index: 5;
  }
  .topbar h1 { font-size: 16px; margin: 0; letter-spacing: 0.5px; color: var(--muted); font-weight: 600; }
  .topbar .actions { display: flex; gap: 8px; }
  .icon-btn {
    min-width: var(--tap); height: var(--tap); padding: 0 10px;
    background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
    color: var(--text); font-size: 22px; font-weight: 600; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; line-height: 1;
  }
  .help-content { font-size: 14px; line-height: 1.5; color: var(--text); }
  .help-content h4 { margin: 14px 0 4px; font-size: 14px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; }
  .help-content p, .help-content ul { margin: 4px 0; }
  .help-content ul { padding-left: 20px; }
  .help-content li { margin: 3px 0; }
  .icon-btn:active { transform: scale(0.98); }

  .main { flex: 1 1 auto; display: flex; flex-direction: column; padding: 12px; gap: 12px; overflow-y: auto; min-height: 0; }
  .main > .team { flex: 1 1 0; min-height: 0; justify-content: center; }
  .team {
    background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
    padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
  }
  .team .label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
  .team .name { font-size: clamp(28px, 8vw, 40px); font-weight: 700; }
  .team .score-block { display: flex; justify-content: center; align-items: baseline; gap: 14px; margin: 4px 0; }
  .team .score { font-size: clamp(80px, 22vw, 140px); font-weight: 800; line-height: 1; letter-spacing: -2px; }
  .team .current-bid-large { font-size: clamp(28px, 8vw, 48px); font-weight: 700; line-height: 1; color: var(--accent); letter-spacing: -1px; }
  .team .current-bid-large.empty { color: var(--muted); opacity: 0.5; }
  .team .prev-delta { text-align: center; font-size: 14px; color: var(--muted); }
  .team .prev-delta .delta-pos { color: var(--ok); font-weight: 700; }
  .team .prev-delta .delta-neg { color: var(--danger); font-weight: 700; }
  .team .meta { color: var(--muted); font-size: 14px; display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
  .team .meta b { color: var(--text); font-weight: 600; }
  .team .meta .tag { padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); font-size: 12px; }
  .team.winner { border-color: var(--ok); box-shadow: 0 0 0 2px rgba(110,231,183,0.2) inset; }

  .actions-row { display: flex; gap: 10px; }
  .btn-primary {
    flex: 1; min-height: 56px; border-radius: 14px; border: 1px solid var(--accent);
    background: linear-gradient(180deg, #5b95ff, #3a73e6); color: white; font-size: 18px; font-weight: 700;
    cursor: pointer;
  }
  .btn-primary[disabled] { opacity: 0.45; cursor: not-allowed; background: var(--panel-2); border-color: var(--border); color: var(--muted); }
  .btn-secondary {
    flex: 1; min-height: 56px; border-radius: 14px; border: 1px solid var(--accent-2);
    background: linear-gradient(180deg, #2dd4a4, #169c75); color: #0b1220; font-size: 18px; font-weight: 800; cursor: pointer;
    letter-spacing: 0.5px;
  }
  .btn-secondary[disabled] { opacity: 0.35; cursor: not-allowed; background: var(--panel-2); border-color: var(--border); color: var(--muted); box-shadow: none; }
  .footer-info { text-align: center; color: var(--muted); font-size: 13px; padding: 2px; }
  .banner {
    padding: 12px 14px; border-radius: 12px; background: rgba(110,231,183,0.12);
    border: 1px solid var(--ok); color: var(--ok); text-align: center; font-weight: 600;
  }
  .banner.warn { background: rgba(255,184,107,0.12); border-color: var(--warn); color: var(--warn); }

  /* Dialog / sheet */
  .overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 100;
    display: flex; align-items: flex-end; justify-content: center;
    animation: fade .15s ease-out;
  }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
  .sheet {
    width: 100%; max-width: 560px; background: var(--panel); border-radius: 18px 18px 0 0;
    border: 1px solid var(--border); border-bottom: none;
    max-height: 92dvh; overflow-y: auto; padding: 16px;
    animation: rise .2s ease-out;
  }
  @keyframes rise { from { transform: translateY(20px); opacity: 0.6; } to { transform: none; opacity: 1; } }
  @media (min-width: 640px) {
    .overlay { align-items: center; }
    .sheet { border-radius: 18px; border-bottom: 1px solid var(--border); max-height: 88dvh; }
  }
  .sheet h2 { margin: 4px 0 14px; font-size: 20px; }
  .sheet h3 { margin: 18px 0 8px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

  .group { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-2); }
  .group + .group { margin-top: 10px; }
  .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .row label { color: var(--text); font-size: 15px; }
  .radio-row { display: flex; flex-direction: row; flex-wrap: wrap; gap: 12px; }
  .radio-row label { display: flex; align-items: center; gap: 6px; padding: 8px 4px; cursor: pointer; }
  .inline-inputs { display: flex; flex-direction: column; gap: 8px; margin-left: 28px; }

  /* Stepper */
  .stepper { display: flex; align-items: center; gap: 8px; }
  .stepper button {
    width: var(--tap); height: var(--tap); border-radius: 12px; border: 1px solid var(--border);
    background: var(--panel); color: var(--text); font-size: 24px; font-weight: 700; cursor: pointer;
  }
  .stepper button[disabled] { opacity: 0.35; cursor: not-allowed; }
  .stepper .val { min-width: 56px; text-align: center; font-size: 22px; font-weight: 700; }

  /* Toggle */
  .toggle { position: relative; display: inline-block; width: 48px; height: 28px; }
  .toggle input { opacity: 0; width: 0; height: 0; }
  .toggle .slider { position: absolute; cursor: pointer; inset: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 999px; transition: .15s; }
  .toggle .slider::before { content: ""; position: absolute; height: 22px; width: 22px; left: 2px; top: 2px; background: white; border-radius: 50%; transition: .15s; }
  .toggle input:checked + .slider { background: var(--accent); border-color: var(--accent); }
  .toggle input:checked + .slider::before { transform: translateX(20px); }
  .toggle input:disabled + .slider { opacity: 0.4; cursor: not-allowed; }

  .sheet-actions { display: flex; gap: 10px; margin-top: 18px; position: sticky; bottom: 0; background: var(--panel); padding-top: 10px; }

  .total-pill { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); font-weight: 700; }
  .total-pill.bad { color: var(--danger); border-color: var(--danger); }
  .total-pill.good { color: var(--ok); border-color: var(--ok); }

  /* History */
  table.history { width: 100%; border-collapse: collapse; font-size: 14px; }
  table.history th, table.history td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: center; }
  table.history th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
  table.history .delta-pos { color: var(--ok); }
  table.history .delta-neg { color: var(--danger); }
  table.history .marker { display: inline-block; padding: 1px 5px; border-radius: 4px; background: var(--panel-2); font-size: 11px; margin-left: 2px; }

  .hint { color: var(--muted); font-size: 13px; }
  .err { color: var(--danger); font-size: 13px; }

  /* Splash */
  .splash { position: fixed; inset: 0; z-index: 9999; background: #fff; display: flex; align-items: center; justify-content: center; transition: opacity .4s ease; }
  .splash.hide { opacity: 0; pointer-events: none; }
  .splash-img { position: absolute; max-width: 90vw; max-height: 70vh; object-fit: contain; }
  #splash-img-1 { opacity: 1; }
  #splash-img-2 { opacity: 0; }
  @keyframes splashBg {
    0%, 40% { background-color: #fff; }
    50%, 100% { background-color: #000; }
  }
  @keyframes splashImg1 {
    0%, 40% { opacity: 1; }
    50%, 100% { opacity: 0; }
  }
  @keyframes splashImg2 {
    0%, 50% { opacity: 0; }
    60%, 100% { opacity: 1; }
  }
  .splash.animate { animation: splashBg 5s linear forwards; }
  .splash.animate #splash-img-1 { animation: splashImg1 5s linear forwards; }
  .splash.animate #splash-img-2 { animation: splashImg2 5s linear forwards; }

.info-tip-wrap { position: relative; display: inline-block; }
.info-tip {
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 4px; padding: 4px 6px; min-width: 28px; min-height: 28px;
  background: transparent; border: none; color: inherit;
  font-size: 0.95em; line-height: 1; opacity: 0.65; cursor: pointer;
  user-select: none; border-radius: 6px;
}
.info-tip:hover, .info-tip:focus { opacity: 1; outline: none; }
.info-tip-bubble {
  display: none; position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(100% + 8px); z-index: 50;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font-size: 13px; line-height: 1.35;
  width: max-content; max-width: 240px; white-space: pre-line; text-align: left;
  text-transform: none; letter-spacing: normal; font-weight: 400;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4); pointer-events: none;
}
.info-tip-bubble::after {
  content: ""; position: absolute; left: 50%; top: 100%;
  transform: translateX(-50%); border: 6px solid transparent;
  border-top-color: var(--border);
}
.info-tip-wrap.open .info-tip-bubble { display: block; }
@media (hover: hover) {
  .info-tip-wrap:hover .info-tip-bubble,
  .info-tip-wrap:focus-within .info-tip-bubble { display: block; }
}

/* Topbar menu (mobile) */
.menu-wrap { position: relative; display: none; }
.menu-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  min-width: 200px; padding: 6px; display: flex; flex-direction: column; gap: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.menu-dropdown[hidden] { display: none; }
.menu-dropdown button {
  background: transparent; border: 0; color: var(--text); text-align: left;
  padding: 12px 14px; border-radius: 8px; font-size: 15px; cursor: pointer;
  min-height: var(--tap);
}
.menu-dropdown button:hover, .menu-dropdown button:focus-visible { background: var(--panel-2); }
.menu-dropdown button:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

@media (max-width: 560px) {
  #topbar-actions { display: none; }
  .menu-wrap { display: block; }
}

/* Game Over modal */
.game-over-body { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.game-over-winner { font-size: 22px; font-weight: 800; color: var(--accent-2); text-align: center; }
.game-over-scores { display: flex; gap: 16px; width: 100%; justify-content: center; flex-wrap: wrap; }
.game-over-scores .go-team {
  flex: 1 1 140px; min-width: 0; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; text-align: center;
}
.game-over-scores .go-team.winner { border-color: var(--accent-2); }
.game-over-scores .go-name { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; overflow-wrap: anywhere; }
.game-over-scores .go-score { font-size: 44px; font-weight: 800; line-height: 1.1; margin-top: 4px; }

/* Options collapse */
.options-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.options-header h3 { margin: 4px 0 14px; }
.collapse-btn {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 14px; font-weight: 700;
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; line-height: 1; padding: 0;
}
.collapse-btn:active { transform: scale(0.96); }
#options-content { display: flex; flex-direction: column; gap: 10px; }



/* Game History modal */
.gh-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; padding: 4px 2px; }
.gh-empty { text-align: center; color: var(--muted, #94a3b8); padding: 24px 8px; }
.gh-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 10px 12px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: 8px; }
.gh-when { display: flex; flex-direction: column; line-height: 1.1; }
.gh-date { font-weight: 600; font-size: 14px; }
.gh-time { font-size: 11px; color: var(--muted, #94a3b8); }
.gh-scores { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gh-team { font-size: 14px; }
.gh-team.win { font-weight: 700; color: #fbbf24; }
.gh-sep { color: var(--muted, #94a3b8); }
.gh-icon { font-size: 22px; }
