:root {
  color-scheme: dark;
  --ink: #f4efe4;
  --muted: #b8b0a2;
  --paper: rgba(22, 26, 25, 0.82);
  --line: rgba(244, 239, 228, 0.18);
  --line-strong: rgba(107, 210, 198, 0.72);
  --hot: #e05b38;
  --aqua: #6bd2c6;
  --gold: #e0b84f;
  --green: #84b86f;
  --deep: #121615;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(224, 184, 79, 0.16), transparent 28%),
    radial-gradient(circle at 82% 72%, rgba(107, 210, 198, 0.1), transparent 26%),
    linear-gradient(135deg, #171b19 0%, #232015 43%, #111817 100%);
  font-family:
    "Inter",
    "Noto Sans SC",
    "Microsoft YaHei",
    Arial,
    sans-serif;
}

button {
  font: inherit;
}

#field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  padding: clamp(18px, 3.5vw, 50px);
}

.status-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: clamp(18px, 4vh, 42px);
}

.kicker,
.meter-cell span,
.panel-title span,
.menu-index,
.menu-meta,
.question-meta,
.final-score span,
.result-grid span,
.stat-grid span,
.option-key,
.option-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 8px;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1;
  font-weight: 780;
}

.run-meter {
  display: grid;
  grid-template-columns: repeat(2, 88px);
  gap: 10px;
}

.meter-cell {
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(17, 24, 22, 0.66);
  text-align: right;
}

.meter-cell strong {
  display: block;
  margin-top: 2px;
  color: var(--aqua);
  font-size: 30px;
  line-height: 1;
}

.screen {
  display: none;
  min-height: 0;
}

.shell[data-screen="menu"] .screen-menu,
.shell[data-screen="ban"] .screen-ban,
.shell[data-screen="item"] .screen-item,
.shell[data-screen="quiz"] .screen-quiz,
.shell[data-screen="result"] .screen-result,
.shell[data-screen="end"] .screen-end,
.shell[data-screen="adventure"] .screen-adventure,
.shell[data-screen="gameover"] .screen-gameover,
.shell[data-screen="leaderboard"] .screen-leaderboard,
.shell[data-screen="exit"] .screen-exit {
  display: grid;
}

.screen-menu {
  align-content: center;
  gap: 28px;
}

.menu-track {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 24px);
}

.menu-card,
.option-card,
.question-card,
.stat-grid div,
.result-grid div,
.score-list li,
.final-score {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.menu-card {
  position: relative;
  display: grid;
  min-height: clamp(170px, 24vh, 248px);
  padding: clamp(18px, 3vw, 28px);
  color: var(--ink);
  text-align: left;
  cursor: default;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.menu-card::before,
.option-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid transparent;
  pointer-events: none;
}

.menu-card.is-active {
  transform: translateY(-10px);
  border-color: var(--line-strong);
  background: rgba(34, 44, 39, 0.9);
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.34);
}

.menu-card.is-active::before {
  border-color: rgba(224, 184, 79, 0.58);
}

.menu-title {
  align-self: center;
  font-size: clamp(25px, 3.5vw, 44px);
  font-weight: 780;
  line-height: 1.08;
}

.menu-meta {
  align-self: end;
}

.play-layout,
.result-layout,
.end-layout,
.adventure-layout {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 22px;
}

.panel-title {
  width: min(920px, 100%);
}

.panel-title h2 {
  margin-top: 8px;
  font-size: clamp(28px, 4vw, 50px);
  line-height: 1.1;
}

.direction-grid {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(210px, 1fr) minmax(210px, 1fr);
  grid-template-areas:
    ". up ."
    "left down right";
  gap: 14px;
  width: min(980px, 100%);
}

.answer-grid {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(210px, 1fr) minmax(210px, 1fr);
  grid-template-areas:
    ". up ."
    "left center right"
    ". down .";
  gap: 14px;
  width: min(980px, 100%);
}

