.game-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 10px 0;
  backdrop-filter: blur(10px);
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  width: 100%;
}

.hud-item {
  min-height: 54px;
  border: 1px solid rgba(255, 248, 234, 0.26);
  border-radius: var(--radius);
  padding: 0.45rem 0.65rem;
  color: #fff8ea;
  background: rgba(255, 255, 255, 0.1);
}

.hud-item span {
  display: block;
  color: rgba(255, 248, 234, 0.72);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hud-item strong {
  display: block;
  margin-top: 0.12rem;
  font-size: 1rem;
}

.hero-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(320px, 0.76fr);
  gap: 22px;
  align-items: stretch;
  min-height: calc(100vh - 52px);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 640px;
  padding: clamp(24px, 4vw, 54px);
  color: #fff8ea;
}

.hero-copy h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 5.4rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.hero-copy p {
  max-width: 640px;
  margin: 18px 0 0;
  color: rgba(255, 248, 234, 0.82);
  font-size: 1.18rem;
}

.hero-actions,
.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.field-row {
  margin-top: 22px;
}

.field-row label {
  display: grid;
  gap: 6px;
  flex: 1 1 220px;
  color: #fff8ea;
  font-weight: 800;
}

.field-row input {
  width: 100%;
}

.hero-actions {
  margin-top: 20px;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.castle-scene {
  position: relative;
  min-height: 640px;
  overflow: hidden;
  border: 1px solid rgba(255, 248, 234, 0.3);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(44, 55, 92, 0.95), rgba(44, 91, 96, 0.82)),
    linear-gradient(90deg, transparent 0 22%, rgba(255, 255, 255, 0.05) 22% 23%, transparent 23% 100%);
  box-shadow: var(--shadow);
}

.moon {
  position: absolute;
  top: 34px;
  right: 48px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #ffe9aa;
  box-shadow: 0 0 36px rgba(255, 225, 161, 0.65);
}

.castle {
  position: absolute;
  left: 50%;
  bottom: 74px;
  width: min(460px, 88%);
  height: 360px;
  transform: translateX(-50%);
}

