/* REFH 09 · Harrison's Heroes vocab games */

.games-page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 20px 80px;
}

.games-hero {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 0;
  background: #0f2438;
  color: #fff;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  min-height: 260px;
}

.games-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  min-height: 260px;
  display: block;
}

.games-hero-copy { padding: 28px 28px 24px; }
.games-hero-copy .kicker {
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: .72rem;
  color: #e4c76a;
  font-weight: 700;
}
.games-hero-copy h1 {
  font-family: var(--font-display);
  margin: 8px 0 10px;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1.2;
}
.games-hero-copy p { margin: 0; color: #e8eef4; line-height: 1.65; }

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  box-shadow: var(--shadow);
  padding: 0;
  transition: transform .18s ease, border-color .18s;
}
.game-card:hover { transform: translateY(-4px); border-color: var(--primary); }
.game-card img { width: 100%; height: 132px; object-fit: cover; display: block; }
.game-card .body { padding: 14px 16px 16px; }
.game-card .no { font-size: .75rem; font-weight: 800; color: var(--primary); letter-spacing: .06em; }
.game-card h3 { margin: 4px 0 4px; font-size: 1.08rem; color: var(--text); }
.game-card .en { font-size: .78rem; color: var(--accent); font-weight: 700; margin-bottom: 6px; }
.game-card p { font-size: .82rem; color: var(--muted); }
.game-card .tag {
  display: inline-block;
  margin-top: 8px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: .72rem;
  font-weight: 700;
}

.play-wrap { display: none; }
.play-wrap.on { display: block; }
.hub-wrap.off { display: none; }

.play-top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 700;
  color: var(--primary);
}
.hud .muted { color: var(--muted); font-weight: 600; }

.stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
  min-height: 320px;
}

.stage-img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 14px;
  display: block;
  margin-bottom: 14px;
  background: #e8eef2;
}
.stage-img.storyboard {
  max-height: 380px;
}

