/* Game Center — PaperView-matched light theme */

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

:root {
  --bg:        #fff;
  --bg2:       #f8f9fa;
  --bg3:       #f1f3f5;
  --chip-bg:   #fff;
  --chip-text: #1a1a1a;
  --text-1:    #1a1a1a;
  --text-2:    #6b7280;
  --text-3:    #9ca3af;
  --accent:    #0056b3;
  --correct:   #2e7d32;
  --wrong:     #c62828;
  --border:    #e5e7eb;
  --surface:   #fff;
  --surface2:  #f1f3f5;
  --text:      #1a1a1a;
  --text-dim:  #6b7280;
  --shadow:    rgba(0, 0, 0, 0.04);
  --font-ui:   -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  /* Type colors — readable on white */
  --color-duality:    #1565c0;
  --color-theorem:    #2e7d32;
  --color-conjecture: #e65100;
  --color-claim:      #c62828;
  --color-brane:      #6a1b9a;
  --color-qft:        #00695c;
  --color-gravity:    #bf360c;
  --color-symmetry:   #880e4f;
  --color-spacetime:  #004d40;
  --color-solution:   #33691e;
  --color-default:    #0056b3;
}

html, body {
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-ui);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}

/* ── Layout ── */
.game-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.game-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);            /* themed per game */
  font-family: var(--font-display);
}

.back-link {
  font-size: 12px;
  color: var(--text-3);
  text-decoration: none;
  transition: color 0.15s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
}
.back-link:hover { color: var(--text-1); }

.progress-bar {
  height: 3px;
  background: transparent;   /* no grey track — avoids a 2nd line under the header border */
  border-radius: 2px;
  margin-bottom: 32px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

/* Header controls: refresh, send, flag in the upper right. */
.head-left {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-self: start;
  min-width: 0;
}
.head-actions { display: flex; align-items: center; gap: 2px; }
.head-actions-right { justify-self: end; }
.game-score-label {
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
}
.flag-row, #flag-row { display: flex; align-items: center; justify-content: flex-end; gap: 2px; margin-top: 0; }
#btn-flag {
  background: none; border: none; cursor: pointer; color: var(--text-3);
  opacity: 0.4; padding: 6px; line-height: 0; min-height: 36px; min-width: 36px;
  transition: opacity 0.15s, color 0.15s;
}
#btn-flag:hover { opacity: 1; color: var(--wrong); }
#btn-flag.flagged { opacity: 1; color: var(--wrong); cursor: default; }
#btn-flag svg { width: 14px; height: 14px; display: block; }

#btn-send {
  background: none; border: none; cursor: pointer; color: var(--text-3);
  opacity: 0.45; padding: 6px; line-height: 0; min-height: 36px; min-width: 36px;
  transition: opacity 0.15s, color 0.15s;
}
#btn-send:hover { opacity: 1; color: var(--accent); }
#btn-send svg { width: 15px; height: 15px; display: block; }

.btn-refresh {
  background: none; border: none; cursor: pointer; color: var(--text-3);
  opacity: 0.45; padding: 6px; line-height: 0; min-height: 36px; min-width: 36px;
  transition: opacity 0.15s, color 0.15s;
}
.btn-refresh:hover { opacity: 1; color: var(--accent); }
.btn-refresh svg { width: 15px; height: 15px; display: block; }

/* brief "link copied" toast */
.game-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(8px);
  background: var(--text-1); color: #fff; font-size: 13px; font-weight: 500;
  padding: 9px 16px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease; z-index: 60;
}
.game-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Chip component ── */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--chip-text);
  font-size: 13px;
  font-weight: 400;
  font-family: var(--font-mono);
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  touch-action: manipulation;
  min-height: 44px;
}
.chip:active { transform: scale(0.96); }
.chip.large  { font-size: 16px; padding: 14px 24px; }
.chip.small  { font-size: 12px; padding: 7px 14px; }

