:root {
  --ink: #f7fbff;
  --text: #142033;
  --muted: #64748b;
  --line: rgba(255, 255, 255, 0.28);
  --panel: rgba(255, 255, 255, 0.88);
  --panel-dark: rgba(13, 23, 42, 0.78);
  --shadow: 0 22px 70px rgba(5, 12, 28, 0.36);
  --accent: #18c79c;
  --accent-2: #ffbd35;
  --danger: #f45b69;
  --good: #23b26d;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: #08111f;
}

button,
input,
select {
  font: inherit;
}

button,
a,
select,
input {
  border-radius: var(--radius);
}

.app {
  min-height: 100dvh;
  background:
    linear-gradient(90deg, rgba(5, 12, 28, 0.78), rgba(5, 12, 28, 0.35) 48%, rgba(5, 12, 28, 0.68)),
    var(--age-bg) center / cover no-repeat;
  transition: background-image 260ms ease;
}

.age-1,
.age-2 {
  --age-bg: url("assets/world-1-2.png");
  --accent: #17b978;
  --accent-2: #ffcf43;
}

.age-3-4 {
  --age-bg: url("assets/world-3-4.png");
  --accent: #15b8d5;
  --accent-2: #ffb52e;
}

.age-5-6 {
  --age-bg: url("assets/world-5-6.png");
  --accent: #2dd4bf;
  --accent-2: #f5a524;
}

.age-7-9 {
  --age-bg: url("assets/world-7-9.png");
  --accent: #22d3ee;
  --accent-2: #f59e0b;
}

.screen {
  width: 100vw;
  height: 100dvh;
  padding: clamp(12px, 2vw, 24px);
}

.hidden {
  display: none !important;
}

.start-screen,
.placement-screen,
.end-screen {
  display: grid;
  place-items: center;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.start-layout,
.end-screen {
  width: min(1220px, 100%);
}

.start-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: clamp(16px, 3vw, 34px);
  align-items: center;
}

.hero-copy {
  max-width: 760px;
  min-width: 0;
  text-shadow: 0 3px 22px rgba(0, 0, 0, 0.62);
}

.kicker {
  margin: 0 0 10px;
  color: #dcfffb;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 11ch;
  font-size: clamp(3.2rem, 6.4vw, 5.9rem);
  line-height: 0.9;
  font-weight: 950;
}

.intro {
  max-width: 42rem;
  margin: 18px 0 0;
  color: #f6fbff;
  font-size: clamp(1.05rem, 1.8vw, 1.35rem);
  font-weight: 750;
  line-height: 1.45;
}

.mission-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.mission-strip span,
.task-pill,
.pill {
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  background: rgba(6, 15, 30, 0.62);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 850;
}

.setup-panel,
.placement-panel,
.challenge-panel,
.map-panel,
.training-panel,
.result-panel,
.leaderboard-panel,
.modal {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.setup-panel {
  display: grid;
  gap: 16px;
  padding: clamp(16px, 2.2vw, 24px);
}

.placement-panel {
  display: grid;
  gap: 16px;
  width: min(720px, 100%);
  padding: clamp(18px, 3vw, 30px);
}

.placement-panel h2 {
  color: #102033;
  font-size: clamp(2rem, 4.8vw, 4rem);
  line-height: 1;
}

.placement-result {
  padding: 16px;
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.07);
}

.placement-result span {
  display: block;
  color: var(--muted);
  font-weight: 850;
}

.placement-result strong {
  display: block;
  margin-top: 4px;
  color: #102033;
  font-size: clamp(1.6rem, 3vw, 2.5rem);
}

.placement-reason {
  margin: 0;
  color: #40516a;
  font-weight: 750;
  line-height: 1.45;
}

label {
  display: grid;
  gap: 7px;
  color: #203049;
  font-weight: 850;
}

input,
select {
  min-height: 46px;
  width: 100%;
  border: 2px solid rgba(15, 23, 42, 0.16);
  background: #fff;
  color: #111827;
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.avatar-picker legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  font-weight: 900;
}

.avatar-picker label {
  place-items: center;
  gap: 6px;
  min-height: 126px;
  padding: 9px 6px;
  border: 2px solid rgba(15, 23, 42, 0.14);
  background: #fff;
  text-align: center;
  cursor: pointer;
}

