/* game.css — gameplay-specific layout */

/* Pre-game (v2 layout: stacked sections, balanced two-col grid, sticky action bar) */
.pregame-v2 {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 96px; /* room for sticky action bar */
}
.pg-head h1 {
  font-size: 38px;
  margin: 0 0 8px;
  letter-spacing: -.03em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.pg-head .subhead {
  color: var(--fg-2);
  font-size: 15px;
  margin: 0;
}
.pg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.pg-grid > .card { height: 100%; display: flex; flex-direction: column; }

.pg-action-bar {
  position: sticky;
  bottom: 0;
  margin-top: 4px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 1.4fr;
  gap: 14px;
  align-items: center;
  box-shadow: var(--shadow-md);
  z-index: 5;
}
.pg-action-bar .btn-primary { padding: 14px 22px; font-size: 16px; }
.pg-practice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}
.pg-practice-title { font-size: 13px; font-weight: 700; }
.pg-practice-desc { font-size: 11px; color: var(--fg-3); margin-top: 2px; }

/* Legacy class kept for any orphan refs */
.pregame {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
}
.pregame-section { margin-bottom: 18px; }
.pregame-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--fg-3);
  margin: 0 0 8px;
  font-weight: 700;
}
.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.preset-grid .chip {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
}
.preset-grid .chip b { font-size: 13px; color: inherit; }
.preset-grid .chip span { font-size: 11px; opacity: .7; }

.round-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
}

.daily-tile {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  padding: 18px;
  border-radius: 14px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.daily-tile h3 { color: white; margin: 0 0 4px; font-size: 14px; opacity: .9; letter-spacing: .04em; }
.daily-tile .daily-headline { font-size: 22px; font-weight: 800; margin-bottom: 4px; letter-spacing: -.02em; }
.daily-tile .daily-meta { font-size: 12px; opacity: .85; }
.daily-tile .btn {
  background: rgba(255,255,255,.18);
  color: white;
  border-color: rgba(255,255,255,.25);
  margin-top: 12px;
  backdrop-filter: blur(8px);
}
.daily-tile .btn:hover { background: rgba(255,255,255,.28); }
.daily-tile.played::after {
  content: '✓ Played today';
  position: absolute;
  top: 14px; right: 14px;
  background: rgba(0,0,0,.25);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
}

/* Game screen */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

.stage-wrap {
  position: relative;
}

#stage {
  display: block;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  display: grid;
  place-items: center;
  font-size: 80px;
  font-weight: 800;
  opacity: 0;
  transition: opacity .15s ease;
}
.stage-overlay.show-correct { opacity: 1; color: var(--ok); }
.stage-overlay.show-skip    { opacity: 1; color: var(--bad); }

.stage-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: var(--ok);
  opacity: 0;
  transition: opacity .15s ease;
  border-radius: 18px;
}
.stage-flash.flash-ok   { background: var(--ok);  opacity: .25; }
.stage-flash.flash-skip { background: var(--bad); opacity: .25; }

/* Answer area */
.answer-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 14px;
}
.answer-input-wrap {
  position: relative;
}
.answer-input-wrap .input {
  font-size: 18px;
  padding: 14px 56px 14px 18px;
  border-radius: 14px;
  border-width: 2px;
  font-weight: 500;
}
.answer-hint-chip {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--fg-3);
  background: var(--bg-2);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  pointer-events: none;
  user-select: none;
}

.feedback {
  margin-top: 8px;
  min-height: 22px;
  font-size: 14px;
  color: var(--fg-2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.feedback.ok { color: var(--ok); }
.feedback.no { color: var(--bad); }
.feedback.warn { color: var(--warn); }
.feedback .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; animation: pulse-caret 1s ease infinite; }

/* Stats sidebar */
.stats-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 76px;
}
.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.stat-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--fg-3);
  font-weight: 700;
}
.stat-card .value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.stats-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-2);
  overflow: hidden;
  position: relative;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .3s cubic-bezier(.2, .8, .2, 1);
}

/* Modifier toggles in-game */
.modifier-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}
.modifier-bar .small { color: var(--fg-3); margin-right: 6px; }

/* Settings panel */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.panel-backdrop.open { opacity: 1; pointer-events: auto; }

