/* The Loneliest Schoolboy · 词汇游戏营（版式对齐 Human Moles / REFH，配图 contain 不裁切） */

html:has(body.games-app),
html:has(body.games-app) body,
body.games-app {
  height: auto !important;
  min-height: 100dvh !important;
  max-height: none !important;
  display: block !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  padding: 0 !important;
}

body.games-app .games-page {
  width: min(1120px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding: 0 1.1rem 4.5rem;
}

body.games-app .top {
  margin: 0 -0.2rem 1rem;
  border-radius: 0 0 16px 16px;
}

body.games-app .actions {
  position: static !important;
  background: none !important;
  margin-top: 0.75rem;
  padding-top: 0;
}

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

.pic-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  width: 100%;
  background: #1a120c;
  border-radius: 14px;
  overflow: hidden;
}

.pic-frame img,
img.stage-img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  object-position: center;
  display: block;
  background: #1a120c;
}

.stage > .pic-frame {
  max-width: min(100%, 28rem);
  margin: 0 0 0.75rem;
}

.games-hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  align-items: stretch;
  gap: 0;
  background: #122018;
  color: #fff;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 1.2rem;
  min-height: 260px;
}

.games-hero img {
  width: 100%;
  height: 100%;
  min-height: 260px;
  object-fit: contain;
  object-position: center;
  display: block;
  background: #1a120c;
}

.games-hero-copy { padding: 1.5rem 1.5rem 1.3rem; }
.games-hero-copy .kicker {
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--gold);
  font-weight: 800;
}
.games-hero-copy h1,
.games-hero-copy h2 {
  color: #fff;
  font-size: clamp(1.4rem, 2.6vw, 2.05rem);
  margin: 0.35rem 0 0.5rem;
  line-height: 1.2;
}
.games-hero-copy p { color: #d7e4d8; font-weight: 650; line-height: 1.6; margin: 0; }

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

.game-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 20px;
  padding: 0;
  overflow: hidden;
  border: 0;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease;
}
.game-card:hover { transform: translateY(-4px); }
.game-card .cover-wrap {
  aspect-ratio: 4 / 3;
  height: auto;
  background: #1a120c;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.game-card img {
  width: 100%;
  height: 100%;
  max-height: none;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  object-position: center;
  display: block;
}
.game-card .body { padding: 0.75rem 0.9rem 0.95rem; }
.game-card .no {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--sky);
}
.game-card h3 { font-size: 1.08rem; margin: 0.12rem 0 0.2rem; }
.game-card .en { font-size: 0.78rem; color: var(--moss); font-weight: 800; margin-bottom: 0.25rem; }
.game-card p { color: var(--muted); font-weight: 650; font-size: 0.82rem; line-height: 1.45; }
.game-card .tag {
  display: inline-block;
  margin-top: 0.45rem;
  padding: 0.08rem 0.55rem;
  border-radius: 999px;
  background: #e8f4fb;
  color: var(--sky);
  font-size: 0.68rem;
  font-weight: 800;
}

.play-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}
.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  align-items: center;
  background: var(--card);
  border-radius: 14px;
  padding: 0.55rem 0.85rem;
  font-weight: 800;
  color: var(--moss);
}
.hud .muted { color: var(--muted); font-weight: 650; }

.stage {
  background: var(--card);
  border-radius: 20px;
  padding: 1.15rem 1.2rem 1.4rem;
  box-shadow: var(--shadow);
  min-height: 22rem;
}
.prompt { font-size: 1.08rem; font-weight: 800; margin: 0.7rem 0 0.35rem; }
.sub { color: var(--muted); font-weight: 650; margin-bottom: 0.75rem; line-height: 1.5; }

.form-note {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #f3d2a8;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  margin-top: 0.75rem;
  line-height: 1.55;
}