.avatar-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.avatar-picker label:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.avatar {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  background-color: color-mix(in srgb, var(--accent) 12%, #fff);
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: 112%;
  box-shadow: inset 0 -8px 15px rgba(0, 0, 0, 0.08), 0 8px 18px rgba(15, 23, 42, 0.12);
}

.avatar-grade1 {
  background-image: url("assets/avatar-grade1.png");
}

.avatar-grade2 {
  background-image: url("assets/avatar-grade2.png");
}

.avatar-grade34 {
  background-image: url("assets/avatar-grade34.png");
}

.avatar-grade56 {
  background-image: url("assets/avatar-grade56.png");
}

.avatar-grade79 {
  background-image: url("assets/avatar-grade79.png");
}

.rules {
  padding: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.66);
}

.rules p {
  margin: 5px 0 0;
  color: #42526a;
  line-height: 1.42;
}

.start-actions,
.answer-actions,
.end-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.icon-text-button,
.icon-button,
.sound-icon-button,
.choice-button,
.tile,
.word-chip,
.bin-button {
  border: 0;
  min-height: 44px;
  padding: 0 15px;
  cursor: pointer;
  font-weight: 900;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.sound-icon-button {
  width: 58px;
  min-height: 58px;
  padding: 0;
  border: 2px solid rgba(15, 23, 42, 0.13);
  background: #fff url("assets/icon-sound.png") center / 72% 72% no-repeat;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.13);
}

.sound-icon-button.is-speaking {
  animation: pulseGood 780ms ease-in-out infinite;
  background-color: #fff7c2;
}

.picto {
  display: inline-grid;
  place-items: center;
  width: 1.55em;
  height: 1.55em;
  margin-right: 0.25em;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.1);
  color: currentColor;
  font-weight: 950;
  line-height: 1;
}

.ai-icon {
  display: inline-block;
  flex: 0 0 auto;
  width: 1.65em;
  height: 1.65em;
  margin-right: 0.28em;
  border-radius: 50%;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  vertical-align: -0.38em;
}

.icon-start {
  background-image: url("assets/icon-start.png");
}

.icon-hint {
  background-image: url("assets/icon-hint.png");
}

.icon-check {
  background-image: url("assets/icon-check.png");
}

.icon-sound {
  background-image: url("assets/icon-sound.png");
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), #7cf7cf);
  color: #082019;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 34%, transparent);
}

.secondary-button,
.icon-text-button,
.choice-button,
.tile,
.word-chip,
.bin-button {
  background: #fff;
  color: #172033;
  border: 2px solid rgba(15, 23, 42, 0.13);
}

button:hover,
a.secondary-button:hover {
  transform: translateY(-1px);
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.hud {
  display: grid;
  grid-template-columns: repeat(7, minmax(86px, 1fr)) auto;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 12px;
}

.hud > div,
.hud button {
  min-height: 58px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius);
  background: rgba(5, 12, 28, 0.74);
  color: #fff;
  backdrop-filter: blur(12px);
}

.hud span {
  display: block;
  color: #cfe6ef;
  font-size: 0.78rem;
  font-weight: 850;
}

.hud strong {
  display: block;
  margin-top: 2px;
  font-size: 1.18rem;
}

.expedition {
  display: grid;
  grid-template-columns: minmax(230px, 0.78fr) minmax(380px, 1.55fr) minmax(220px, 0.72fr);
  gap: 12px;
  height: calc(100dvh - 94px);
}

.map-panel,
.training-panel,
.challenge-panel {
  min-height: 0;
  padding: 16px;
}

.map-panel,
.training-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.avatar-display {
  width: 112px;
  height: 150px;
  border-radius: 0;
  background-color: transparent;
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: contain;
  box-shadow: none;
}

.map-panel h2,
.training-panel h2,
.leaderboard-panel h2 {
  color: #102033;
  font-size: clamp(1.2rem, 2vw, 1.7rem);
}

#missionText {
  margin: 0;
  color: #40516a;
  line-height: 1.4;
  font-weight: 700;
}

.progress-shell {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.12);
}