.castle-main,
.tower-left,
.tower-right,
.tower-mid {
  position: absolute;
  bottom: 0;
  border: 3px solid rgba(255, 248, 234, 0.38);
  background: linear-gradient(180deg, #e9d5a7, #b58d66);
}

.castle-main {
  left: 20%;
  width: 60%;
  height: 218px;
  border-radius: 8px 8px 0 0;
}

.tower-left,
.tower-right {
  width: 24%;
  height: 286px;
  border-radius: 8px 8px 0 0;
}

.tower-left {
  left: 0;
}

.tower-right {
  right: 0;
}

.tower-mid {
  left: 38%;
  width: 24%;
  height: 330px;
  border-radius: 8px 8px 0 0;
}

.roof {
  position: absolute;
  left: 50%;
  top: -72px;
  width: 0;
  height: 0;
  border-left: 52px solid transparent;
  border-right: 52px solid transparent;
  border-bottom: 76px solid #824e63;
  transform: translateX(-50%);
}

.tower-mid .roof {
  top: -92px;
  border-left-width: 58px;
  border-right-width: 58px;
  border-bottom-width: 96px;
}

.window {
  position: absolute;
  width: 34px;
  height: 48px;
  border-radius: 18px 18px 4px 4px;
  background: linear-gradient(180deg, #fff3b8, #5ed0bd);
  box-shadow: 0 0 18px rgba(94, 208, 189, 0.55);
}

.window.one {
  left: 22%;
  top: 82px;
}

.window.two {
  right: 22%;
  top: 82px;
}

.window.three {
  left: 50%;
  top: 110px;
  transform: translateX(-50%);
}

.gate {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 80px;
  height: 112px;
  border-radius: 44px 44px 0 0;
  background: #2f2b38;
  transform: translateX(-50%);
  box-shadow: inset 0 0 0 4px rgba(255, 248, 234, 0.16);
}

.crystal-preview {
  position: absolute;
  left: 50%;
  bottom: 22px;
  width: 108px;
  height: 132px;
  transform: translateX(-50%);
}

.crystal-shard {
  position: absolute;
  left: 50%;
  top: 12px;
  width: 64px;
  height: 96px;
  transform: translateX(-50%) rotate(45deg);
  border: 2px solid rgba(255, 248, 234, 0.72);
  background: linear-gradient(135deg, rgba(77, 166, 255, 0.72), rgba(114, 214, 160, 0.9), rgba(255, 224, 110, 0.84));
  box-shadow: 0 0 34px rgba(114, 214, 160, 0.6);
}

.ground {
  position: absolute;
  inset: auto 0 0;
  height: 115px;
  background: linear-gradient(180deg, rgba(31, 84, 77, 0.72), rgba(21, 54, 51, 0.95));
}

.how-panel,
.intro-card,
.map-panel,
.room-panel,
.final-panel,
.certificate-panel {
  padding: clamp(18px, 3vw, 32px);
}

.how-panel {
  max-width: 880px;
  margin: 34px auto;
}

.how-panel h2,
.intro-card h1,
.map-panel h1,
.room-panel h1,
.final-panel h1,
.certificate-panel h1 {
  margin: 0 0 0.7rem;
  color: #18202c;
  line-height: 1.04;
}

.how-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.how-step {
  padding: 16px;
}

.intro-card {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(280px, 0.75fr);
  gap: 24px;
  align-items: center;
  max-width: 1050px;
  margin: 34px auto;
}

.story-text {
  margin: 0;
  font-size: 1.22rem;
}

.french-help {
  display: none;
  margin-top: 14px;
  padding: 12px;
  border-left: 5px solid var(--violet);
  border-radius: var(--radius);
  background: #f1edff;
  font-weight: 700;
}

.french-help.is-visible {
  display: block;
}

.crystal-stage,
.tower-stage {
  position: relative;
  min-height: 300px;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(38, 52, 84, 0.9), rgba(46, 87, 83, 0.86)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 2px, transparent 2px 54px);
  overflow: hidden;
}

.large-crystal {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 112px;
  height: 158px;
  transform: translate(-50%, -50%) rotate(45deg);
  border: 3px solid rgba(255, 248, 234, 0.78);
  background: linear-gradient(135deg, rgba(77, 166, 255, 0.86), rgba(114, 214, 160, 0.86), rgba(255, 224, 110, 0.9));
  box-shadow: 0 0 38px rgba(77, 166, 255, 0.7);
  animation: crystalPulse 2.8s ease-in-out infinite;
}

@keyframes crystalPulse {
  0%,
  100% {
    filter: brightness(1);
    transform: translate(-50%, -50%) rotate(45deg) scale(1);
  }
  50% {
    filter: brightness(1.26);
    transform: translate(-50%, -50%) rotate(45deg) scale(1.04);
  }
}

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

.map-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.progress-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-width: min(420px, 100%);
}

.fragment-chip {
  min-height: 54px;
  border: 2px dashed rgba(24, 32, 44, 0.24);
  border-radius: var(--radius);
  padding: 0.48rem;
  background: rgba(255, 255, 255, 0.55);
  font-weight: 900;
  text-align: center;
}

.fragment-chip.is-earned {
  border-style: solid;
  color: #17213a;
  background: var(--amber-2);
}

.castle-map {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.room-tile,
.final-tile {
  position: relative;
  min-height: 218px;
  border: 2px solid rgba(24, 32, 44, 0.13);
  border-radius: var(--radius);
  padding: 16px;
  overflow: hidden;
  color: #18202c;
  background: #fffdf7;
  text-align: left;
  box-shadow: 0 9px 22px rgba(27, 31, 43, 0.12);
}

.room-tile::after,
.final-tile::after {
  content: "";
  position: absolute;
  inset: auto -12px -28px auto;
  width: 110px;
  height: 110px;
  border: 18px solid rgba(54, 184, 176, 0.16);
  transform: rotate(22deg);
}

.room-tile.is-locked {
  background: #e7e3d7;
}

.room-tile.is-complete {
  border-color: rgba(54, 184, 176, 0.65);
}

.room-tile h2,
.final-tile h2 {
  margin: 0 0 0.35rem;
  font-size: 1.32rem;
  line-height: 1.08;
}

.room-tile p,
.final-tile p {
  margin: 0.2rem 0 0.8rem;
  color: var(--ink-soft);
}

.room-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 12px;
  border-radius: 50%;
  background: #dff6ee;
  font-size: 1.6rem;
}