.feedback {
  margin-top: 0.8rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  font-weight: 750;
  display: none;
}
.feedback.show { display: block; }
.feedback.ok { background: #e8f6ee; color: #1f6b3f; }
.feedback.bad { background: #fdecea; color: #9a2f1a; }

.stage .actions,
.match-gate .actions,
.match-hold .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.puzzle-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 1rem;
  align-items: start;
}
.puzzle-grid {
  display: grid;
  gap: 3px;
  user-select: none;
  touch-action: none;
  width: 100%;
  max-width: 32rem;
}
.cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #efe7d6;
  border: 1px solid #d9ccb4;
  font-weight: 800;
  font-size: clamp(0.65rem, 2vw, 1rem);
  cursor: pointer;
}
.cell.on { background: var(--gold); color: #1c241f; }
.cell.found { background: var(--moss); color: #fff; }
.word-list { display: flex; flex-direction: column; gap: 0.45rem; }
.word-item {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem;
  border-radius: 10px;
  background: #fff7e8;
}
.word-item img {
  width: 72px;
  height: 54px;
  object-fit: contain;
  background: #1a120c;
  border-radius: 8px;
  flex-shrink: 0;
}
.word-item b { font-size: 0.82rem; color: var(--moss); display: block; }
.word-item span { font-size: 0.82rem; color: var(--ink); font-weight: 700; }
.word-item .word-hidden { letter-spacing: 0.12em; color: var(--muted); }
.word-item .word-reveal { font-family: inherit; color: var(--moss); }
.word-item.done { opacity: 0.68; }
.word-item.done span { text-decoration: line-through; }

.sent-box {
  font-size: 1.2rem;
  line-height: 2;
  background: #fff7e8;
  border-radius: 14px;
  padding: 1rem;
}
.tok {
  display: inline;
  cursor: pointer;
  border: 0;
  border-bottom: 2px dotted var(--gold-deep);
  padding: 0 2px;
  border-radius: 4px;
  font: inherit;
  font-weight: 800;
  background: none;
}
.tok:hover { background: #fff3c4; }
.tok.picked { background: #fdecea; color: #9a2f1a; }
.tok.right { background: #e8f6ee; color: #1f6b3f; }

.choice-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.choice {
  border: 2px solid #d9ccb4;
  background: #fff;
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.choice:hover { border-color: var(--moss); }
.choice.good { background: var(--ok); color: #fff; border-color: var(--ok); }
.choice.bad { background: var(--claw); color: #fff; border-color: var(--claw); }

.write-box {
  width: 100%;
  border: 2px solid #d9ccb4;
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--ink);
  resize: vertical;
  margin-bottom: 0.7rem;
  background: #fff;
}
.write-box:focus {
  outline: none;
  border-color: var(--moss);
  box-shadow: 0 0 0 4px rgba(47, 106, 74, 0.14);
}
.ai-score {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: #e8f4fb;
}
.ai-score-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 800;
  color: var(--sky);
  margin-bottom: 0.35rem;
}
.ai-score-head b { font-size: 1.35rem; }
.ai-score p { margin: 0.35rem 0 0; color: var(--ink); font-size: 0.92rem; }
.ai-score .ai-better { color: var(--moss); }
.sort-box {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed #d9ccb4;
}

.chip-tray, .chip-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-height: 3.2rem;
  padding: 0.6rem;
  border-radius: 12px;
  margin-bottom: 0.6rem;
}
.chip-tray { background: #fff7e8; border: 2px dashed var(--gold); }
.chip-bank { background: #f4eee2; }
.chip {
  border: 0;
  background: var(--moss);
  color: #fff;
  border-radius: 10px;
  padding: 0.4rem 0.7rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.chip.dist { background: var(--claw); }

.listen-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.listen-opt {
  border: 3px solid transparent;
  border-radius: 14px;
  overflow: hidden;
  padding: 0.4rem;
  cursor: pointer;
  background: #efe7d6;
}
.listen-opt .pic-frame {
  aspect-ratio: 4 / 3;
  height: auto;
  min-height: 0;
  border-radius: 10px;
}
.listen-opt img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  background: #1a120c;
}
.listen-opt:hover { border-color: var(--gold); }
.listen-opt.good { border-color: var(--ok); }
.listen-opt.bad { border-color: var(--claw); }

.play-audio {
  background: var(--moss);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.2rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.match-gate {
  max-width: 34rem;
  margin: 0.4rem auto 0;
  padding: 1.5rem 1.25rem 1.3rem;
  background: #fff7e8;
  border-radius: 20px;
  text-align: center;
}
.match-gate h2 { margin: 0.35rem 0 0.55rem; font-size: 1.45rem; }
.match-gate-kicker {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--moss);
}
.match-steps {
  text-align: left;
  margin: 1rem auto 0.5rem;
  max-width: 22rem;
  padding-left: 1.2em;
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.92rem;
}
.match-timer {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
#match-timer-num {
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--moss);
  line-height: 1;
  min-width: 2ch;
  text-align: right;
}
.match-timer-unit { color: var(--muted); font-weight: 700; }
.match-hold {
  margin-top: 1rem;
  padding: 0.9rem;
  border-radius: 14px;
  background: #e8f6ee;
  text-align: center;
  font-weight: 750;
}
.match-board,
.match-board.group4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  max-width: 46rem;
  margin: 0 auto;
}
.match-card {
  aspect-ratio: 4 / 3;
  border: 0;
  border-radius: 14px;
  background: #1a2a22;
  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: 0.4rem;
}
.match-card .back { font-size: 1.6rem; }
.match-card .face {
  display: none;
  background: #efe7d6;
  color: var(--ink);
  flex-direction: column;
}
.match-card.flipped .back,
.match-card.matched .back { display: none; }
.match-card.flipped .face,
.match-card.matched .face { display: flex; }
.match-card.matched { outline: 3px solid var(--ok); }
.match-card .pic-frame {
  width: 100%;
  height: 100%;
  border-radius: 8px;
}
.match-card img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  background: #1a120c;
  display: block;
}
.match-card .w {
  font-size: clamp(0.9rem, 2vw, 1.25rem);
  line-height: 1.2;
  padding: 0.4rem;
  text-align: center;
}

.result { text-align: center; padding: 1.6rem 0.5rem; }
.result .score {
  width: 7.5rem;
  height: 7.5rem;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--moss), #1a2a22);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.result .score b { font-size: 2rem; line-height: 1; color: #fff; }

@media (max-width: 800px) {
  body.games-app .games-page {
    padding: 0 0.7rem calc(1.2rem + env(safe-area-inset-bottom, 0px));
  }
  body.games-app .top {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem 0.45rem;
  }
  body.games-app .sec-nav {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  body.games-app .sec-nav::-webkit-scrollbar { display: none; }
  .games-hero {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .games-hero img {
    min-height: 0;
    height: auto;
    max-height: min(28vh, 11rem);
    aspect-ratio: 16 / 9;
  }
  .games-hero-copy { padding: 1rem 1rem 0.95rem; }
  .puzzle-layout { grid-template-columns: 1fr; }
  .listen-grid { grid-template-columns: 1fr 1fr; }
  .match-board.group4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #sclass-tts-settings {
    bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 520px) {
  .listen-grid { grid-template-columns: 1fr; }
}
