/* Four in a Row — mobile-first styles.
 * System theme via prefers-color-scheme (no JS toggle), plus
 * color-scheme so form controls follow the OS theme too.
 * Banner reserve: anchored adaptive banners are up to 90dp tall on
 * phones (Michelle 2026-11-12) — body padding-bottom reserves it and
 * fixed overlays (toast, sheet) carry their own --banner-h offset.
 * The whole game view fits above the banner with no scrolling:
 * topbar + HUD + status + board + controls = 100dvh minus the
 * banner reserve (the board is flex-centred in the stage, so the
 * controls row always lands exactly on the banner zone).
 */
:root {
  color-scheme: light dark;
  --banner-h: 0px;
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #e2e9f1;
  --ink: #101820;
  --ink-2: #46525e;
  --ink-3: #76828e;
  --line: #c9d3dd;
  --accent: #b91c1c;
  --accent-ink: #ffffff;
  --accent-soft: #fee2e2;
  --danger: #b3261e;
  --warn: #8a5a00;
  --good: #15803d;
  --radius: 16px;
  --board-bg: #1d4ed8;
  --board-bg-2: #1e40af;
  --hole: #eef2f7;
  --p1: #dc2626;
  --p1-edge: #991b1b;
  --p2: #eab308;
  --p2-edge: #a16207;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f16;
    --surface: #141b28;
    --surface-2: #1d2739;
    --ink: #eef2f8;
    --ink-2: #b9c4d4;
    --ink-3: #7e8ba0;
    --line: #2a3448;
    --accent: #f87171;
    --accent-ink: #1f0505;
    --accent-soft: #3f1d1d;
    --danger: #ff8a80;
    --warn: #ffcf7d;
    --good: #4ade80;
    --board-bg: #1e40af;
    --board-bg-2: #172f7d;
    --hole: #0b0f16;
    --p1: #ef4444;
    --p1-edge: #7f1d1d;
    --p2: #facc15;
    --p2-edge: #854d0e;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--banner-h);
  overflow: hidden;
}
body, button, input { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
button { touch-action: manipulation; }
button, a { -webkit-touch-callout: none; user-select: none; }

.app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 0 12px;
}

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 52px; padding-top: 6px; flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 30px; height: 30px; color: var(--accent); display: block; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-word { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.brand-word span { color: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.about-button {
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; cursor: pointer;
}
.icon-button {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 20px;
}

/* ---- HUD + status ---- */
.hud {
  display: flex; align-items: center; gap: 14px;
  min-height: 34px; flex-shrink: 0;
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em; color: var(--ink-3);
}
.hud-item strong { color: var(--ink); font-size: 15px; letter-spacing: 0; }
.hud-mode { margin-left: auto; font-size: 11px; letter-spacing: 0.04em; text-align: right; }
.status {
  flex-shrink: 0; min-height: 24px; padding: 2px 0 4px;
  font-size: 14px; font-weight: 600; color: var(--ink-2); text-align: center;
}
.status .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }
.status .dot.p1 { background: var(--p1); }
.status .dot.p2 { background: var(--p2); }

/* ---- stage / board ---- */
.stage {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
}
.col-indicator {
  width: min(336px, 100%);
  display: grid; grid-template-columns: repeat(7, 1fr);
  height: 20px; flex-shrink: 0;
}
.col-indicator span {
  text-align: center; font-size: 14px; line-height: 20px; color: var(--ink-3);
  visibility: hidden;
}
.col-indicator span.on { visibility: visible; color: var(--accent); }
.board {
  width: min(336px, 100%);
  aspect-ratio: 7 / 6;
  max-height: 100%;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 4px;
  padding: 8px;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--board-bg), var(--board-bg-2));
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
  touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.cell {
  position: relative;
  border-radius: 50%;
  background: var(--hole);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.cell.col-hot { background: color-mix(in srgb, var(--hole) 70%, var(--accent-soft)); }
.disc {
  position: absolute; inset: 6%;
  border-radius: 50%;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.3), inset 0 3px 6px rgba(255, 255, 255, 0.35);
}
.disc.p1 { background: radial-gradient(circle at 35% 30%, #f87171, var(--p1) 55%, var(--p1-edge)); }
.disc.p2 { background: radial-gradient(circle at 35% 30%, #fde047, var(--p2) 55%, var(--p2-edge)); }
.disc.land { animation: drop-in 0.28s ease-in; }
@keyframes drop-in {
  from { transform: translateY(calc(var(--drop-rows, 1) * -100%)); }
  to { transform: translateY(0); }
}
.cell.win .disc {
  outline: 3px solid #ffffff;
  outline-offset: -1px;
  animation: win-pulse 0.7s ease-in-out infinite alternate;
}
@keyframes win-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.12); }
}

/* ---- controls: thumb-sized, clear of the 90px banner zone.
 * One row, three buttons, no wrapping (Chess vc3 lesson):
 * compact text + nowrap, heights proven in the harness. */
.controls {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0 6px;
  min-height: 66px;
  touch-action: none;
}
.ctl-btn {
  flex: 1 1 0; min-width: 0; height: 52px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 14px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: none; white-space: nowrap; overflow: hidden;
  padding: 0 8px;
}
.ctl-btn:active { background: var(--accent-soft); border-color: var(--accent); }
#settingsBtn { flex: 0 0 52px; font-size: 22px; }

/* ---- buttons ---- */
.button {
  min-height: 52px; border-radius: 12px; border: 1px solid transparent;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; font-size: 16px; cursor: pointer; padding: 0 16px;
  width: 100%; margin-top: 10px; white-space: nowrap;
}
.button-primary { background: var(--accent); color: var(--accent-ink); }
.button-secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }

/* ---- segmented pickers (menu + settings) ---- */
.seg-label { margin: 14px 0 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; color: var(--ink-3); text-transform: uppercase; }
.seg { display: flex; gap: 8px; }
.seg-btn {
  flex: 1 1 0; min-width: 0; min-height: 48px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-weight: 700; font-size: 15px; cursor: pointer; white-space: nowrap;
}
.seg-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---- sheets ---- */
.sheet {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-center { align-items: center; }
.sheet-card {
  background: var(--surface); color: var(--ink);
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + var(--banner-h));
  width: 100%; max-width: 560px; max-height: 82dvh; overflow-y: auto;
}
.sheet-center .sheet-card { border-radius: 20px; margin: 16px; padding-bottom: 20px; text-align: center; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet-card h1 { margin: 0; font-size: 30px; letter-spacing: -0.02em; }
.menu-sub { margin: 6px 0 0; color: var(--ink-2); font-size: 15px; }
.menu-best { margin: 10px 0 0; font-weight: 700; color: var(--accent); }
.menu-help { margin: 14px 0 0; font-size: 13px; color: var(--ink-2); }
.menu-first { margin: 14px 0 0; font-size: 14px; color: var(--ink-2); }
.menu-first strong { color: var(--accent); }
.about-body { font-size: 14px; color: var(--ink-2); }
.about-meta { font-size: 12px; color: var(--ink-3); margin: 14px 0 0; }
.footer-link {
  background: none; border: 0; padding: 10px 4px; cursor: pointer;
  color: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: 0;
}

/* ---- toast: pointer-events none so it never eats taps (BlockDrop
 * T26); anchored ABOVE the controls + banner, never overlapping
 * them (Solitaire correction). */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--banner-h) + 82px);
  z-index: 50; pointer-events: none;
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  max-width: calc(100vw - 32px); text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