.option-card {
  position: relative;
  display: grid;
  align-content: space-between;
  min-height: 142px;
  padding: 20px;
  color: var(--ink);
  text-align: left;
  cursor: default;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.option-card[data-dir="up"] {
  grid-area: up;
}

.option-card[data-dir="right"] {
  grid-area: right;
}

.option-card[data-dir="down"] {
  grid-area: down;
}

.option-card[data-dir="left"] {
  grid-area: left;
}

.option-card.is-active,
.option-card.is-correct {
  border-color: var(--line-strong);
  background: rgba(33, 48, 44, 0.92);
}

.option-card.is-wrong {
  border-color: rgba(224, 91, 56, 0.78);
  background: rgba(48, 28, 22, 0.92);
}

.option-card.is-active {
  transform: translateY(-5px);
}

.option-card.is-active::before {
  border-color: rgba(224, 184, 79, 0.58);
}

.option-key {
  color: var(--gold);
}

.option-title {
  margin-top: 18px;
  font-size: clamp(20px, 2.6vw, 30px);
  font-weight: 760;
  line-height: 1.16;
}

.option-meta {
  margin-top: 14px;
  line-height: 1.5;
}

.quiz-layout {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
}

.question-card {
  width: min(980px, 100%);
  padding: clamp(22px, 4vw, 34px);
}

.question-meta {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.question-card h2 {
  margin-top: 16px;
  font-size: clamp(25px, 3.7vw, 44px);
  line-height: 1.18;
}

#questionFeedback {
  min-height: 28px;
  margin-top: 16px;
  color: var(--gold);
  font-size: 18px;
  line-height: 1.45;
}

.result-grid,
.stat-grid {
  display: grid;
  width: min(920px, 100%);
  gap: 12px;
}

.result-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.result-grid div,
.stat-grid div {
  display: grid;
  gap: 10px;
  min-height: 112px;
  padding: 18px;
}

.result-grid strong,
.stat-grid strong {
  font-size: 42px;
  line-height: 1;
}

.continue-button {
  width: min(260px, 100%);
  min-height: 58px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--deep);
  background: var(--gold);
  font-weight: 820;
}

.final-score {
  display: grid;
  justify-items: center;
  width: min(460px, 100%);
  padding: 28px;
}

.final-score strong {
  color: var(--aqua);
  font-size: clamp(70px, 12vw, 138px);
  line-height: 0.95;
}

.story-card {
  width: min(920px, 100%);
  max-height: 32vh;
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(22, 26, 25, 0.86);
  color: var(--ink);
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.6;
  white-space: pre-wrap;
}

.screen-gameover,
.screen-leaderboard,
.screen-exit {
  align-content: center;
  justify-items: center;
  gap: 24px;
}

.score-list {
  display: grid;
  width: min(760px, 100%);
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: score;
}

.score-list li {
  counter-increment: score;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
}

.score-list li::before {
  content: counter(score, decimal-leading-zero);
  color: var(--gold);
  font-weight: 820;
}

.score-name,
.score-value {
  font-size: 22px;
  font-weight: 760;
}

.score-value {
  color: var(--aqua);
  font-weight: 820;
}

.score-story {
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.exit-mark {
  width: min(720px, 100%);
  padding: 44px 24px;
  border: 1px solid rgba(224, 91, 56, 0.58);
  border-radius: 8px;
  color: var(--hot);
  background: rgba(36, 21, 17, 0.78);
  text-align: center;
  font-size: clamp(36px, 6vw, 78px);
  font-weight: 820;
}

.screen-gameover p,
.screen-exit p {
  color: var(--muted);
  font-size: 20px;
}

.direction-dock {
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(4, 54px);
  gap: 10px;
  padding-top: clamp(16px, 3vh, 30px);
}

.direction-dock span {
  display: grid;
  width: 54px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(18, 22, 21, 0.78);
  color: var(--muted);
  font-size: 23px;
}

.direction-dock span.is-pulse {
  color: var(--deep);
  background: var(--gold);
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .shell {
    min-height: 100vh;
    padding: 16px;
  }

  .status-bar {
    align-items: stretch;
  }

  .run-meter {
    grid-template-columns: 74px;
  }

  .menu-track,
  .result-grid,
  .stat-grid,
  .direction-grid,
  .answer-grid {
    grid-template-columns: 1fr;
    grid-template-areas: none;
  }

  .option-card[data-dir] {
    grid-area: auto;
  }

  .menu-card,
  .option-card {
    min-height: 116px;
  }

  .direction-dock {
    grid-template-columns: repeat(4, 44px);
  }

  .direction-dock span {
    width: 44px;
    height: 40px;
  }
}
