/* ===========================================================
   Games — shared stylesheet (extends style.css variables)
   =========================================================== */

.games-hub-header { text-align: center; margin-bottom: 24px; }
.games-hub-header h1 { font-family: var(--font-display); font-size: 26px; margin: 0 0 6px; }
.games-hub-header p { color: var(--ink-soft); margin: 0; }

.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.game-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 18px 14px; text-align: center; text-decoration: none; color: var(--ink);
  transition: transform .15s ease, border-color .15s ease;
}
.game-card:hover { transform: translateY(-3px); border-color: var(--gold-500); }
.game-card .g-emoji { font-size: 34px; display: block; margin-bottom: 8px; }
.game-card .g-name { font-family: var(--font-display); font-weight: 700; font-size: 14px; display: block; margin-bottom: 4px; }
.game-card .g-desc { font-size: 12px; color: var(--ink-soft); }

/* ---------- Common game shell ---------- */
.game-shell { max-width: 480px; margin: 0 auto; }
.game-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.game-topbar h1 { font-family: var(--font-display); font-size: 19px; margin: 0; }
.back-link { color: var(--ink-soft); text-decoration: none; font-size: 13px; font-weight: 600; }

.game-stat-row { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.game-stat { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 14px; font-size: 13px; font-weight: 700; flex: 1; text-align: center; }
.game-stat span { display: block; font-size: 10px; color: var(--ink-soft); font-weight: 500; margin-top: 2px; }

.game-board {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  position: relative;
}

.game-btn {
  background: var(--gold-500); color: var(--navy-900); border: none; padding: 12px 26px; border-radius: 999px;
  font-weight: 700; font-family: var(--font-display); cursor: pointer; font-size: 14px;
}
.game-btn:hover { background: var(--gold-600); }
.game-btn.secondary { background: var(--bg); color: var(--ink); border: 1.5px solid var(--border); }

.game-over-box { text-align: center; }
.game-over-box h2 { font-family: var(--font-display); margin: 0 0 6px; }
.game-over-box .final-score { font-size: 32px; font-weight: 800; color: var(--gold-600); font-family: var(--font-display); margin: 8px 0; }

.name-input-row { display: flex; gap: 8px; margin: 14px 0; max-width: 280px; }
.name-input-row input {
  flex: 1; padding: 10px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--bg); color: var(--ink); font-size: 14px;
}

.mini-leaderboard { margin-top: 20px; width: 100%; max-width: 320px; }
.mini-leaderboard h3 { font-family: var(--font-display); font-size: 14px; margin: 0 0 8px; text-align: center; }
.mini-lb-row { display: flex; justify-content: space-between; padding: 6px 10px; font-size: 13px; border-bottom: 1px solid var(--border); }
.mini-lb-row:last-child { border-bottom: none; }

/* ---------- Memory match ---------- */
.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; max-width: 320px; }
.memory-card {
  aspect-ratio: 1; background: var(--navy-800); border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 24px; cursor: pointer; color: transparent; transition: background .2s;
}
.memory-card.flipped, .memory-card.matched { background: var(--card-bg); border: 1.5px solid var(--gold-500); color: initial; }
.memory-card.matched { opacity: .5; cursor: default; }