.progress-shell span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 260ms ease;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  min-height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff, var(--accent-2));
  color: #473008;
  font-weight: 950;
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.16);
}

.mini-stats {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.mini-stats div {
  padding: 10px;
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.06);
}

.mini-stats span {
  display: block;
  color: var(--muted);
  font-weight: 850;
  font-size: 0.8rem;
}

.mini-stats strong {
  display: block;
  margin-top: 3px;
}

.challenge-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.challenge-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 12%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 26%),
    radial-gradient(circle at 88% 82%, rgba(255, 189, 53, 0.17), transparent 24%);
}

.challenge-top,
.challenge-host,
.answer-actions,
.feedback {
  position: relative;
}

.challenge-top {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.task-pill {
  background: color-mix(in srgb, var(--accent) 86%, #08111f);
}

.task-pill.muted {
  background: rgba(15, 23, 42, 0.74);
}

.challenge-host {
  display: grid;
  align-content: center;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(8px, 1.8vw, 18px);
}

.prompt {
  display: flex;
  align-items: center;
  gap: 0.35em;
  margin: 0;
  color: #122033;
  font-size: clamp(1.45rem, 3vw, 2.5rem);
  line-height: 1.16;
  font-weight: 950;
}

.subprompt {
  margin: 0;
  color: #43546d;
  font-weight: 760;
  line-height: 1.42;
}

.big-input {
  min-height: 62px;
  font-size: clamp(1.2rem, 2.4vw, 2rem);
  font-weight: 850;
}

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

.choice-button {
  min-height: 70px;
  font-size: clamp(1.05rem, 2vw, 1.55rem);
}

.choice-button.selected,
.word-chip.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, #fff);
}

.tile-row,
.built-word,
.word-row,
.sort-bins {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.tile,
.word-chip {
  min-width: 54px;
  min-height: 50px;
  font-size: 1.12rem;
}

.built-word {
  min-height: 54px;
  align-items: center;
  padding: 10px;
  border: 2px dashed rgba(15, 23, 42, 0.18);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.56);
  color: #132033;
  font-weight: 950;
  font-size: 1.4rem;
}

.sentence-box {
  padding: 16px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.68);
  color: #162033;
  font-size: clamp(1.1rem, 2vw, 1.65rem);
  line-height: 1.45;
  font-weight: 800;
}

.sort-bins {
  align-items: stretch;
}

.bin-button {
  flex: 1 1 180px;
  min-height: 82px;
  padding: 10px;
  white-space: normal;
}

.feedback {
  min-height: 46px;
  margin: 0;
  padding: 11px 12px;
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.07);
  color: #172033;
  font-weight: 850;
  line-height: 1.35;
}

.feedback.good {
  background: color-mix(in srgb, var(--good) 16%, #fff);
  color: #07532f;
}

.feedback.bad {
  background: color-mix(in srgb, var(--danger) 15%, #fff);
  color: #7a1624;
}

.practice-words {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 54px;
  align-content: start;
}

.practice-words span {
  padding: 7px 9px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: #1f2c42;
  font-weight: 850;
}

.training-panel button {
  margin-top: auto;
}

.training-panel button + button {
  margin-top: 0;
}

.end-screen {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
  align-items: center;
}

.result-panel,
.leaderboard-panel {
  width: 100%;
  padding: clamp(16px, 2.4vw, 26px);
}

.result-panel h2 {
  font-size: clamp(2.2rem, 5vw, 5rem);
}

.new-highscore {
  display: inline-flex;
  margin: 10px 0;
  padding: 8px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff36a, #ffbd35);
  color: #442800;
  font-weight: 950;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.result-grid div {
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.07);
}

.result-grid span {
  display: block;
  color: var(--muted);
  font-weight: 850;
  font-size: 0.82rem;
}

.result-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 1.1rem;
}

.final-insight {
  padding: 12px;
  border-left: 5px solid var(--accent);
  background: rgba(15, 23, 42, 0.06);
  line-height: 1.42;
  font-weight: 750;
}

.leader-row {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.11);
}

.leader-row strong,
.leader-row span {
  display: block;
}

.leader-row span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.rank {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-2);
  color: #332000;
  font-weight: 950;
}