.panel {
  position: fixed;
  top: 0; right: 0;
  width: min(420px, 100vw);
  height: 100vh;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  z-index: 101;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.3, .8, .2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
.panel-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 40px;
}
.panel-section {
  margin-bottom: 22px;
}
.panel-section h4 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--fg-3);
  font-weight: 700;
}
.panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}
.panel-row .label { font-size: 14px; }
.panel-row .desc { font-size: 12px; color: var(--fg-3); }

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute;
  inset: 0;
  background: var(--bg-3);
  border-radius: 999px;
  transition: background .2s ease;
}
.switch span::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform .2s ease;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); }

/* Modifier groups in panel */
.mod-group { margin-bottom: 14px; }
.mod-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.mod-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* Palette swatches */
.palettes {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.palette-swatch {
  aspect-ratio: 1;
  border-radius: 10px;
  cursor: pointer;
  border: 2px solid transparent;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}
.palette-swatch.active { border-color: var(--accent); }
.palette-swatch[data-palette="galaxy"] { display: none; }
.palette-swatch[data-palette="galaxy"].unlocked { display: grid; }

/* End-game / results */
.results {
  max-width: 900px;
  margin: 0 auto;
}
.results h2 {
  font-size: 32px;
  letter-spacing: -.02em;
  margin: 0 0 8px;
}
.results-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.results-summary .stat-card .value { font-size: 24px; }

.results-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}
.review-tile {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: transform .12s ease, border-color .15s ease;
}
.review-tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.review-tile .thumb {
  aspect-ratio: 1;
  background: var(--canvas-bg);
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.review-tile .thumb img {
  max-width: 80%;
  max-height: 80%;
  filter: drop-shadow(0 0 0 var(--silhouette));
}
.review-tile .review-name {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}
.review-tile .review-meta {
  font-size: 11px;
  color: var(--fg-3);
  display: flex;
  justify-content: space-between;
}
.review-tile .badge-correct { color: var(--ok); }
.review-tile .badge-skip    { color: var(--bad); }
.review-tile .badge-wrong   { color: var(--warn); }

/* Mistake review map */
.map-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 20px;
}
.map-wrap h3 { margin: 0 0 12px; font-size: 14px; font-weight: 700; }
.map-svg {
  width: 100%;
  height: auto;
  max-height: 720px;
  display: block;
}
.map-svg path {
  fill: var(--bg-3);
  stroke: var(--border);
  stroke-width: .5;
  cursor: pointer;
  transition: fill .15s ease, opacity .15s ease;
}
.map-svg path.got    { fill: var(--ok); }
.map-svg path.missed { fill: var(--bad); }
.map-svg path.skipped { fill: var(--warn); }
.map-svg path:hover { opacity: .8; stroke-width: 1; }
.map-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  margin-top: 8px;
  color: var(--fg-2);
}
.map-legend .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 4px; }

/* Sidebar "Last round" info card */
.info-card-side {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  animation: fade-in .25s ease;
}
.info-card-side .ic-side-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--fg-3);
  font-weight: 700;
  margin-bottom: 8px;
}
.info-card-side .ic-side-icon {
  display: inline-grid;
  place-items: center;
  width: 18px; height: 18px;
  border-radius: 999px;
  background: var(--bg-2);
  font-size: 12px;
}
.info-card-side .ic-side-head.ic-side-ok .ic-side-icon { background: var(--ok-soft); color: var(--ok); }
.info-card-side .ic-side-head.ic-side-skip .ic-side-icon { background: var(--bad-soft); color: var(--bad); }
.info-card-side .ic-side-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-bottom: 2px;
}
.info-card-side .ic-side-sub {
  font-size: 11px;
  color: var(--fg-3);
  margin-bottom: 8px;
}
.info-card-side .ic-side-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--canvas-bg);
  border-radius: 8px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.info-card-side .ic-side-thumb img {
  max-width: 80%; max-height: 80%;
}
.info-card-side .ic-row {
  display: flex;
  gap: 6px;
  font-size: 12px;
  color: var(--fg-2);
  margin-bottom: 3px;
}
.info-card-side .ic-label { color: var(--fg-3); min-width: 80px; }
.info-card-side .ic-flag { display: inline-flex; gap: 2px; }
.info-card-side .ic-flag-band { width: 10px; height: 14px; border-radius: 2px; border: 1px solid rgba(0,0,0,.15); }
.info-card-side .ic-fact { font-size: 12px; color: var(--fg-2); margin-top: 6px; font-style: italic; line-height: 1.4; }

