:root {
  color-scheme: light;
  --bg: #fff8e8;
  --surface: #ffffff;
  --ink: #1f2933;
  --muted: #667085;
  --line: #eadfc8;
  --yellow: #ffd166;
  --orange: #f97316;
  --blue: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --lavender: #e8ddff;
  --shadow: 0 18px 48px rgba(37, 35, 30, 0.12);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.16), transparent 28rem),
    linear-gradient(180deg, #fff8e8 0%, #eef7ff 100%);
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.topbar,
.brand,
.section-title,
.session-bar,
.action-row {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  padding: max(6px, env(safe-area-inset-top)) 0 14px;
}

.brand {
  gap: 10px;
}

.brand-mark {
  width: 46px;
  height: 46px;
}

.brand h1,
.hero-copy h2,
.panel h2,
.result-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 1.35rem;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--orange);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.view {
  animation: fade 170ms ease-out;
}

.stack {
  display: grid;
  gap: 14px;
}

.hidden {
  display: none !important;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.field select {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.hero-panel,
.panel,
.result-panel {
  border: 1px solid rgba(234, 223, 200, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  grid-template-columns: 1fr 118px;
  gap: 8px;
  overflow: hidden;
  padding: 18px;
}

.hero-copy h2 {
  max-width: 18ch;
  font-size: clamp(1.25rem, 6vw, 1.85rem);
  line-height: 1.08;
}

.hero-copy p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.hero-mascot {
  align-self: end;
  width: 118px;
  max-width: 100%;
  filter: drop-shadow(0 14px 16px rgba(249, 115, 22, 0.18));
}

.panel {
  padding: 16px;
}

.panel h2 {
  font-size: 1.05rem;
}

.section-title {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.quick-presets,
.table-grid,
.mode-grid,
.stats-grid,
.result-stats {
  display: grid;
  gap: 8px;
}

.quick-presets {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 12px;
}

.table-grid {
  grid-template-columns: repeat(3, 1fr);
}

.table-chip,
.preset,
.small-button,
.text-button,
.mode-card,
.secondary-button,
.primary-button,
.icon-button,
.round-button {
  border-radius: var(--radius);
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.table-chip,
.preset {
  min-height: 44px;
  border: 1px solid var(--line);
  background: #fffaf0;
  color: var(--ink);
  font-weight: 800;
}

.table-chip.active,
.preset:active {
  background: var(--yellow);
  border-color: #f4bb3f;
  box-shadow: inset 0 -3px 0 rgba(160, 94, 0, 0.12);
}

.mode-grid {
  grid-template-columns: repeat(2, 1fr);
}

.mode-card {
  display: grid;
  min-height: 82px;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #f8fbff;
  color: var(--ink);
  text-align: left;
}

.mode-card span {
  color: var(--muted);
  font-size: 0.84rem;
}

.mode-card.active {
  border-color: #7cb3ff;
  background: #eaf4ff;
  box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.18);
}

.mode-options {
  margin-top: 12px;
}

.small-button,
.text-button {
  min-height: 38px;
  padding: 0 12px;
  background: #eaf4ff;
  color: #1457a3;
  font-weight: 800;
}

.text-button {
  min-height: 32px;
  background: transparent;
}

.danger {
  color: var(--red);
}

.stats-grid,
.result-stats {
  grid-template-columns: repeat(3, 1fr);
}

.stat-tile {
  min-height: 70px;
  padding: 10px;
  border-radius: var(--radius);
  background: #f7f7ff;
}

.stat-tile strong {
  display: block;
  font-size: 1.25rem;
}

.stat-tile span {
  color: var(--muted);
  font-size: 0.78rem;
}

.hard-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.hard-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #fff6db;
}

.hard-item span {
  color: var(--muted);
  font-size: 0.8rem;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 54px;
  padding: 0 18px;
  font-weight: 900;
}

.primary-button {
  background: var(--ink);
  color: white;
  box-shadow: 0 12px 24px rgba(31, 41, 51, 0.18);
}

.secondary-button {
  background: #eaf4ff;
  color: #1457a3;
}

.stats-toggle {
  min-height: 44px;
  margin-top: 12px;
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 700;
  text-align: center;
}

.training-view {
  min-height: calc(100dvh - 84px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
}

.session-bar {
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
}

.session-bar span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.round-button,
.icon-button {
  width: 42px;
  height: 42px;
  background: white;
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(31, 41, 51, 0.12);
}

.timer-box {
  min-width: 52px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--yellow);
  font-weight: 900;
  text-align: center;
}

.question-card {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 20px;
  min-height: 340px;
  padding: 22px;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 209, 102, 0.42), rgba(234, 244, 255, 0.92)),
    white;
  box-shadow: var(--shadow);
}

.feedback {
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 999px;
  background: white;
  color: var(--muted);
  font-weight: 900;
}

.feedback.correct {
  background: #dcfce7;
  color: #16703b;
}

.feedback.wrong {
  background: #fee2e2;
  color: #b42318;
}

.question-text {
  font-size: clamp(4rem, 21vw, 8rem);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 0.9;
}

.answer-display {
  min-width: min(70vw, 330px);
  min-height: 78px;
  padding: 10px 20px;
  border: 3px solid white;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
  font-size: 3rem;
  font-weight: 950;
  text-align: center;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-bottom: max(0px, env(safe-area-inset-bottom));
}

.keypad button {
  min-height: 64px;
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  font-size: 1.55rem;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(31, 41, 51, 0.1);
}

.keypad .submit-key {
  background: var(--green);
  color: white;
}

.result-panel {
  padding: 22px;
  text-align: center;
}

.result-panel h2 {
  font-size: 2rem;
}

.action-row {
  gap: 10px;
}

button:active {
  transform: translateY(1px) scale(0.99);
}

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

  .hero-panel {
    grid-template-columns: 1fr 170px;
    padding: 24px;
  }

  .hero-mascot {
    width: 166px;
  }

  .table-grid {
    grid-template-columns: repeat(9, 1fr);
  }
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
