:root {
  color-scheme: dark;
  --bg: #10151b;
  --panel: #18212a;
  --panel-strong: #202b36;
  --line: #334252;
  --text: #f5f1e8;
  --muted: #b8c2cc;
  --soft: #7f8c99;
  --gold: #f2bd57;
  --gold-dark: #936d26;
  --mint: #69d6a7;
  --coral: #ff8e76;
  --blue: #7db7ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(242, 189, 87, 0.08), transparent 340px),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  width: min(100%, 820px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 32px;
}

.topbar {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.topbar h1,
.section-heading h2,
.hero-panel h2,
.game-status h2,
.finish-panel h2,
.empty-panel h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.08;
}

.topbar h1 {
  font-size: clamp(24px, 5vw, 38px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lead {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hidden {
  display: none !important;
}

.icon-button,
.primary-button,
.secondary-button,
.menu-button {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.icon-button:active,
.primary-button:active,
.secondary-button:active,
.menu-button:active {
  transform: translateY(1px);
}

.icon-button {
  width: 48px;
  height: 48px;
  padding: 0;
  border-color: var(--line);
  background: rgba(24, 33, 42, 0.84);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}

.primary-button {
  padding: 0 18px;
  background: var(--gold);
  color: #171207;
  font-weight: 850;
  border-color: #ffd987;
  box-shadow: 0 10px 24px rgba(242, 189, 87, 0.22);
}

.secondary-button {
  padding: 0 18px;
  background: #24303c;
  color: var(--text);
  font-weight: 750;
  border-color: var(--line);
}

.compact {
  min-height: 42px;
  padding-inline: 14px;
  font-size: 14px;
}

.full-width {
  width: 100%;
}

.hero-panel,
.word-card,
.finish-panel,
.empty-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(24, 33, 42, 0.94);
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 22px;
}

.hero-panel h2 {
  max-width: 620px;
  font-size: clamp(32px, 7vw, 54px);
}

.home-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.stat-box {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #151d25;
}

.stat-box strong {
  display: block;
  color: var(--text);
  font-size: clamp(24px, 7vw, 36px);
  line-height: 1;
}

.stat-box span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.menu-button {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #18212a;
  color: var(--text);
  text-align: left;
  border-color: var(--line);
}

.menu-button span {
  font-size: 18px;
  font-weight: 850;
}

.menu-button small {
  color: var(--muted);
  text-align: right;
}

.section-heading {
  margin: 4px 0 16px;
}

.section-heading h2,
.game-status h2 {
  font-size: clamp(28px, 6vw, 42px);
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.level-card {
  min-height: 118px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #151d25;
  color: var(--text);
  text-align: left;
}

.level-card.available {
  border-color: rgba(242, 189, 87, 0.66);
}

.level-card.done {
  border-color: rgba(105, 214, 167, 0.64);
}

.level-card.locked {
  color: var(--soft);
}

.level-card strong {
  display: block;
  font-size: 24px;
}

.level-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.stars {
  color: var(--gold);
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.preview-list,
.dictionary-list,
.rule-list {
  display: grid;
  gap: 10px;
}

.preview-item,
.dictionary-card,
.rule-list article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #151d25;
}

.preview-item {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: start;
}

.preview-number {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: #263441;
  color: var(--gold);
  font-weight: 850;
}

.preview-item strong,
.dictionary-card strong {
  display: block;
  font-size: 24px;
}

.preview-item span,
.dictionary-card span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.game-status {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.score-pill {
  flex: 0 0 auto;
  padding: 9px 11px;
  border: 1px solid rgba(242, 189, 87, 0.42);
  border-radius: 999px;
  background: rgba(242, 189, 87, 0.13);
  color: var(--gold);
  font-size: 14px;
  font-weight: 850;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #263441;
}

.progress-track div {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--mint));
  transition: width 220ms ease;
}

.session-line {
  margin: 8px 0 12px;
  color: var(--muted);
}

.word-card {
  padding: 18px;
}

.word-display {
  margin: 12px 0 20px;
  color: var(--text);
  font-size: clamp(44px, 15vw, 78px);
  font-weight: 900;
  line-height: 1;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0e1318;
  color: var(--text);
  outline: none;
}

input {
  padding: 0 14px;
  font-size: 18px;
}

select {
  padding: 0 12px;
}

input:focus,
select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(242, 189, 87, 0.18);
}

#answerForm {
  display: grid;
  gap: 12px;
}

.feedback {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.feedback-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.feedback-top strong {
  font-size: 22px;
}

.feedback-top span {
  color: var(--muted);
}

.feedback.correct .feedback-top strong {
  color: var(--mint);
}

.feedback.wrong .feedback-top strong {
  color: var(--coral);
}

.correct-answer {
  margin: 10px 0 12px;
  font-size: 22px;
  font-weight: 850;
}

.examples {
  display: grid;
  gap: 8px;
}

.example {
  padding: 12px;
  border-radius: var(--radius);
  background: #111820;
  border: 1px solid #263441;
}

.example strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.example span {
  color: var(--muted);
}

.feedback-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.finish-panel,
.empty-panel {
  padding: 22px;
}

.finish-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.finish-stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #151d25;
}

.finish-stat strong {
  display: block;
  font-size: 28px;
}

.finish-stat span {
  color: var(--muted);
}

.dictionary-controls {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.dictionary-card.weak {
  border-color: rgba(255, 142, 118, 0.72);
}

.word-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.tag {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: #24303c;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tag.weak {
  background: rgba(255, 142, 118, 0.13);
  color: var(--coral);
}

.dictionary-examples {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.rule-list article p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 10;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 16px;
  border: 1px solid rgba(242, 189, 87, 0.42);
  border-radius: var(--radius);
  background: #1b2530;
  color: var(--text);
  box-shadow: var(--shadow);
}

@media (min-width: 620px) {
  .app-shell {
    padding: 26px 22px 48px;
  }

  .home-actions,
  .feedback-actions,
  .dictionary-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .menu-grid,
  .level-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .menu-button {
    display: grid;
    align-content: space-between;
    min-height: 126px;
  }

  .menu-button small {
    text-align: left;
  }

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

  .feedback-actions {
    align-items: center;
  }
}

@media (max-width: 360px) {
  .app-shell {
    padding-inline: 12px;
  }

  .topbar {
    grid-template-columns: 44px 1fr 44px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
  }

  .hero-panel,
  .word-card,
  .finish-panel,
  .empty-panel {
    padding: 16px;
  }

  .menu-button {
    align-items: start;
    flex-direction: column;
  }

  .menu-button small {
    text-align: left;
  }
}