.chip.snap {
  animation: spring-snap 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chip.bounce {
  animation: bounce-wrong 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
/* legacy class names */
.chip.snapped {
  animation: spring-snap 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.chip.bounced {
  animation: bounce-wrong 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}
.chip.dragging {
  opacity: 0.75;
  transform: scale(1.06);
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.16);
}

/* ── Keyframes ── */
@keyframes spring-snap {
  0%   { transform: scale(1); }
  25%  { transform: scale(1.15); }
  50%  { transform: scale(0.95); }
  75%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes bounce-wrong {
  0%  { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
  100%{ transform: translateX(0); }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 2px currentColor; }
  50%       { box-shadow: 0 0 0 4px currentColor; }
}

/* ── Glow classes ── */
.glow-duality    { box-shadow: 0 0 0 3px rgba(21,101,192,0.18); }
.glow-theorem    { box-shadow: 0 0 0 3px rgba(46,125,50,0.18); }
.glow-conjecture { box-shadow: 0 0 0 3px rgba(230,81,0,0.18); }
.glow-claim      { box-shadow: 0 0 0 3px rgba(198,40,40,0.18); }
.glow-brane      { box-shadow: 0 0 0 3px rgba(124,58,237,0.18); }
.glow-qft        { box-shadow: 0 0 0 3px rgba(0,105,92,0.2); }
.glow-gravity    { box-shadow: 0 0 0 3px rgba(191,54,12,0.2); }
.glow-symmetry   { box-shadow: 0 0 0 3px rgba(136,14,79,0.18); }
.glow-spacetime  { box-shadow: 0 0 0 3px rgba(0,77,64,0.18); }
.glow-solution   { box-shadow: 0 0 0 3px rgba(51,105,30,0.18); }
.glow-default    { box-shadow: 0 0 0 3px rgba(52,88,164,0.2); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.12s, background 0.15s;
  touch-action: manipulation;
  text-decoration: none;
  min-height: 56px;
  min-width: 44px;
  color: var(--text-1);
  background: var(--bg3);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { opacity: 0.9; }
.btn-ghost   { background: var(--bg3); color: var(--text-1); }
.btn-full    { width: 100%; }

/* ── Cards (VERDICT) ── */
.card-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
.verdict-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 16px;
  min-height: 160px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  touch-action: manipulation;
}
.verdict-card:hover  { border-color: var(--accent); transform: translateY(-2px); }
.verdict-card:active { transform: scale(0.97); }
.verdict-card.chosen {
  border-color: var(--correct);
  box-shadow: 0 0 0 3px rgba(46,125,50,0.16);
}
.verdict-card.unchosen { opacity: 0.35; }
.verdict-type {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.verdict-text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-1);
  flex: 1;
  font-family: var(--font-mono);
}

/* ── Cluster board ── */
.cluster-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.1;
  max-height: 480px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
  touch-action: none;
}
.cluster-chip {
  position: absolute;
  padding: 10px 16px;
  background: var(--chip-bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--chip-text);
  cursor: grab;
  user-select: none;
  transform: translate(-50%, -50%);
  transition: box-shadow 0.2s;
  white-space: nowrap;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cluster-chip:active { cursor: grabbing; }
.cluster-chip.dragging {
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.16);
  cursor: grabbing;
}
.cluster-group {
  position: absolute;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  border-radius: 8px;
  border: 2px solid;
  animation: fade-up 0.3s ease forwards;
}

/* ── Closer ── */
.closer-trio {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}
.closer-chip {
  padding: 18px 20px;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 400;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s, background 0.15s;
  touch-action: manipulation;
  min-height: 52px;
  display: flex;
  align-items: center;
}
.closer-chip:hover  { border-color: var(--accent); }
.closer-chip:active { transform: scale(0.98); }
.closer-chip.selected { border-color: var(--accent); background: rgba(99,102,241,0.12); }
.closer-chip.correct  { border-color: var(--correct); color: var(--correct); animation: spring-snap 0.4s ease; }
.closer-chip.wrong    { border-color: var(--wrong); opacity: 0.4; }
.closer-chip.odd-out  { border-color: var(--wrong); opacity: 0.4; }

/* ── Link game chip states ── */
.chip.correct { border-color: var(--correct); color: var(--correct); background: rgba(46,125,50,0.07); }
.chip.wrong   { border-color: var(--wrong);   color: var(--wrong);   opacity: 0.5; }
.chip.selected { border-color: var(--accent); background: rgba(0,86,179,0.1); color: var(--accent); }

.reveal-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-2);
  animation: fade-up 0.3s ease;
  margin-bottom: 16px;
}

/* ── Link ── */
.link-ends {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.link-end {
  flex: 1;
  padding: 14px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
  min-width: 0;
  word-break: break-word;
}
@media (max-width: 360px) {
  .link-ends { flex-direction: column; }
  .link-arrow { transform: rotate(90deg); }
}
.link-arrow { color: var(--text-3); font-size: 20px; flex-shrink: 0; }
.link-chain {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  min-height: 44px;
  padding: 8px 0;
}
.link-step {
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  animation: fade-up 0.2s ease;
  cursor: pointer;
}
.link-candidates {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ── Hat result ── */
.hat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 40px 28px;
  text-align: center;
  animation: fade-up 0.5s ease;
}
.hat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 12px;
}
.hat-house {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-1);
  margin-bottom: 20px;
  line-height: 1.2;
}
.hat-desc {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-2);
  margin-bottom: 32px;
}
.share-btn {
  background: #1d9bf0;
  color: #fff;
  padding: 14px 28px;
  border-radius: 8px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.12s;
  min-height: 44px;
}
.share-btn:hover  { opacity: 0.9; }
.share-btn:active { transform: scale(0.97); }

/* ── Taste profile (VERDICT result) ── */
.taste-profile {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px 24px;
  text-align: center;
  animation: fade-up 0.4s ease;
}
.taste-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}
.taste-title { font-size: 24px; font-weight: 800; margin-bottom: 14px; }
.taste-desc  { font-size: 15px; color: var(--text-2); line-height: 1.7; margin-bottom: 28px; }
.vote-type-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg3);
  margin-bottom: 8px;
}

/* ── Misc ── */
.round-label {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 20px;
  letter-spacing: 0.05em;
}
.score-display {
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
}
.section-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.3;
}
.section-sub {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 28px;
  line-height: 1.6;
}
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.gap-12 { gap: 12px; }
.mt-16  { margin-top: 16px; }
.mt-24  { margin-top: 24px; }
.hidden { display: none !important; }

@media (max-width: 400px) {
  .card-pair { grid-template-columns: 1fr; }
  .verdict-card { min-height: 120px; }
}