.lock-label {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 0.22rem 0.65rem;
  color: #fffdf7;
  background: #7a6270;
  font-size: 0.86rem;
  font-weight: 900;
}

.future-map-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.future-map-row button {
  min-height: 38px;
  padding: 0 0.75rem;
  border: 1px solid rgba(24, 32, 44, 0.15);
  color: #4a5668;
  background: rgba(255, 255, 255, 0.65);
  font-weight: 800;
}

.room-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.room-panel {
  min-height: 640px;
}

.room-scene {
  position: sticky;
  top: 92px;
  min-height: 560px;
  padding: 18px;
}

.lesson-visual {
  display: grid;
  place-items: center;
  min-height: 520px;
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(38, 52, 84, 0.26), rgba(46, 87, 83, 0.2)),
    #fff8ea;
}

.lesson-image {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 680px;
  object-fit: cover;
  border-radius: var(--radius);
}

.lesson-visual-fallback {
  gap: 8px;
  padding: 18px;
  color: #fff8ea;
  background: linear-gradient(180deg, #303854, #27392f);
  text-align: center;
}

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

.activity-card {
  padding: 18px;
}

.activity-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.35rem;
}

.activity-card p {
  margin-top: 0;
}

.question-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.question-block legend,
.question-title {
  margin-bottom: 8px;
  font-weight: 900;
}

.option-grid,
.word-bank,
.sequence-grid,
.spell-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.option-btn,
.word-chip,
.ingredient-btn,
.spell-btn,
.small-choice {
  min-height: 48px;
  border: 2px solid rgba(24, 32, 44, 0.14);
  color: var(--ink);
  background: #fffdf7;
  font-weight: 900;
  text-align: center;
}

.option-btn.is-selected,
.word-chip.is-selected,
.ingredient-btn.is-selected,
.spell-btn.is-selected,
.small-choice.is-selected {
  border-color: var(--teal);
  background: #e5fbf7;
}

.option-btn.is-correct,
.small-choice.is-correct {
  border-color: var(--mint);
  background: #e9fff2;
}

.option-btn.is-wrong,
.small-choice.is-wrong {
  border-color: var(--coral);
  background: #fff1eb;
}

.activity-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.hint-box {
  display: none;
  margin-top: 12px;
  border-left: 5px solid var(--amber);
  border-radius: var(--radius);
  padding: 0.8rem;
  background: #fff4d5;
  font-weight: 800;
}

.hint-box.is-visible {
  display: block;
}

.sentence-list,
.spell-build,
.match-board,
.description-board,
.spelling-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.sentence-row,
.spell-answer,
.match-row,
.description-row,
.spelling-row {
  display: grid;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(255, 255, 255, 0.62);
}

.sentence-row {
  grid-template-columns: minmax(130px, 1fr) minmax(120px, 0.55fr) minmax(110px, 1fr);
}

.slot {
  display: grid;
  place-items: center;
  min-height: 46px;
  border: 2px dashed rgba(24, 32, 44, 0.28);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  font-weight: 900;
}

.slot.is-filled {
  border-style: solid;
  border-color: var(--teal);
  background: #e5fbf7;
}

.slot:focus-visible {
  box-shadow: var(--focus);
}

.word-chip[draggable="true"] {
  cursor: grab;
}

.sequence-order {
  display: flex;
  flex-wrap: wrap;
  min-height: 54px;
  gap: 8px;
  align-items: center;
  border: 2px dashed rgba(24, 32, 44, 0.22);
  border-radius: var(--radius);
  padding: 8px;
  background: rgba(255, 255, 255, 0.65);
}

