/* ==========================================================================
   Games: flashcards, matching, hangman, listening, quiz
   ========================================================================== */

.game-shell { max-width: 1000px; margin: 0 auto; }

.game-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--sh-1); margin-bottom: 20px;
}
.game-bar .gb-item { display: flex; flex-direction: column; line-height: 1.2; }
.game-bar .gb-item b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.game-bar .gb-item span { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; }

.game-stage {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--sh-2);
  padding: 28px; min-height: 380px;
  display: flex; flex-direction: column;
  position: relative;
}

.game-prompt { text-align: center; margin-bottom: 22px; }
.game-prompt .gp-label {
  font-size: .72rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-4); display: block; margin-bottom: 8px;
}
.game-prompt .gp-word {
  font-size: clamp(1.6rem, 1.2rem + 2vw, 2.6rem);
  font-weight: 800; letter-spacing: -.025em; line-height: 1.1;
}
.game-prompt .gp-sub { color: var(--ink-3); font-size: .88rem; margin-top: 6px; }

/* --- choice buttons ----------------------------------------------------- */
.choices { display: grid; gap: 11px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.choice {
  padding: 15px 18px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1.5px solid var(--border);
  font-size: .98rem; font-weight: 600; text-align: left;
  transition: transform .13s var(--ease), background .16s var(--ease),
              border-color .16s var(--ease), box-shadow .16s var(--ease);
  display: flex; align-items: center; gap: 10px;
}
.choice:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--border-2); }
.choice .ck {
  flex: none; width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center; font-size: .72rem; font-weight: 800;
  background: var(--surface); border: 1px solid var(--border); color: var(--ink-3);
}
.choice.correct {
  background: var(--ok-soft); border-color: var(--ok); color: var(--ok);
  animation: popIn .2s var(--ease-out) both;
}
.choice.correct .ck { background: var(--ok); border-color: var(--ok); color: #fff; }
.choice.wrong {
  background: var(--bad-soft); border-color: var(--bad); color: var(--bad);
  animation: shake .4s var(--ease);
}
.choice.wrong .ck { background: var(--bad); border-color: var(--bad); color: #fff; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

/* --- flip card ---------------------------------------------------------- */
.flip-wrap { perspective: 1400px; max-width: 560px; width: 100%; margin: 0 auto; }
.flip {
  position: relative; width: 100%; aspect-ratio: 8 / 5;
  transform-style: preserve-3d;
  transition: transform .55s var(--ease-out);
  cursor: pointer;
}
.flip.flipped { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: var(--r-xl);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 26px; text-align: center; gap: 10px;
  border: 1.5px solid var(--border); box-shadow: var(--sh-3);
}
.flip-front { background: linear-gradient(150deg, var(--brand-soft), var(--surface)); }
.flip-back  { background: linear-gradient(150deg, var(--accent-soft), var(--surface)); transform: rotateY(180deg); }
.flip-face .ff-word { font-size: clamp(1.6rem, 1.2rem + 2.4vw, 2.9rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.08; }
.flip-face .ff-hint { font-size: .76rem; color: var(--ink-4); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.flip-face .ff-meta { font-size: .78rem; color: var(--ink-3); }

/* --- matching board ----------------------------------------------------- */
.match-board {
  display: grid; gap: 14px;
  grid-template-columns: 1fr 1fr;
  max-width: 760px; margin: 0 auto; width: 100%;
}
.match-col { display: flex; flex-direction: column; gap: 9px; }
.match-item {
  padding: 11px 15px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1.5px solid var(--border);
  font-size: .92rem; font-weight: 600; text-align: left;
  transition: all .16s var(--ease);
}
.match-item:hover:not(:disabled) { border-color: var(--border-2); transform: translateX(2px); }
.match-item.sel { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.match-item.done {
  border-color: var(--ok); background: var(--ok-soft); color: var(--ok);
  opacity: .65; cursor: default;
}
.match-item.err { animation: shake .4s var(--ease); border-color: var(--bad); background: var(--bad-soft); }

/* --- hangman ------------------------------------------------------------ */
.hang-stage { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.hang-word { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.hang-slot {
  width: 40px; height: 54px; border-bottom: 3.5px solid var(--ink-2);
  display: grid; place-items: center;
  font-size: 1.7rem; font-weight: 800; text-transform: lowercase;
}
.hang-slot.revealed { color: var(--ink); animation: popIn .2s var(--ease-out) both; }
.hang-slot.space { border-bottom: 0; width: 22px; }
.hang-keys { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 640px; }
.hang-key {
  width: 38px; height: 42px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1.5px solid var(--border);
  font-weight: 700; font-size: .92rem; text-transform: lowercase;
  transition: all .14s var(--ease);
}
.hang-key:hover:not(:disabled) { background: var(--surface); border-color: var(--border-2); transform: translateY(-2px); }
.hang-key.hit { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.hang-key.miss { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); opacity: .55; }
.lives { display: flex; gap: 5px; }
.lives i {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--brand); display: block;
}
.lives i.lost { background: var(--border); }

/* --- listening ---------------------------------------------------------- */
.listen-btn {
  width: 108px; height: 108px; border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #fff; border: 0; display: grid; place-items: center;
  box-shadow: var(--sh-3); margin: 0 auto 18px;
  transition: transform .16s var(--ease), box-shadow .2s var(--ease);
}
.listen-btn:hover { transform: scale(1.06); box-shadow: var(--sh-4); }
.listen-btn:active { transform: scale(.97); }
.listen-btn svg { width: 44px; height: 44px; }
.listen-btn.playing { animation: pulseRing 1.4s var(--ease) infinite; }
@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent), var(--sh-3); }
  70%  { box-shadow: 0 0 0 22px transparent, var(--sh-3); }
  100% { box-shadow: 0 0 0 0 transparent, var(--sh-3); }
}

/* --- results ------------------------------------------------------------ */
.result-card {
  text-align: center; padding: 34px 26px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.result-card .rc-score {
  font-size: clamp(3rem, 2rem + 6vw, 5rem); font-weight: 800;
  letter-spacing: -.045em; line-height: 1;
  background: linear-gradient(135deg, var(--brand), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.result-card .rc-title { font-size: 1.35rem; font-weight: 700; }
.stars { display: flex; gap: 6px; font-size: 1.6rem; }
.stars span { opacity: .25; transition: opacity .3s var(--ease), transform .3s var(--ease-out); }
.stars span.on { opacity: 1; transform: scale(1.08); }

/* --- game picker tiles -------------------------------------------------- */
.game-tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.game-tile {
  display: flex; flex-direction: column; gap: 8px;
  padding: 20px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--sh-1); text-decoration: none; color: inherit;
  transition: transform .17s var(--ease), box-shadow .2s var(--ease), border-color .17s var(--ease);
  position: relative; overflow: hidden;
}
.game-tile::after {
  content: ""; position: absolute; inset: auto -30% -60% auto;
  width: 150px; height: 150px; border-radius: 50%;
  background: var(--ga, var(--brand-soft)); opacity: .5;
  transition: transform .3s var(--ease);
}
.game-tile:hover { transform: translateY(-4px); box-shadow: var(--sh-3); border-color: var(--border-2); text-decoration: none; color: inherit; }
.game-tile:hover::after { transform: scale(1.25); }
.game-tile .gt-ic { font-size: 1.9rem; position: relative; z-index: 1; }
.game-tile .gt-name { font-weight: 700; font-size: 1.05rem; position: relative; z-index: 1; }
.game-tile .gt-desc { font-size: .84rem; color: var(--ink-3); line-height: 1.45; position: relative; z-index: 1; }
.game-tile .gt-tag { position: relative; z-index: 1; margin-top: 4px; }

/* --- scoreboard --------------------------------------------------------- */
.board { display: flex; flex-direction: column; gap: 2px; }
.board-row {
  display: grid; grid-template-columns: 34px 1fr auto auto; gap: 10px;
  align-items: center; padding: 8px 10px; border-radius: var(--r-sm);
  font-size: .86rem;
}
.board-row:nth-child(odd) { background: var(--surface-2); }
.board-row .br-rank { color: var(--ink-4); font-weight: 700; font-variant-numeric: tabular-nums; }
.board-row .br-score { font-weight: 700; font-variant-numeric: tabular-nums; }

/* progress dots for a game session */
.dots { display: flex; gap: 4px; flex-wrap: wrap; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.dots i.ok { background: var(--ok); }
.dots i.no { background: var(--bad); }
.dots i.cur { background: var(--accent); transform: scale(1.35); }

@media (max-width: 620px) {
  .game-stage { padding: 18px; border-radius: var(--r-lg); }
  .match-board { grid-template-columns: 1fr; }
  .hang-slot { width: 30px; height: 44px; font-size: 1.35rem; }
  .hang-key { width: 32px; height: 38px; font-size: .84rem; }
}