.modal {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100dvh - 36px);
  overflow: auto;
  padding: 18px;
  border: 0;
}

.modal::backdrop {
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(5px);
}

.dialog-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 1.45rem;
}

.teacher-report {
  display: grid;
  gap: 10px;
}

.teacher-report div {
  padding: 10px;
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.06);
}

.pulse-good {
  animation: pulseGood 480ms ease;
}

.shake {
  animation: shake 360ms ease;
}

@keyframes pulseGood {
  0%,
  100% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.018);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

@media (max-width: 1080px) {
  .hud {
    grid-template-columns: repeat(4, 1fr);
  }

  .expedition {
    grid-template-columns: 1fr 1.45fr;
  }

  .training-panel {
    display: none;
  }

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

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

  .screen {
    min-height: 100dvh;
    height: auto;
  }

  .start-layout,
  .end-screen,
  .expedition {
    grid-template-columns: 1fr;
  }

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

  .expedition {
    height: auto;
  }

  .choice-grid {
    grid-template-columns: 1fr;
  }

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

  h1 {
    max-width: 100%;
    font-size: clamp(2.35rem, 10.4vw, 3rem);
  }

  .mission-strip {
    max-width: calc(100vw - 24px);
  }
}

/* Staveeventyr task view */
.game-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0)),
    var(--age-bg) center / cover no-repeat;
}

.hud {
  display: grid;
  grid-template-columns: 1.45fr 0.65fr 0.75fr 1.3fr 0.78fr 0.75fr 0.78fr auto auto;
  gap: 0;
  align-items: center;
  margin: 0;
  min-height: 92px;
  padding: 12px 26px;
  border-radius: 0 0 28px 28px;
  background: linear-gradient(180deg, #073f9a, #052a72);
  box-shadow: 0 10px 28px rgba(5, 18, 50, 0.3);
}

.hud > div,
.hud button {
  min-height: 0;
  height: 56px;
  padding: 7px 16px;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.hud button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  margin-left: 8px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.11);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 14px;
  border-left: 0 !important;
  text-transform: uppercase;
}

.brand-mark strong {
  color: #fff;
  font-size: clamp(1.4rem, 2vw, 2rem);
  letter-spacing: 0;
}

.book-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff8c7, #f6b23b);
  box-shadow: inset 0 -7px 0 rgba(97, 48, 0, 0.13), 0 8px 18px rgba(0, 0, 0, 0.18);
}

.book-mark::before {
  content: "";
  display: block;
  width: 34px;
  height: 26px;
  border-radius: 4px 4px 9px 9px;
  background:
    linear-gradient(90deg, #fff 0 48%, #dbeafe 48% 52%, #fff 52%),
    linear-gradient(#fff, #fff);
  box-shadow: 0 0 0 3px #1766d9, 0 -8px 0 -4px #fff;
}

.hud-level strong {
  color: #ffd43b;
  font-size: clamp(1.5rem, 2.5vw, 2.4rem);
}

.hud-focus strong,
.hud-stars strong {
  font-size: clamp(1rem, 1.5vw, 1.35rem);
}

.hud-focus strong {
  max-width: 14ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-left: 0 !important;
  border-radius: 999px !important;
  background: rgba(0, 24, 76, 0.34) !important;
}

.hud-stars > span {
  width: 44px;
  height: 44px;
  clip-path: polygon(50% 0, 61% 33%, 96% 35%, 68% 56%, 78% 91%, 50% 70%, 22% 91%, 32% 56%, 4% 35%, 39% 33%);
  background: linear-gradient(180deg, #fff77b, #ffb323 62%, #e67f00);
  filter: drop-shadow(0 4px 0 rgba(163, 82, 0, 0.45));
}

.hud-hearts {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 25px;
  border-left: 0 !important;
}

.hud-hearts span {
  position: relative;
  width: 24px;
  height: 24px;
  display: block;
  transform: rotate(45deg);
  border-radius: 8px 8px 4px 8px;
  background: linear-gradient(135deg, #ff6b73, #d8193c);
  box-shadow: inset 6px 6px 9px rgba(255, 255, 255, 0.26), 0 4px 8px rgba(120, 4, 24, 0.2);
}

.hud-hearts span::before,
.hud-hearts span::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: inherit;
}

.hud-hearts span::before {
  left: -12px;
}

.hud-hearts span::after {
  top: -12px;
}

.hud-player {
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 0 !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.12) !important;
}

.hud-player::before {
  content: "";
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  margin-right: 8px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.28);
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: 128%;
}

.avatar-token.avatar-grade1,
.avatar-token.avatar-grade1::before {
  background-image: url("assets/avatar-grade1.png");
}

.avatar-token.avatar-grade2,
.avatar-token.avatar-grade2::before {
  background-image: url("assets/avatar-grade2.png");
}

.avatar-token.avatar-grade34,
.avatar-token.avatar-grade34::before {
  background-image: url("assets/avatar-grade34.png");
}

.avatar-token.avatar-grade56,
.avatar-token.avatar-grade56::before {
  background-image: url("assets/avatar-grade56.png");
}

.avatar-token.avatar-grade79,
.avatar-token.avatar-grade79::before {
  background-image: url("assets/avatar-grade79.png");
}

.expedition {
  grid-template-columns: minmax(250px, 0.78fr) minmax(430px, 1.5fr) minmax(250px, 0.78fr);
  gap: 16px;
  height: auto;
  min-height: 0;
  padding: 0 28px;
}

.map-panel,
.training-panel,
.challenge-panel {
  border: 0;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 50px rgba(6, 30, 80, 0.22);
}

.map-panel {
  padding: 12px;
  background: rgba(255, 255, 255, 0.42);
}

.map-card {
  position: relative;
  display: grid;
  align-content: end;
  gap: 10px;
  min-height: 100%;
  overflow: hidden;
  padding: 18px;
  border: 4px solid rgba(255, 255, 255, 0.84);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(2, 65, 25, 0.24)),
    var(--age-bg) center / cover no-repeat;
}