.order-pill {
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  background: #e5fbf7;
  font-weight: 900;
}

.match-row {
  grid-template-columns: minmax(88px, 0.3fr) minmax(160px, 1fr);
}

.description-row {
  grid-template-columns: minmax(0, 1fr) minmax(190px, 0.42fr);
}

.spelling-row {
  grid-template-columns: minmax(90px, 0.25fr) minmax(160px, 1fr);
}

.scrambled {
  display: inline-flex;
  justify-content: center;
  border-radius: var(--radius);
  padding: 0.45rem 0.65rem;
  color: #fffdf7;
  background: #4b456a;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0;
}

.chosen-words {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 50px;
  border: 2px dashed rgba(24, 32, 44, 0.24);
  border-radius: var(--radius);
  padding: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.classroom-scene,
.lab-scene,
.library-scene,
.tower-visual {
  position: relative;
  min-height: 522px;
  overflow: hidden;
  border-radius: var(--radius);
  background: #e9ddc5;
}

.classroom-scene {
  background:
    linear-gradient(180deg, #cbb991 0 54%, #8a694b 54% 100%);
}

.room-door {
  position: absolute;
  right: 26px;
  top: 80px;
  width: 86px;
  height: 180px;
  border-radius: 44px 44px 4px 4px;
  background: #6c3d36;
  box-shadow: inset 0 0 0 4px rgba(255, 248, 234, 0.18);
}

.desk {
  position: absolute;
  left: 68px;
  top: 238px;
  width: 220px;
  height: 110px;
  border-radius: 8px;
  background: #8b553a;
  box-shadow: inset 0 -16px 0 rgba(0, 0, 0, 0.16);
}

.table-leg {
  position: absolute;
  top: 342px;
  width: 22px;
  height: 94px;
  background: #5f392c;
}

.table-leg.left {
  left: 90px;
}

.table-leg.right {
  left: 244px;
}

.book-object {
  position: absolute;
  left: 135px;
  top: 368px;
  width: 76px;
  height: 24px;
  border-radius: 4px;
  background: #c9585a;
  box-shadow: inset 0 0 0 3px rgba(255, 248, 234, 0.28);
}

.bottle-object {
  position: absolute;
  left: 164px;
  top: 176px;
  width: 42px;
  height: 78px;
  border-radius: 16px 16px 8px 8px;
  background: linear-gradient(180deg, #bef0d0 0 26%, #3db26b 26% 100%);
  box-shadow: 0 0 16px rgba(61, 178, 107, 0.54);
}

.chair {
  position: absolute;
  left: 332px;
  top: 274px;
  width: 80px;
  height: 100px;
  border: 12px solid #6a4434;
  border-bottom-width: 24px;
  border-radius: 8px;
}

.wand-object {
  position: absolute;
  left: 430px;
  top: 316px;
  width: 94px;
  height: 8px;
  border-radius: 8px;
  background: #37261e;
  transform: rotate(-18deg);
}

.wand-object::after {
  content: "";
  position: absolute;
  right: -10px;
  top: -7px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffe06e;
  box-shadow: 0 0 18px #ffe06e;
}

.box-object {
  position: absolute;
  right: 132px;
  bottom: 70px;
  width: 106px;
  height: 80px;
  border-radius: 6px;
  background: #b77845;
  box-shadow: inset 0 0 0 4px rgba(255, 248, 234, 0.18);
}

.cat-object {
  position: absolute;
  right: 196px;
  bottom: 118px;
  width: 84px;
  height: 52px;
  border-radius: 50% 50% 42% 42%;
  background: #30303c;
}

.cat-object::before,
.cat-object::after {
  content: "";
  position: absolute;
  top: -18px;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-bottom: 24px solid #30303c;
}

.cat-object::before {
  left: 10px;
}

.cat-object::after {
  right: 10px;
}

.star-row {
  position: absolute;
  right: 22px;
  top: 34px;
  display: flex;
  gap: 12px;
}

.scene-star {
  width: 26px;
  height: 26px;
  background: #ffe06e;
  clip-path: polygon(50% 0, 62% 35%, 100% 35%, 69% 56%, 82% 100%, 50% 72%, 18% 100%, 31% 56%, 0 35%, 38% 35%);
  box-shadow: 0 0 14px #ffe06e;
}

.lab-scene {
  background:
    linear-gradient(180deg, #adbea5 0 45%, #614d47 45% 100%);
}

.lab-shelf {
  position: absolute;
  left: 28px;
  right: 28px;
  top: 72px;
  height: 16px;
  border-radius: 8px;
  background: #704b38;
}

.cauldron {
  position: absolute;
  left: 50%;
  bottom: 84px;
  width: 180px;
  height: 122px;
  border-radius: 0 0 90px 90px;
  background: #2d3942;
  transform: translateX(-50%);
  box-shadow: inset 0 -18px 0 rgba(0, 0, 0, 0.22);
}

.cauldron::before {
  content: "";
  position: absolute;
  left: -12px;
  right: -12px;
  top: -18px;
  height: 34px;
  border-radius: 50%;
  background: #52606c;
}

.potion-bubble {
  position: absolute;
  border-radius: 50%;
  background: rgba(114, 214, 160, 0.78);
  animation: bubble 2.4s ease-in-out infinite;
}

.potion-bubble.one {
  left: 42%;
  top: 230px;
  width: 22px;
  height: 22px;
}

.potion-bubble.two {
  left: 56%;
  top: 210px;
  width: 15px;
  height: 15px;
  animation-delay: 0.4s;
}

.potion-bubble.three {
  left: 50%;
  top: 186px;
  width: 18px;
  height: 18px;
  animation-delay: 0.9s;
}

@keyframes bubble {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.82;
  }
  50% {
    transform: translateY(-18px);
    opacity: 1;
  }
}

.ingredient-prop {
  position: absolute;
  display: grid;
  place-items: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 4px solid rgba(255, 248, 234, 0.42);
  color: #18202c;
  font-weight: 900;
}

.ingredient-prop.red {
  left: 58px;
  bottom: 112px;
  background: #e85555;
}

.ingredient-prop.yellow {
  right: 58px;
  bottom: 112px;
  background: #f4c542;
}

.ingredient-prop.blue {
  left: 78px;
  top: 118px;
  background: #4da6ff;
}

.ingredient-prop.green {
  right: 78px;
  top: 118px;
  background: #54b66f;
}

.ingredient-prop.silver {
  left: 50%;
  top: 106px;
  width: 120px;
  height: 22px;
  border-radius: 999px;
  background: #d7dde7;
  transform: translateX(-50%) rotate(-14deg);
}

.library-scene {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(121, 85, 62, 0.92), rgba(59, 47, 58, 0.96)),
    repeating-linear-gradient(90deg, rgba(255, 248, 234, 0.15) 0 42px, transparent 42px 48px);
}

.creature-card {
  display: grid;
  gap: 8px;
  align-content: start;
  border: 1px solid rgba(255, 248, 234, 0.24);
  border-radius: var(--radius);
  padding: 12px;
  color: #fff8ea;
  background: rgba(24, 32, 44, 0.45);
}

.creature-card h3,
.creature-card p {
  margin: 0;
}

.creature-card p {
  color: rgba(255, 248, 234, 0.8);
  font-size: 0.92rem;
}

.creature-portrait {
  position: relative;
  height: 118px;
  border-radius: var(--radius);
  background: #fff8ea;
  overflow: hidden;
}

.creature-portrait::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.creature-glimfox::before {
  background: #e98043;
  box-shadow: 0 -28px 0 -18px #e98043, -30px -18px 0 -22px #e98043, 30px -18px 0 -22px #e98043;
}

.creature-cloudmoth::before {
  width: 84px;
  height: 52px;
  background: #f2f4f0;
  box-shadow: -42px 0 0 -18px #dce8ef, 42px 0 0 -18px #dce8ef;
}

.creature-blubbit::before {
  background: #4da6ff;
  box-shadow: 32px 14px 0 -24px #4da6ff;
}

.creature-trillbit::before {
  background: #54b66f;
  box-shadow: -16px -18px 0 -26px #fff8ea, 0 -20px 0 -26px #fff8ea, 16px -18px 0 -26px #fff8ea;
}

.tower-visual {
  background:
    linear-gradient(180deg, #303854 0 62%, #27392f 62% 100%);
}

.tower-column {
  position: absolute;
  left: 50%;
  bottom: 44px;
  width: 178px;
  height: 390px;
  border: 3px solid rgba(255, 248, 234, 0.32);
  border-radius: 92px 92px 8px 8px;
  background: linear-gradient(180deg, #c7bfac, #817568);
  transform: translateX(-50%);
}

.tower-window {
  position: absolute;
  left: 50%;
  top: 86px;
  width: 54px;
  height: 86px;
  border-radius: 28px 28px 4px 4px;
  background: #ffe06e;
  transform: translateX(-50%);
  box-shadow: 0 0 28px rgba(255, 224, 110, 0.66);
}

.spell-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 220px;
  height: 220px;
  border: 8px double rgba(255, 224, 110, 0.68);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: ringSpin 12s linear infinite;
}

@keyframes ringSpin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.completion-banner {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border: 2px solid rgba(54, 184, 176, 0.45);
  border-radius: var(--radius);
  padding: 14px;
  background: #edfff4;
}

.final-code-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.final-code-grid label {
  display: grid;
  gap: 6px;
  font-weight: 900;
}

.success-stage {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(260px, 0.5fr);
  gap: 18px;
  align-items: center;
}

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

.result-tile {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fffdf7;
}

.result-tile span {
  display: block;
  color: var(--ink-soft);
  font-size: 0.83rem;
  font-weight: 800;
}

.result-tile strong {
  font-size: 1.2rem;
}

.badge {
  display: grid;
  place-items: center;
  width: 180px;
  height: 180px;
  margin: 0 auto;
  border: 10px solid var(--amber);
  border-radius: 50%;
  color: #17213a;
  background: radial-gradient(circle, #fff8ea 0 42%, #72d6a0 43% 62%, #4da6ff 63% 100%);
  text-align: center;
  font-weight: 900;
  box-shadow: 0 0 30px rgba(255, 224, 110, 0.55);
}

.certificate-panel {
  max-width: 940px;
  margin: 24px auto;
  text-align: center;
}

.certificate-paper {
  position: relative;
  margin: 18px auto;
  border: 8px double #b88d3e;
  border-radius: var(--radius);
  padding: 34px;
  background:
    linear-gradient(135deg, rgba(114, 214, 160, 0.12), transparent 34%),
    linear-gradient(225deg, rgba(77, 166, 255, 0.12), transparent 34%),
    #fff8ea;
}

.certificate-paper h2 {
  margin: 0;
  font-size: 2.2rem;
  line-height: 1.06;
}

.certificate-name {
  margin: 18px 0;
  font-size: 2rem;
  font-weight: 900;
  color: #2f6f73;
}

.print-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 980px) {
  .hero-layout,
  .intro-card,
  .room-layout,
  .success-stage {
    grid-template-columns: 1fr;
  }

  .hero-copy,
  .castle-scene {
    min-height: auto;
  }

  .castle-scene {
    height: 480px;
  }

  .room-scene {
    position: static;
    min-height: auto;
  }

  .lesson-visual {
    min-height: 360px;
  }

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

  .map-header {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .castle-map,
  .how-grid,
  .library-scene,
  .final-code-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

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

  .sentence-row,
  .match-row,
  .description-row,
  .spelling-row {
    grid-template-columns: 1fr;
  }

  .castle {
    width: 94%;
  }

  .room-tile,
  .final-tile {
    min-height: 188px;
  }

  .lesson-visual {
    min-height: 280px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .print-actions,
  .game-topbar {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .certificate-panel {
    box-shadow: none;
    border: 0;
  }
}