/* ---------- Word scramble / hangman ---------- */
.scrambled-word { font-family: var(--font-display); font-size: 32px; letter-spacing: 4px; font-weight: 800; color: var(--gold-600); text-align: center; }
.game-text-input { width: 100%; max-width: 260px; padding: 12px; text-align: center; font-size: 18px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--bg); color: var(--ink); text-transform: uppercase; }
.hangman-word { font-family: var(--font-display); font-size: 26px; letter-spacing: 6px; font-weight: 800; }
.hangman-keyboard { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 340px; }
.hangman-key { width: 34px; height: 34px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--card-bg); color: var(--ink); font-weight: 700; cursor: pointer; }
.hangman-key:disabled { opacity: .35; cursor: default; }
.hangman-key.wrong-key { background: var(--red-500); color: #fff; border-color: var(--red-500); }
.hangman-key.right-key { background: var(--green-500); color: #fff; border-color: var(--green-500); }
.hangman-figure { font-size: 40px; text-align: center; }

/* ---------- Math sprint / typing / GK rapid fire ---------- */
.big-question { font-family: var(--font-display); font-size: 26px; font-weight: 800; text-align: center; }
.answer-options-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.answer-options-mini button {
  padding: 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--card-bg); color: var(--ink);
  font-size: 14px; cursor: pointer; font-weight: 600;
}
.answer-options-mini button.correct { background: rgba(34,197,94,.15); border-color: var(--green-500); }
.answer-options-mini button.wrong { background: rgba(239,68,68,.15); border-color: var(--red-500); }
.typing-prompt { background: var(--bg); border-radius: var(--radius-sm); padding: 14px; font-size: 16px; line-height: 1.6; width: 100%; }
.typing-prompt span.correct-char { color: var(--green-500); }
.typing-prompt span.wrong-char { color: var(--red-500); text-decoration: underline; }
.typing-prompt span.current-char { background: var(--gold-500); color: var(--navy-900); border-radius: 2px; }
.typing-input-hidden { position: absolute; opacity: 0; pointer-events: none; }

/* ---------- Reaction time ---------- */
.reaction-box {
  width: 100%; height: 220px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 18px; font-weight: 700; color: #fff; cursor: pointer; text-align: center;
}
.reaction-box.waiting { background: var(--red-500); }
.reaction-box.ready { background: var(--green-500); }
.reaction-box.idle { background: var(--navy-800); }

/* ---------- Tic Tac Toe ---------- */
.ttt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 260px; }
.ttt-cell {
  aspect-ratio: 1; background: var(--bg); border: 1.5px solid var(--border); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; cursor: pointer; font-family: var(--font-display);
}
.ttt-cell.x { color: var(--gold-600); }
.ttt-cell.o { color: var(--red-500); }

/* ---------- Snake / 2048 canvas ---------- */
#snakeCanvas, #game2048Grid { touch-action: none; }
.grid-2048 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; max-width: 300px; background: var(--navy-800); padding: 8px; border-radius: 12px; }
.tile-2048 { aspect-ratio: 1; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-family: var(--font-display); font-size: 16px; background: rgba(255,255,255,.06); color: var(--ink); }

/* ---------- Whack-a-mole ---------- */
.mole-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 300px; }
.mole-hole {
  aspect-ratio: 1; background: var(--navy-800); border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 28px; cursor: pointer; overflow: hidden;
}
.mole-hole.up { background: var(--navy-700); }

/* ---------- Spin wheel ---------- */
.wheel-wrap { position: relative; width: 260px; height: 260px; }
.wheel-pointer { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); font-size: 26px; z-index: 2; }
#spinWheelCanvas { transition: transform 4s cubic-bezier(.17,.67,.32,1.29); }

/* ---------- Flag guess ---------- */
.flag-display { font-size: 90px; text-align: center; }

/* ---------- Simon says ---------- */
.simon-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 260px; }
.simon-pad { aspect-ratio: 1; border-radius: 16px; cursor: pointer; opacity: .55; border: none; }
.simon-pad.active { opacity: 1; box-shadow: 0 0 20px currentColor; }
.simon-pad.green { background: #22c55e; color: #22c55e; }
.simon-pad.red { background: #ef4444; color: #ef4444; }
.simon-pad.yellow { background: #ffc93c; color: #ffc93c; }
.simon-pad.blue { background: #3b82f6; color: #3b82f6; }

/* ---------- RPS ---------- */
.rps-choices { display: flex; gap: 14px; }
.rps-choices button { font-size: 34px; background: var(--bg); border: 1.5px solid var(--border); border-radius: 50%; width: 66px; height: 66px; cursor: pointer; }
.rps-result { font-family: var(--font-display); font-weight: 700; text-align: center; }

@media (max-width: 400px) {
  .memory-grid, .grid-2048 { max-width: 280px; }
}