/* Brand button hover (so users discover it goes home mid-game) */
.brand {
  cursor: pointer;
  padding: 4px 8px 4px 4px;
  border-radius: 10px;
  transition: background .15s ease, transform .15s ease;
  position: relative;
}
.brand:hover {
  background: var(--bg-2);
}
.brand::after {
  content: '↩ Menu';
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--fg-3);
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}
.brand:hover::after { opacity: 1; }
.brand:active { transform: scale(.97); }

/* Modifier preview pane (collapsible) */
.mod-preview-details {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.mod-preview-details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--fg-3);
  font-weight: 700;
  transition: background .15s ease;
  user-select: none;
}
.mod-preview-details > summary::-webkit-details-marker { display: none; }
.mod-preview-details > summary:hover { background: var(--bg-2); color: var(--fg); }
.mod-preview-details .mp-toggle { transition: transform .2s ease; font-size: 14px; }
.mod-preview-details[open] .mp-toggle { transform: rotate(180deg); }

.mod-preview {
  margin-top: 8px;
  background: var(--canvas-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: fade-in .2s ease;
}
.mod-preview canvas {
  width: 100%;
  max-width: 240px;
  aspect-ratio: 1;
  background: var(--canvas-bg);
  border-radius: 8px;
}

/* Toast */
.toast-stack {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  max-width: 360px;
  animation: pop .22s ease;
}
.toast.toast-ok { border-color: var(--ok); }
.toast.toast-bad { border-color: var(--bad); }
.toast.toast-warn { border-color: var(--warn); }
.toast.toast-achievement {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border: none;
}
.toast .ico { font-size: 18px; }
.toast .body { flex: 1; }
.toast .body b { display: block; font-weight: 700; }
.toast .body span { display: block; font-size: 11px; opacity: .8; }

/* Confetti canvas */
#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
}

/* Hint chip in-game */
.hint-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.hint-bubble {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  animation: pop .2s ease;
}
.btn-hint {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-size: 12px;
  padding: 6px 12px;
}
.btn-hint:hover { background: var(--accent); color: white; }
.btn-hint.pulse {
  animation: hint-pulse 1s ease infinite;
}
@keyframes hint-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); }
  50% { box-shadow: 0 0 0 10px transparent; }
}

/* Stats / Achievements page */
.stats-page {
  max-width: 1000px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.stats-page h2 { font-size: 26px; margin: 0 0 12px; }
.stats-page h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-3); }

.achievement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.ach {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  position: relative;
}
.ach.locked { opacity: .35; filter: grayscale(.7); }
.ach .ach-ico { font-size: 28px; line-height: 1; margin-bottom: 4px; }
.ach .ach-name { font-size: 12px; font-weight: 700; }
.ach .ach-desc { font-size: 10px; color: var(--fg-3); margin-top: 3px; }

.miss-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.miss-list .miss-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-2);
  border-radius: 8px;
  font-size: 13px;
}
.miss-list .miss-row .pct { color: var(--bad); font-weight: 600; }

/* Leaderboard */
.board {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.board-row {
  display: grid;
  grid-template-columns: 48px 1fr 100px 90px 140px;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  align-items: center;
}
.board-row.head {
  background: var(--bg-2);
  color: var(--fg-3);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .06em;
}
.board-row:not(.head) { border-top: 1px solid var(--border); }
.board-row .rank { font-weight: 700; color: var(--fg-3); }
.board-row .rank.gold { color: #f5c454; }
.board-row .rank.silver { color: #c1c8d0; }
.board-row .rank.bronze { color: #cd8e5c; }

/* Mobile */
@media (max-width: 900px) {
  .pregame { grid-template-columns: 1fr; }
  .game-layout { grid-template-columns: 1fr; }
  .stats-side {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    overflow-x: auto;
  }
  .stat-card { flex-shrink: 0; min-width: 110px; padding: 8px 12px; }
  .stat-card .value { font-size: 18px; }
  .stats-grid-2 { display: contents; }
  .stats-page { grid-template-columns: 1fr; }
  .results-summary { grid-template-columns: repeat(2, 1fr); }
  .preset-grid { grid-template-columns: repeat(2, 1fr); }
  .round-grid { grid-template-columns: repeat(5, 1fr); }
  .panel { width: 100vw; }
  .info-card { left: 8px; right: 8px; transform: translateY(20px); min-width: 0; max-width: none; }
  .info-card.show { transform: translateY(0); }
}

/* iOS keyboard awareness */
@supports (-webkit-touch-callout: none) {
  .answer-input-wrap .input { font-size: 16px; }
}
