/* Design tokens — every knob the game will let players twist later. */
:root {
  /* palette — dark mode default */
  --bg: #0e0e13;
  --bg-grid: #1a1b24;
  --surface: #1c1d27;
  --surface-2: #22232e;
  --ink: #ececf1;
  --ink-soft: #b4b5bf;
  --muted: #6d6e79;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #7c81ff;
  --accent-soft: rgba(124, 129, 255, 0.16);
  --match: #34d399;
  --match-soft: rgba(52, 211, 153, 0.14);
  --miss: #f87171;
  --miss-soft: rgba(248, 113, 113, 0.14);

  /* card back gradient */
  --back-a: #2c2d3a;
  --back-b: #1a1b26;
  --back-dot: rgba(255, 255, 255, 0.06);

  /* icon rendering — swap these to make the game feel different */
  --icon-color: #ececf1;
  --icon-stroke: 1.75;
  --icon-size: 68px;

  /* geometry */
  --radius: 6px;
  --radius-sm: 4px;
  --card-gap: 14px;
  --board-max: 1180px;

  /* motion */
  --flip: 520ms cubic-bezier(0.22, 1, 0.36, 1);
  --pop: 220ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* type */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 15% -10%, var(--bg-grid), transparent 60%),
    radial-gradient(900px 600px at 100% 100%, var(--bg-grid), transparent 55%),
    var(--bg);
  height: 100vh;
  /* dvh = dynamic viewport height — respects iOS Safari's URL bar */
  height: 100dvh;
  display: flex;
  flex-direction: row;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'cv11';
}

button {
  font-family: inherit;
}

/* ── Side panel ──────────────────────────────────────────── */
.sidepanel {
  flex: 0 0 260px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 28px 24px;
  border-right: 1px solid var(--line);
  background: rgba(14, 14, 19, 0.6);
  backdrop-filter: blur(10px);
  z-index: 10;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  background: url('../logo.png') center/contain no-repeat;
  position: relative;
}

.brand-name {
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.brand-tag {
  color: var(--ink-soft);
  font-size: 13px;
  margin-top: 2px;
}

.hud {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat .label {
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.stat .value {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.pick-value {
  font-family: var(--font);
  font-size: 24px;
  text-transform: capitalize;
  transition: color 200ms ease;
  min-height: 1.2em;
}

.pick-value.match { color: var(--match); }
.pick-value.miss  { color: var(--miss); }

.side-actions {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-block {
  flex: 1;
  text-align: center;
}

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.btn:hover {
  background: var(--surface-2);
  border-color: rgba(255, 255, 255, 0.22);
}

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

.btn-primary {
  background: var(--accent);
  color: #0e0e13;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #9498ff;
  border-color: #9498ff;
}

/* ── Icon-only button (mute) ─────────────────────────────── */
.icon-btn {
  appearance: none;
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.icon-btn:hover {
  color: var(--ink);
  background: var(--surface-2);
  border-color: rgba(255, 255, 255, 0.22);
}

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

.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.icon-btn .ic-off { display: none; }

.icon-btn[data-muted="true"] {
  color: var(--muted);
}

.icon-btn[data-muted="true"] .ic-on  { display: none; }
.icon-btn[data-muted="true"] .ic-off { display: block; }

/* ── Stage ───────────────────────────────────────────────── */
.stage {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
  position: relative;
}

/* ── Right ad panel (desktop only) ───────────────────────── */
.ad-panel {
  flex: 0 0 180px;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  border-left: 1px solid var(--line);
  background: rgba(14, 14, 19, 0.6);
  backdrop-filter: blur(10px);
  overflow-y: auto;
}

/* Ads aren't live yet (waiting on more traffic) — panel stays in the
   markup so it's a one-line revert to bring back, but takes no layout
   space until then. */
.ad-panel[hidden] {
  display: none;
}

.ad-slot {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ad-label {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

.ad-slot .adsbygoogle {
  min-height: 250px;
  border-radius: var(--radius);
  overflow: hidden;
}

/* Peek countdown badge — top-right of the stage during Blindfold peek. */
.peek-badge {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  background: rgba(15, 15, 20, 0.85);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  box-shadow: 0 0 0 4px rgba(124, 129, 255, 0.14), 0 20px 40px -18px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  animation: peekPulse 900ms ease-in-out infinite;
}

.peek-badge[hidden] { display: none; }

.peek-badge .peek-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
}

.peek-badge .peek-count {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

@keyframes peekPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

/* ── Mobile / portrait layout ────────────────────────────── */
@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  /* Hide ad panel on mobile */
  .ad-panel {
    display: none;
  }

  /* Sidepanel becomes a compact TOP bar. */
  .sidepanel {
    order: 0;
    flex: 0 0 auto;
    display: grid;
    grid-template-rows: auto auto;
    grid-template-columns: auto 1fr auto auto auto;
    gap: 12px;
    padding: 10px 14px 12px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow: visible;
    align-items: center;
  }

  .sidepanel .brand { display: none; }

  .hud,
  .side-actions {
    display: contents;
  }

  .stat-time {
    grid-row: 1;
    grid-column: 1;
  }

  .stat-pairs {
    grid-row: 1;
    grid-column: 2;
  }

  #pause {
    grid-row: 1;
    grid-column: 3;
    width: 38px;
    height: 38px;
  }

  #mute {
    grid-row: 1;
    grid-column: 4;
    width: 38px;
    height: 38px;
  }

  #restart {
    grid-row: 1;
    grid-column: 5;
    justify-self: end;
    width: max-content;
    background: var(--accent);
    color: #0e0e13;
    border-color: var(--accent);
  }

  #restart:hover {
    background: #9498ff;
    border-color: #9498ff;
  }

  .stat-lastpick {
    grid-row: 2;
    grid-column: 1 / 5;
  }

  .stat-moves {
    grid-row: 2;
    grid-column: 5;
    justify-self: end;
    text-align: right;
  }

  .stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .stat .label {
    font-size: 9px;
    letter-spacing: 0.08em;
  }

  .stat .value {
    font-size: 17px;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .pick-value {
    font-size: 13px;
  }

  .icon-btn { width: 38px; height: 38px; }
  .btn-block { padding: 9px 14px; font-size: 13px; }

  /* Stage takes the remaining vertical space (below the top bar). */
  .stage {
    order: 1;
    padding: 8px;
  }

  /* Peek badge scaled down. */
  .peek-badge { top: 14px; right: 14px; padding: 10px 16px; gap: 10px; }
  .peek-badge .peek-count { font-size: 24px; }
}

/* ── Pause overlay (shared by both games) ────────────────── */
.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  background: rgba(14, 14, 19, 0.72);
  backdrop-filter: blur(6px);
  animation: pauseFadeIn 200ms ease-out;
}
.pause-overlay[hidden] { display: none; }

.pause-title {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.pause-sub {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
  max-width: 340px;
  line-height: 1.5;
}
.pause-resume {
  margin-top: 4px;
  min-width: 160px;
}

@keyframes pauseFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (max-width: 768px) {
  .pause-title { font-size: 22px; }
  .pause-sub { font-size: 13px; }
  .pause-resume { width: 80%; }
}