.map-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 26%, rgba(12, 41, 22, 0.2));
  pointer-events: none;
}

.map-card > * {
  position: relative;
  z-index: 1;
}

.map-card .avatar-display {
  position: absolute;
  left: 8px;
  bottom: 6px;
  z-index: 2;
  width: clamp(120px, 11vw, 170px);
  height: clamp(170px, 19vw, 250px);
  filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.28));
}

.map-card h2,
.map-card .mission-badge,
.map-card #missionText {
  margin-left: clamp(82px, 8vw, 130px);
}

.mission-badge {
  justify-self: start;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: #0b3274;
  font-weight: 950;
  text-transform: uppercase;
}

.map-card h2 {
  color: #fff;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.55);
}

.map-card #missionText {
  color: #f8fbff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.path-steps {
  display: grid;
  grid-template-columns: repeat(2, 58px);
  gap: 9px;
  justify-content: center;
  margin-top: 8px;
}

.path-step {
  display: grid;
  place-items: center;
  width: 58px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(180deg, #dfdfe5, #a2a6b0);
  color: #fff;
  font-size: 1.35rem;
  font-weight: 950;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.12), 0 8px 14px rgba(8, 22, 60, 0.18);
}

.path-step.active {
  background: linear-gradient(180deg, #55d374, #159947);
}

.path-step:nth-child(3n + 1).active {
  background: linear-gradient(180deg, #5eb8ff, #116bd7);
}

.path-step:nth-child(3n + 2).active {
  background: linear-gradient(180deg, #ffd449, #f09c12);
}

.challenge-panel {
  padding: clamp(16px, 2vw, 28px);
  background: rgba(255, 255, 255, 0.94);
}

.challenge-top {
  justify-content: center;
}

.task-pill {
  min-width: 150px;
  padding: 9px 16px;
  border: 2px solid rgba(20, 93, 190, 0.16);
  background: #159447;
  text-align: center;
  font-size: 1rem;
}

.task-pill.muted {
  background: rgba(4, 45, 115, 0.88);
}

.challenge-host {
  justify-items: center;
  align-content: center;
  padding: 8px;
}

.prompt {
  justify-content: center;
  width: 100%;
  color: #071b57;
  text-align: center;
  font-size: clamp(1.55rem, 2.4vw, 2.65rem);
  line-height: 1.12;
}

.subprompt {
  color: #3f4560;
  text-align: center;
  font-size: clamp(1rem, 1.35vw, 1.25rem);
}

.sentence-box {
  width: min(100%, 780px);
  padding: 22px 28px;
  border: 2px solid rgba(6, 34, 94, 0.1);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(8, 28, 72, 0.12);
  text-align: center;
  font-size: clamp(1.4rem, 2.6vw, 2.4rem);
}

.choice-grid {
  width: min(100%, 780px);
  grid-template-columns: 1fr;
  gap: 12px;
}

.choice-button {
  min-height: clamp(54px, 7vh, 76px);
  border: 3px solid #6cbcff;
  border-radius: 17px;
  background: linear-gradient(180deg, #f8fcff, #e9f5ff);
  color: #092364;
  font-size: clamp(1.35rem, 2.65vw, 2.35rem);
  box-shadow: inset 0 -4px 0 rgba(20, 93, 190, 0.06);
}

.choice-button:nth-child(2n) {
  border-color: #9d7af0;
  background: linear-gradient(180deg, #fffaff, #f2eaff);
}

.choice-button.selected {
  border-color: #0ba342;
  background: linear-gradient(180deg, #f0fff1, #d9fadf);
  color: #0b722e;
}

.choice-button.selected::after {
  content: "✓";
  float: right;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #2fbd54;
  color: #fff;
}

.big-input {
  width: min(100%, 780px);
  min-height: 74px;
  border: 3px solid #65aaf8;
  border-radius: 17px;
  text-align: center;
  font-size: clamp(1.6rem, 3vw, 2.8rem);
}

.answer-actions {
  justify-content: center;
}

.answer-actions .sound-icon-button {
  order: -1;
}

.feedback {
  width: min(100%, 780px);
  justify-self: center;
  border-radius: 18px;
  text-align: center;
  font-size: 1.05rem;
}

.training-panel {
  align-items: center;
  padding: 20px;
  background: linear-gradient(180deg, rgba(255, 252, 255, 0.97), rgba(244, 238, 255, 0.92));
  text-align: center;
}

.help-figure {
  width: clamp(90px, 10vw, 140px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 30%, #fff5b8 0 18%, transparent 19%),
    radial-gradient(circle at 50% 50%, #92e766 0 45%, #27a943 46% 68%, transparent 69%),
    url("assets/icon-hint.png") center / 58% no-repeat,
    #d9ccff;
  box-shadow: 0 12px 28px rgba(77, 44, 146, 0.18);
}

.training-panel h2 {
  color: #6230b5;
  font-size: clamp(2rem, 3vw, 3rem);
}

.help-rule {
  width: 100%;
  margin: 0;
  padding: 18px;
  border: 3px solid rgba(140, 103, 225, 0.34);
  border-radius: 24px;
  background: #fff;
  color: #111c4a;
  font-size: clamp(1.08rem, 1.45vw, 1.35rem);
  font-weight: 850;
  line-height: 1.35;
}

.practice-words {
  justify-content: center;
}

.game-progress {
  display: grid;
  grid-template-columns: minmax(150px, 0.35fr) minmax(320px, 1fr) minmax(180px, 0.35fr);
  gap: 18px;
  align-items: center;
  margin: 0 28px 18px;
  padding: 14px 26px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.93);
  color: #09215f;
  box-shadow: 0 16px 38px rgba(5, 26, 68, 0.18);
}

.progress-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.2rem;
}

.star-medal {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(180deg, #116deb, #0046b8);
  }

.star-medal::before {
  content: "";
  display: block;
  width: 34px;
  height: 34px;
  clip-path: polygon(50% 0, 61% 33%, 96% 35%, 68% 56%, 78% 91%, 50% 70%, 22% 91%, 32% 56%, 4% 35%, 39% 33%);
  background: linear-gradient(180deg, #fff77b, #ffb323 62%, #e67f00);
}

.star-track {
  display: flex;
  justify-content: center;
  gap: clamp(6px, 1vw, 14px);
  min-width: 0;
}

.progress-star {
  display: grid;
  gap: 2px;
  justify-items: center;
  color: #aeb5c1;
  font-weight: 950;
}

.progress-star span {
  color: #cfd3da;
  font-size: clamp(1.4rem, 2.2vw, 2.2rem);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.09);
}

.progress-star.active span {
  color: #ffbf22;
  text-shadow: 0 2px 0 #dc7b00, 0 5px 12px rgba(245, 166, 35, 0.35);
}

.progress-star small {
  color: #1d2d66;
}

.progress-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 6px 12px;
  font-weight: 850;
}

.progress-summary > strong {
  color: #6230b5;
  font-size: 1.6rem;
}

.age-7-9 .game-screen {
  background:
    linear-gradient(90deg, rgba(3, 11, 24, 0.92), rgba(3, 11, 24, 0.55), rgba(3, 11, 24, 0.88)),
    var(--age-bg) center / cover no-repeat;
}

.age-7-9 .hud {
  border-radius: 0;
  background: linear-gradient(180deg, #061424, #07101d);
}

.age-7-9 .map-panel,
.age-7-9 .training-panel,
.age-7-9 .challenge-panel,
.age-7-9 .game-progress {
  border: 1px solid rgba(125, 185, 255, 0.22);
  background: rgba(6, 22, 38, 0.86);
  color: #eef7ff;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.35);
}

.age-7-9 .map-panel {
  background: rgba(6, 22, 38, 0.58);
}

.age-7-9 .map-card {
  border-color: rgba(125, 185, 255, 0.22);
}

.age-7-9 .challenge-panel {
  background: rgba(8, 30, 50, 0.88);
}

.age-7-9 .prompt,
.age-7-9 .training-panel h2,
.age-7-9 .map-panel h2,
.age-7-9 .progress-summary,
.age-7-9 .progress-title {
  color: #f8fbff;
}

.age-7-9 .sentence-box,
.age-7-9 .feedback,
.age-7-9 .help-rule {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fbff;
  border-color: rgba(125, 185, 255, 0.25);
}

.age-7-9 .choice-button,
.age-7-9 .big-input,
.age-7-9 .tile,
.age-7-9 .word-chip,
.age-7-9 .bin-button {
  background: rgba(8, 30, 50, 0.78);
  color: #f8fbff;
  border-color: rgba(125, 185, 255, 0.34);
}

.age-7-9 .challenge-panel {
  padding: 18px 28px;
}

.age-7-9 .challenge-host {
  gap: 9px;
  align-content: center;
}

.age-7-9 .prompt {
  font-size: clamp(1.45rem, 2vw, 2.05rem);
}

.age-7-9 .subprompt {
  font-size: 1rem;
}

.age-7-9 .choice-grid {
  gap: 8px;
}

.age-7-9 .choice-button {
  min-height: 54px;
  font-size: clamp(1.35rem, 2.25vw, 2.2rem);
}

.age-7-9 .choice-button.selected {
  background: rgba(40, 145, 86, 0.48);
  border-color: #73df8f;
}

@media (max-width: 1080px) {
  .game-screen {
    overflow-y: auto;
  }

  .hud {
    grid-template-columns: repeat(3, 1fr);
    border-radius: 0 0 20px 20px;
  }

  .brand-mark,
  .hud-focus {
    grid-column: span 2;
  }

  .expedition {
    grid-template-columns: minmax(220px, 0.7fr) minmax(360px, 1.3fr);
  }

  .training-panel {
    display: flex;
    grid-column: 1 / -1;
  }

  .game-progress {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .game-screen {
    padding: 0;
  }

  .hud {
    grid-template-columns: repeat(2, 1fr);
    padding: 10px;
  }

  .brand-mark,
  .hud-focus,
  .hud-hearts {
    grid-column: 1 / -1;
  }

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

  .expedition {
    grid-template-columns: 1fr;
    padding: 0 10px;
  }

  .map-panel {
    min-height: 240px;
  }

  .path-steps {
    grid-template-columns: repeat(4, 42px);
  }

  .path-step {
    width: 42px;
    height: 34px;
    font-size: 1rem;
  }

  .prompt {
    font-size: clamp(1.45rem, 7vw, 2.4rem);
  }

  .game-progress {
    margin: 0 10px 10px;
    padding: 12px;
  }

  .star-track {
    overflow-x: auto;
    justify-content: start;
  }

  .desktop-only {
    display: none;
  }
}