.prompt { font-size: 1.05rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.sub { color: var(--muted); font-size: .9rem; margin-bottom: 12px; }
.form-note {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: .85rem;
  margin-top: 12px;
}
.feedback {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 700;
  display: none;
}
.feedback.show { display: block; }
.feedback.ok { background: #ecfdf5; color: #047857; }
.feedback.bad { background: #fef2f2; color: #b91c1c; }

/* Word puzzle */
.puzzle-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 16px;
  align-items: start;
}
.puzzle-grid {
  display: grid;
  gap: 3px;
  user-select: none;
  touch-action: none;
  width: 100%;
  max-width: 560px;
}
.cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #eef3f8;
  border: 1px solid #c5d4e4;
  font-weight: 800;
  font-size: clamp(.7rem, 2.4vw, 1rem);
  color: #1a3a5c;
  cursor: pointer;
}
.cell.on { background: #f97316; color: #fff; border-color: #ea580c; }
.cell.found { background: #1a3a5c; color: #fff; border-color: #1a3a5c; }
.word-list { display: flex; flex-direction: column; gap: 8px; }
.word-item {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}
.word-item img { width: 56px; height: 40px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.word-item b { font-size: .82rem; color: var(--primary); display: block; }
.word-item span { font-size: .82rem; color: var(--text); font-weight: 700; }
.word-item .word-hidden {
  display: none;
}
.word-item .word-reveal {
  font-family: var(--font-display);
  color: #047857;
}
.word-item.done { opacity: .72; }
.word-item.done span { text-decoration: line-through; }

/* Spelling */
.sent-box {
  font-size: 1.2rem;
  line-height: 2;
  background: #f8fafc;
  border-radius: 14px;
  padding: 16px;
}
.tok {
  display: inline;
  cursor: pointer;
  border-bottom: 2px dotted #c9a227;
  padding: 0 2px;
  border-radius: 4px;
}
.tok:hover { background: #e0f2fe; }
.tok.picked { background: #fee2e2; color: #b91c1c; }
.tok.right { background: #d1fae5; color: #047857; border-bottom-color: #10b981; }

.choice-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.choice {
  border: 2px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 800;
  color: var(--primary);
  cursor: pointer;
}
.choice:hover { border-color: var(--primary); background: var(--primary-light); }
.choice.good { background: #059669; color: #fff; border-color: #059669; }
.choice.bad { background: #e11d48; color: #fff; border-color: #e11d48; }

/* Sentence builder */
.write-box {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text);
  resize: vertical;
  margin-bottom: 12px;
  background: #fff;
}
.write-box:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(26, 58, 92, .12);
}
.btn.is-rec {
  background: #e11d48;
  color: #fff;
  border-color: #e11d48;
  animation: recpulse 1s ease-in-out infinite;
}
@keyframes recpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, .45); }
  50% { box-shadow: 0 0 0 8px rgba(225, 29, 72, 0); }
}
.ai-score {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #eef3f8;
  border: 1px solid #c5d4e4;
}
.ai-score-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 800;
  color: #1a3a5c;
  margin-bottom: 6px;
}
.ai-score-head b { font-size: 1.35rem; color: #1a3a5c; }
.ai-score p { margin: 6px 0 0; color: #3d4f63; font-size: .92rem; }
.ai-score .ai-better { color: #0f766e; }
.sort-box {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.chip-tray, .chip-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 52px;
  padding: 10px;
  border-radius: 12px;
  margin-bottom: 10px;
}
.chip-tray {
  background: #eef3f8;
  border: 2px dashed #c9a227;
}
.chip-bank { background: #f8fafc; border: 1px solid var(--border); }
.chip {
  border: 0;
  background: #1a3a5c;
  color: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.chip.dist { background: #c2410c; }
.chip.ghost { opacity: .35; }

/* Listen */
.listen-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.listen-opt {
  border: 3px solid transparent;
  border-radius: 14px;
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  background: #0f2438;
}
.listen-opt img { width: 100%; height: 168px; object-fit: cover; display: block; }
.listen-opt:hover { border-color: #e4c76a; }
.listen-opt.good { border-color: #059669; }
.listen-opt.bad { border-color: #e11d48; }

.play-audio {
  background: linear-gradient(135deg, #1a3a5c, #0f2438);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  margin-bottom: 12px;
}

/* Match · 每组 4 词 4 图（8 张牌） */
.match-gate {
  max-width: 560px;
  margin: 8px auto 0;
  padding: 28px 24px 24px;
  background: linear-gradient(180deg, #eef3f8, #fff);
  border: 1px solid var(--border);
  border-radius: 20px;
  text-align: center;
}
.match-gate h2 {
  margin: 6px 0 10px;
  font-size: 1.45rem;
  color: var(--text);
}
.match-gate-kicker {
  letter-spacing: .12em;
  text-transform: uppercase;
  font-size: .72rem;
  font-weight: 800;
  color: var(--primary);
}
.match-gate .actions { justify-content: center; }
.match-steps {
  text-align: left;
  margin: 16px auto 8px;
  max-width: 320px;
  padding-left: 1.2em;
  color: var(--muted);
  line-height: 1.7;
  font-size: .92rem;
}
.match-timer {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}
#match-timer-num {
  font-size: 2.4rem;
  font-weight: 900;
  color: #1a3a5c;
  line-height: 1;
  min-width: 2ch;
  text-align: right;
}
.match-timer-unit { color: var(--muted); font-weight: 700; }
.match-hold {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  text-align: center;
}
.match-hold p { margin: 0; color: #065f46; font-weight: 700; }
.match-hold .actions { justify-content: center; }
.match-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.match-board.group4 {
  grid-template-columns: repeat(4, 1fr);
  max-width: 720px;
  margin: 0 auto;
}
.match-card {
  aspect-ratio: 1.15;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(160deg, #1a3a5c, #0f2438);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  padding: 0;
}
.match-card:disabled { cursor: default; }
.match-card .back, .match-card .face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
}
.match-card .back { font-size: 1.6rem; }
.match-card .face { display: none; background: #fff; color: var(--primary); }
.match-card.flipped .back, .match-card.matched .back { display: none; }
.match-card.flipped .face, .match-card.matched .face { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.match-card.matched { outline: 3px solid #059669; }
.match-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.match-card .w { font-size: 1.05rem; padding: 8px; font-weight: 800; }
.match-card .cn, .match-card [lang="zh"], .match-face-cn { display: none !important; }

.result {
  text-align: center;
  padding: 28px 12px;
}
.result .score {
  width: 120px;
  height: 120px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: linear-gradient(135deg, #1a3a5c, #0f2438);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.result .score b { font-size: 2rem; line-height: 1; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

@media (max-width: 800px) {
  .games-hero { grid-template-columns: 1fr; }
  .puzzle-layout { grid-template-columns: 1fr; }
  .match-board,
  .match-board.group4 { grid-template-columns: repeat(4, 1fr); }
  .listen-opt img { height: 110px; }
}

@media (max-width: 520px) {
  .match-board.group4 { grid-template-columns: repeat(2, 1fr); }
  .listen-grid { grid-template-columns: 1fr; }
}
