:root {
  color-scheme: dark;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  --ink: #17152d;
  --cream: #fff7df;
  --purple: #6d57cd;
  --purple-dark: #3a2f83;
  --green: #6ff0a3;
  --red: #ff6f7d;
}

[hidden] {
  display: none !important;
}

.home-screen {
  position: relative;
  display: grid;
  width: 100%;
  height: 100dvh;
  min-height: 560px;
  place-items: safe center;
  overflow: auto;
  padding: 90px 20px 30px;
  background:
    radial-gradient(circle at 75% 18%, rgb(255 246 194 / 25%), transparent 24%),
    linear-gradient(160deg, #11152f 0%, #394472 58%, #b85e64 100%);
  color: white;
}

.home-screen::before,
.home-screen::after {
  content: "";
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -12%;
  height: 44%;
  border-radius: 50% 50% 0 0;
  background: #171b38;
  transform: rotate(-3deg);
}

.home-screen::after {
  bottom: -25%;
  background: #10142c;
  transform: rotate(4deg);
}

.home-header {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  z-index: 2;
}

.vocabulary-editor {
  width: min(900px, calc(100% - 24px));
  max-height: 90dvh;
  overflow: auto;
  border: 3px solid #b9b1d0;
  border-radius: 20px;
  padding: 20px;
  background: var(--cream);
  color: var(--ink);
}

.vocabulary-editor::backdrop {
  background: rgb(7 8 28 / 75%);
}

.vocabulary-editor fieldset {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.editor-toolbar > label {
  flex: 1 1 160px;
  min-width: 0;
}

.vocabulary-editor label,
.editor-entry {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.vocabulary-editor input,
.vocabulary-editor select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 2px solid #b9b1d0;
  border-radius: 10px;
  padding: 10px;
  background: white;
  color: var(--ink);
  font: inherit;
}

.editor-import {
  margin-top: 16px;
}

.editor-list {
  display: grid;
  gap: 8px;
  max-height: 28dvh;
  overflow: auto;
  padding: 0;
  list-style: none;
}

.editor-list button {
  width: 100%;
  padding: 12px;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.editor-entry,
#importPreview {
  border-top: 2px solid #b9b1d0;
  padding-top: 12px;
}

.home-card {
  position: relative;
  width: min(660px, 100%);
  border: 3px solid rgb(255 255 255 / 55%);
  border-radius: 30px;
  box-shadow: 0 22px 70px rgb(7 8 28 / 48%);
  background: rgb(255 247 223 / 94%);
  color: var(--ink);
  padding: clamp(24px, 5vw, 46px);
  text-align: center;
  backdrop-filter: blur(12px);
  z-index: 1;
}

.home-card .eyebrow {
  margin: 0;
  color: var(--purple-dark);
  font-size: .8rem;
  font-weight: 1000;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.home-card h1 {
  margin: 8px 0 28px;
  font-size: clamp(1.8rem, 6vw, 3rem);
}

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

.mode-button {
  display: grid;
  min-height: 125px;
  place-content: center;
  gap: 7px;
  border: 0;
  border-radius: 22px;
  box-shadow: 0 7px 0 #352777, 0 12px 22px rgb(53 39 119 / 24%);
  color: white;
  padding: 20px;
  cursor: pointer;
}

.mode-button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #352777;
}

.mode-button span {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 1000;
}

.mode-button small {
  font-weight: 700;
}

.mode-button-english {
  background: linear-gradient(180deg, #8973ea, #5d45c3);
}

.mode-button-latin {
  background: linear-gradient(180deg, #e59b51, #b95f42);
}

.home-balance {
  margin: 25px 0 0;
  color: #625e75;
  font-weight: 800;
}

.lesson-options {
  display: grid;
  gap: 8px;
  max-height: 32dvh;
  overflow-y: auto;
  text-align: left;
}

.nickname-form {
  margin-bottom: 24px;
  text-align: left;
}

.nickname-form > label {
  display: block;
  margin-bottom: 8px;
  font-weight: 900;
}

.nickname-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.nickname-actions input {
  flex: 1 1 180px;
  min-width: 0;
  border: 2px solid #b9b1d0;
  border-radius: 12px;
  padding: 12px;
  background: white;
  color: var(--ink);
  font: inherit;
}

#profileStatus {
  font-size: .9rem;
}

.lesson-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 2px solid #c8bfdc;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
}

.lesson-option input {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  accent-color: var(--purple-dark);
}

.all-lessons {
  margin-bottom: 12px;
  font-weight: 900;
}

.lesson-group {
  display: grid;
  gap: 6px;
}

.page-selection {
  margin-left: 34px;
  text-align: left;
}

.page-selection summary {
  cursor: pointer;
  color: #625e75;
  font-size: .9rem;
  font-weight: 800;
}

.page-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.page-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 2px solid #c8bfdc;
  border-radius: 10px;
  cursor: pointer;
  font-size: .9rem;
}

.page-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--purple-dark);
}

.lesson-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

#startLessons {
  background: var(--purple-dark);
  color: white;
}

.answer-actions {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  justify-content: flex-end;
  gap: 10px;
}

.skip-button {
  min-height: 48px;
  border: 2px solid #b9b1d0;
  border-radius: 15px;
  background: #e9e4f2;
  color: #4a4560;
  font-weight: 900;
  padding: 0 17px;
  cursor: pointer;
}

.skip-button:active {
  transform: translateY(2px);
}

.skip-button:disabled {
  cursor: wait;
  opacity: .6;
}

* {
  box-sizing: border-box;
}

.potion-button {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  border: 2px solid rgb(255 255 255 / 35%);
  border-radius: 18px;
  box-shadow: 0 7px 20px rgb(0 0 0 / 30%);
  background: rgb(25 27 59 / 86%);
  color: white;
  padding: 7px 14px;
  text-align: left;
  backdrop-filter: blur(9px);
  z-index: 4;
  cursor: pointer;
}

.potion-button:disabled {
  cursor: default;
  filter: grayscale(1);
  opacity: .58;
}

.potion-button:not(:disabled) {
  animation: potionReady 1.4s ease-in-out infinite alternate;
}

.potion-button span:last-child {
  display: grid;
}

.potion-button strong {
  font-size: .86rem;
}

.potion-button small {
  color: #c9cce6;
  font-size: .68rem;
}

.potion-icon {
  position: relative;
  width: 30px;
  height: 34px;
  border: 3px solid #e8faff;
  border-radius: 5px 5px 12px 12px;
  background: linear-gradient(transparent 25%, #64ef9e 26%);
  box-shadow: inset 0 0 8px #d4ffe4, 0 0 10px rgb(100 239 158 / 45%);
}

.potion-count {
  position: absolute;
  top: 5px;
  right: -9px;
  display: grid;
  min-width: 18px;
  width: auto;
  height: 18px;
  padding: 0 2px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #6d57cd;
  color: #fff;
  font-size: .68rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 2px rgb(0 0 0 / 55%);
}

.potion-icon::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 6px;
  width: 12px;
  height: 7px;
  border: 3px solid #e8faff;
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #10142c;
}

@keyframes monsterAttack {
  0%, 100% { transform: translate(0) scale(1); }
  35% { transform: translate(-75px, 12px) scale(1.06); }
  55% { transform: translate(-48px, 5px) scale(1.03); }
}

@keyframes heroDamaged {
  0%, 100% { transform: translate(0) rotate(0); filter: brightness(1); }
  20% { transform: translate(-18px, -5px) rotate(-8deg); filter: brightness(2); }
  45% { transform: translate(12px, 3px) rotate(6deg); }
  70% { transform: translate(-6px) rotate(-3deg); }
}

@keyframes potionReady {
  to { box-shadow: 0 7px 25px rgb(92 255 155 / 55%); border-color: #80ffae; }
}

.monster.counter-attack {
  animation: monsterAttack .75s ease-in-out;
}

.hero.damaged {
  animation: heroDamaged .6s ease-in-out;
}

button,
input {
  font: inherit;
}

.potion-button {
  left: 12px;
  bottom: 55px;
  min-height: 48px;
  padding: 5px 9px;
}

.potion-button small {
  display: none;
}

.potion-icon {
  transform: scale(.8);
}

button {
  -webkit-tap-highlight-color: transparent;
}

.game-shell,
.battlefield {
  width: 100%;
  height: 100dvh;
  min-height: 560px;
}

.battlefield {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.landscape {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -5;
}

.rotate-device {
  display: none;
}

.sky-glow {
  position: absolute;
  inset: 0;
  z-index: -4;
  background: radial-gradient(circle at 75% 18%, rgb(255 246 194 / 24%), transparent 25%);
  pointer-events: none;
}

.moon {
  filter: drop-shadow(0 0 24px #fff5b4);
}

.monster {
  --monster-fur: #514783;
  --monster-head: #7569ad;
  --monster-horns: #3c356f;
  --monster-spots: #b9ffda;
  --monster-eyes: #b9ffda;
  transform-origin: 895px 690px;
  animation: monsterBreath 3.2s ease-in-out infinite;
}

.monster .monster-arm,
.monster .monster-body {
  fill: var(--monster-fur);
}

.monster .monster-head {
  fill: var(--monster-head);
  transform-origin: 893px 407px;
  transition: rx .3s, ry .3s, transform .3s;
}

.monster .monster-horns {
  fill: var(--monster-horns);
}

.monster .monster-eyes ellipse {
  fill: var(--monster-eyes);
}

.monster-spots {
  display: none;
  fill: var(--monster-spots);
}

.monster-stripes {
  display: none;
  stroke: var(--monster-spots);
}

.monster.pattern-spots .monster-spots {
  display: block;
}

.monster.pattern-stripes .monster-stripes {
  display: block;
}

.monster.shape-round .monster-head {
  transform: scaleX(1.1) scaleY(.9);
}

.monster.shape-tall .monster-head {
  transform: scaleX(.86) scaleY(1.12);
}

.monster.palette-green {
  --monster-fur: #34694f;
  --monster-head: #58a36f;
  --monster-horns: #244b3e;
  --monster-spots: #d7ef72;
  --monster-eyes: #fff69a;
}

.monster.palette-blue {
  --monster-fur: #315d83;
  --monster-head: #4b8db4;
  --monster-horns: #253c68;
  --monster-spots: #8ffff0;
  --monster-eyes: #bdfcff;
}

.monster.palette-orange {
  --monster-fur: #9b5531;
  --monster-head: #d17a3d;
  --monster-horns: #71341f;
  --monster-spots: #ffe478;
  --monster-eyes: #fff3a7;
}

.monster.palette-red {
  --monster-fur: #843e58;
  --monster-head: #bd5772;
  --monster-horns: #5e2945;
  --monster-spots: #ffb4cf;
  --monster-eyes: #ffd2e4;
}

.monster.palette-teal {
  --monster-fur: #27737a;
  --monster-head: #3fa6a2;
  --monster-horns: #20505c;
  --monster-spots: #9bffd5;
  --monster-eyes: #dcff9f;
}

.monster.palette-gold {
  --monster-fur: #88702e;
  --monster-head: #c4a840;
  --monster-horns: #604925;
  --monster-spots: #fff0a1;
  --monster-eyes: #e5ffbd;
}

.monster.hit {
  animation: monsterHit .62s cubic-bezier(.15, .8, .25, 1);
}

.monster.low-health .monster-eyes {
  animation: worriedEyes .45s ease-in-out infinite alternate;
}

.monster.defeated {
  animation: monsterDefeated 1.25s ease-in forwards;
}

.monster.laugh {
  animation: monsterLaugh .5s ease-in-out;
}

.monster-mouth {
  transform-origin: 895px 500px;
}

.mist {
  position: absolute;
  z-index: -2;
  width: 70%;
  height: 110px;
  border-radius: 50%;
  background: rgb(224 232 255 / 13%);
  filter: blur(25px);
  animation: mistMove 14s linear infinite alternate;
}

.mist-one {
  left: -20%;
  bottom: 13%;
}

.mist-two {
  right: -25%;
  bottom: 25%;
  animation-delay: -7s;
}

.status-bar {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 4;
}

.stat,
.round-button,
.install-button,
.home-button,
.shop-button {
  border: 2px solid rgb(255 255 255 / 25%);
  box-shadow: 0 5px 16px rgb(0 0 0 / 22%);
  background: rgb(21 22 51 / 82%);
  color: white;
  backdrop-filter: blur(9px);
}

.stat {
  display: grid;
  min-width: 76px;
  padding: 6px 12px;
  border-radius: 15px;
}

.stat span {
  color: #c9cce6;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.stat strong {
  font-size: 1.08rem;
}

.round-button,
.install-button,
.home-button,
.shop-button {
  min-height: 44px;
  padding: 0 13px;
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
}

.round-button {
  margin-left: 0;
}

.home-button {
  background: rgb(21 22 51 / 82%);
}

.shop-button {
  margin-left: auto;
  background: linear-gradient(180deg, #f8d775, #e5aa35);
  color: #34284f;
}

.shop-button:disabled {
  cursor: wait;
  filter: grayscale(.8);
  opacity: .7;
}

.install-button {
  background: #f7c758;
  color: #2b254c;
}

.question-card {
  position: absolute;
  top: 50%;
  left: clamp(12px, 7vw, 110px);
  width: min(520px, calc(100% - 24px));
  padding: clamp(18px, 3vw, 32px);
  transform: translateY(-53%);
  border: 3px solid rgb(255 255 255 / 55%);
  border-radius: 28px;
  box-shadow: 0 18px 60px rgb(7 8 28 / 48%), inset 0 1px 0 rgb(255 255 255 / 55%);
  background: rgb(255 247 223 / 91%);
  color: var(--ink);
  text-align: center;
  backdrop-filter: blur(12px);
  z-index: 3;
  transition: opacity .2s, transform .2s;
}

.question-card.attacking {
  opacity: .2;
  transform: translateY(-53%) scale(.96);
}

.category {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  color: #6459a3;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.direction {
  margin: 12px 0 3px;
  color: #67647a;
  font-size: .9rem;
  font-weight: 700;
}

.word {
  min-height: 1.3em;
  margin: 3px 0 20px;
  font-size: clamp(1.75rem, 5vw, 3.35rem);
  font-weight: 1000;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

#answerForm {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.answer-fields {
  display: grid;
  gap: 10px;
}

.answer-input {
  width: 100%;
  min-width: 0;
  height: 54px;
  border: 3px solid #d5cdec;
  border-radius: 15px;
  outline: 0;
  background: white;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0 16px;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}

.answer-input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgb(109 87 205 / 16%);
}

.answer-input.correct {
  border-color: #31bd71;
  box-shadow: 0 0 0 5px rgb(49 189 113 / 20%);
}

.answer-input.wrong {
  border-color: var(--red);
  animation: inputShake .35s ease-in-out;
}

.attack-button,
.skip-button,
.victory button {
  border: 0;
  border-radius: 15px;
  box-shadow: 0 6px 0 #352777, 0 9px 18px rgb(53 39 119 / 26%);
  background: linear-gradient(180deg, #8973ea, #5d45c3);
  color: white;
  font-weight: 1000;
  padding: 0 22px;
  cursor: pointer;
  text-transform: uppercase;
}

.attack-button:active,
.victory button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #352777;
}

.attack-button:disabled {
  cursor: wait;
  filter: grayscale(.7);
}

.feedback {
  min-height: 1.4em;
  margin-top: 15px;
  color: #625e75;
  font-size: .9rem;
  font-weight: 800;
}

.feedback.good {
  color: #17864a;
}

.feedback.bad {
  color: #c74055;
}

.boss-panel {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(420px, 43vw);
  z-index: 3;
}

.boss-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  color: white;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .07em;
  text-shadow: 0 2px 5px #000;
  text-transform: uppercase;
}

.boss-label > span:first-child {
  display: grid;
}

#bossHpText.damage-flash {
  animation: bossDamageFlash .45s ease-out;
}

@keyframes bossDamageFlash {
  0%, 100% { color: white; transform: scale(1); }
  35% { color: #ffb057; transform: scale(1.25); text-shadow: 0 0 12px #ff6f7d; }
}

.boss-label small {
  color: #d7d9ef;
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: none;
}

.health-track {
  height: 20px;
  overflow: hidden;
  border: 3px solid white;
  border-radius: 99px;
  box-shadow: 0 5px 14px rgb(0 0 0 / 40%);
  background: rgb(31 28 57 / 70%);
}

.health-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff6679, #ffb057);
  transition: width .45s cubic-bezier(.2, .8, .2, 1);
}

.hero {
  --hero-hat: #5740a7;
  --hero-robe: #6d55d4;
  --hero-skin: #f5bb89;
  position: absolute;
  left: clamp(40px, 10vw, 150px);
  bottom: 8%;
  width: 64px;
  height: 108px;
  z-index: 1;
  filter: drop-shadow(0 8px 8px rgb(0 0 0 / 35%));
  transform-origin: 50% 100%;
}

.hero.casting {
  animation: heroCast .7s ease-out;
}

.hero-head {
  position: absolute;
  top: 25px;
  left: 18px;
  width: 31px;
  height: 31px;
  border: 4px solid #231b45;
  border-radius: 50%;
  background: var(--hero-skin);
  z-index: 2;
}

.hero-hat {
  position: absolute;
  top: 0;
  left: 7px;
  width: 51px;
  height: 41px;
  clip-path: polygon(52% 0, 100% 100%, 0 100%);
  background: var(--hero-hat);
  z-index: 3;
}

.hero-body {
  position: absolute;
  left: 9px;
  bottom: 0;
  width: 48px;
  height: 57px;
  clip-path: polygon(30% 0, 70% 0, 100% 100%, 0 100%);
  background: var(--hero-robe);
  border-radius: 7px;
}

.hero-hand {
  position: absolute;
  top: 67px;
  width: 14px;
  height: 14px;
  z-index: 4;
}

.hero-hand-left {
  right: -7px;
}

.hero-hand-right {
  left: -7px;
}

.hero-hand::before {
  content: "";
  position: absolute;
  top: 3px;
  width: 22px;
  height: 9px;
  border: 2px solid #231b45;
  border-radius: 6px;
  background: var(--hero-robe);
}

.hero-hand-left::before {
  right: 7px;
}

.hero-hand-right::before {
  left: 7px;
}

.hero-grip {
  position: absolute;
  inset: 0;
  border: 2px solid #231b45;
  border-radius: 50%;
  background: var(--hero-skin);
}

.hero-weapon {
  position: absolute;
  left: -14px;
  bottom: -12px;
  width: 42px;
  height: 82px;
  object-fit: contain;
  transform: rotate(-16deg);
  transform-origin: 50% 80%;
}

.hero-staff {
  position: absolute;
  left: 4px;
  bottom: -28px;
  width: 6px;
  height: 98px;
  border-radius: 4px;
  background: #6d3b2b;
  transform: rotate(-12deg);
}

.hero-staff::before {
  content: "";
  position: absolute;
  top: -13px;
  left: -9px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #8ffff0;
  box-shadow: 0 0 18px #65ffe8;
}

.hero-hat.image-part {
  left: 4px;
  top: 4px;
  width: 57px;
  height: 34px;
  clip-path: none;
  background-color: transparent;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center bottom;
}

.hero-body.image-part {
  clip-path: none;
  border-radius: 0;
  background-color: transparent;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.attack {
  position: absolute;
  left: 17%;
  bottom: 24%;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  opacity: 0;
  z-index: 2;
  pointer-events: none;
}

.attack.fire {
  background: #fff7a4;
  box-shadow: 0 0 18px 8px #f6c95d, -18px 0 25px 6px #8df9ff;
  animation: attackFly .72s cubic-bezier(.35, .1, .7, .9);
}

.attack.mega {
  width: 65px;
  height: 65px;
  background: radial-gradient(circle, white 0 20%, #8ffff0 25% 44%, #896dff 50% 70%, transparent 72%);
  filter: drop-shadow(0 0 18px #90fff1);
  animation: megaFly .9s cubic-bezier(.25, .6, .65, .95);
}

.victory {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
  background: rgb(10 11 31 / 72%);
  backdrop-filter: blur(12px);
}

.victory[hidden] {
  display: none;
}

.victory-card {
  width: min(430px, 100%);
  border: 4px solid white;
  border-radius: 30px;
  box-shadow: 0 25px 70px rgb(0 0 0 / 45%);
  background: var(--cream);
  color: var(--ink);
  padding: 35px;
  text-align: center;
}

.victory-card h1 {
  margin: 4px 0 10px;
  font-size: clamp(1.8rem, 7vw, 2.8rem);
}

.victory-card .eyebrow {
  color: var(--purple-dark);
  font-size: .8rem;
  font-weight: 1000;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.victory button {
  min-height: 52px;
  margin-top: 12px;
  padding: 0 24px;
}

.shop-dialog {
  width: min(760px, calc(100% - 24px));
  max-height: min(88dvh, 850px);
  overflow: auto;
  border: 3px solid rgb(255 255 255 / 70%);
  border-radius: 28px;
  box-shadow: 0 25px 80px rgb(0 0 0 / 55%);
  background: #fff7df;
  color: var(--ink);
  padding: clamp(20px, 4vw, 34px);
}

.shop-dialog::backdrop {
  background: rgb(10 11 31 / 78%);
  backdrop-filter: blur(10px);
}

.shop-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.shop-header h2 {
  margin: 3px 0 0;
  font-size: clamp(1.55rem, 5vw, 2.35rem);
}

.shop-header .eyebrow {
  margin: 0;
  color: var(--purple-dark);
  font-size: .75rem;
  font-weight: 1000;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.shop-close {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #e7def1;
  color: #43366f;
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.shop-balance {
  margin: 20px 0;
  border-radius: 16px;
  background: #3a2f83;
  color: white;
  padding: 12px 16px;
  text-align: center;
}

.shop-balance strong {
  color: #ffe083;
}

.shop-section {
  margin-top: 24px;
}

.shop-section h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 5px;
}

.shop-section h3 span {
  border-radius: 999px;
  background: #d7f6df;
  color: #19763f;
  font-size: .66rem;
  padding: 4px 8px;
  text-transform: uppercase;
}

.shop-section > p {
  margin: 0 0 13px;
  color: #625e75;
}

.skin-tone-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.skin-tone-button {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 4px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #c9c0dc;
  background: var(--skin-tone);
  cursor: pointer;
}

.skin-tone-button[aria-pressed="true"] {
  box-shadow: 0 0 0 4px var(--purple);
}

.skin-tone-button[aria-pressed="true"]::after {
  content: "✓";
  color: white;
  font-size: 1.4rem;
  font-weight: 1000;
  text-shadow: 0 1px 3px #000;
}

.shop-items {
  display: grid;
  gap: 20px;
}

.equipment-group h4 {
  margin: 0 0 10px;
  color: #514783;
}

.equipment-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 13px;
}

.shop-item {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 12px;
  align-items: center;
  border: 2px solid #d8cfea;
  border-radius: 18px;
  background: white;
  padding: 12px;
}

.shop-item.equipped {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgb(109 87 205 / 13%);
}

.shop-item-preview {
  position: relative;
  width: 76px;
  height: 88px;
  border-radius: 12px;
  background: #eee9f6;
}

.shop-item-preview .hero {
  position: absolute;
  top: 5px;
  left: 17px;
  bottom: auto;
  transform: scale(.65);
  transform-origin: top left;
  animation: none;
  filter: none;
}

.shop-item-info {
  min-width: 0;
}

.shop-item-name {
  display: block;
  margin-bottom: 5px;
  font-weight: 1000;
}

.shop-item-price {
  display: block;
  margin-bottom: 9px;
  color: #756d88;
  font-size: .76rem;
  font-weight: 800;
}

.shop-item button,
.shop-back {
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #8973ea, #5d45c3);
  color: white;
  font-weight: 900;
  padding: 0 14px;
  cursor: pointer;
}

.shop-item button:disabled {
  background: #d8d2df;
  color: #625e75;
  cursor: default;
}

.cheat-form {
  margin-top: 24px;
  padding: 14px;
  border: 1px dashed #a99dc8;
  border-radius: 16px;
  background: #f0ebf8;
}

.cheat-form label {
  display: block;
  margin-bottom: 8px;
  color: #514783;
  font-size: .82rem;
  font-weight: 900;
}

.cheat-controls {
  display: flex;
  gap: 8px;
}

.cheat-controls input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border: 2px solid #d5cdec;
  border-radius: 11px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
}

.cheat-controls input:focus {
  border-color: var(--purple);
  outline: 3px solid rgb(109 87 205 / 16%);
}

.cheat-controls button {
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  background: #3a2f83;
  color: white;
  font-weight: 900;
  padding: 0 14px;
  cursor: pointer;
}

.cheat-controls button:disabled {
  background: #aaa4b5;
  cursor: default;
}

.shop-feedback {
  min-height: 1.4em;
  margin: 18px 0 0;
  color: #247947;
  font-weight: 900;
  text-align: center;
}

.shop-feedback.bad {
  color: #c74055;
}

.shop-back {
  display: block;
  width: min(100%, 290px);
  margin: 12px auto 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes monsterBreath {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.012); }
}

@keyframes monsterHit {
  0% { transform: translate(0) rotate(0); }
  22% { transform: translate(34px, -6px) rotate(3deg); filter: brightness(1.8); }
  45% { transform: translate(-15px, 2px) rotate(-2deg); }
  72% { transform: translate(8px) rotate(1deg); }
  100% { transform: translate(0) rotate(0); }
}

@keyframes monsterDefeated {
  0% { transform: rotate(0) translateY(0); }
  30% { transform: rotate(-5deg) translateY(-12px); }
  100% { transform: rotate(12deg) translate(75px, 115px); opacity: .6; }
}

@keyframes monsterLaugh {
  0%, 100% { transform: translateY(0); }
  25%, 75% { transform: translateY(-8px) rotate(-1deg); }
  50% { transform: translateY(3px) rotate(1deg); }
}

@keyframes worriedEyes {
  to { transform: scaleY(.55); transform-origin: center; }
}

@keyframes mistMove {
  to { transform: translateX(65%); }
}

@keyframes heroCast {
  0%, 100% { transform: rotate(0) scale(1); }
  35% { transform: rotate(-7deg) scale(1.08); }
  60% { transform: rotate(4deg) scale(.98); }
}

@keyframes attackFly {
  0% { opacity: 1; transform: translate(0, 0) scale(.45); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(64vw, -16vh) scale(1.9); }
}

@keyframes megaFly {
  0% { opacity: 1; transform: translate(0, 0) rotate(0) scale(.3); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(62vw, -18vh) rotate(540deg) scale(2.4); }
}

@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(7px); }
  75% { transform: translateX(-4px); }
}

@media (max-width: 760px) {
  .home-screen {
    padding-inline: 12px;
  }

  .mode-buttons {
    grid-template-columns: 1fr;
  }

  .mode-button {
    min-height: 96px;
  }

  .status-bar {
    gap: 5px;
  }

  .stat {
    min-width: 58px;
    padding-inline: 8px;
  }

  .shop-button,
  .home-button,
  .round-button {
    padding-inline: 10px;
  }

  .shop-dialog {
    max-height: 94dvh;
    padding: 20px 16px;
  }

  .equipment-items {
    grid-template-columns: 1fr;
  }

  .landscape {
    width: 100%;
    left: 0;
    transform: none;
  }

  .question-card {
    top: 42%;
    left: 12px;
    padding: 18px 16px;
    transform: translateY(-50%);
  }

  .question-card.attacking {
    transform: translateY(-50%) scale(.96);
  }

  .word {
    margin-bottom: 15px;
  }

  .attack-button {
    height: 48px;
  }

  .attack-button,
  .skip-button {
    flex: 1 1 145px;
    min-width: 0;
    padding-inline: 12px;
    overflow-wrap: anywhere;
  }

  .hero {
    left: 8%;
    bottom: 9%;
    transform: scale(.8);
  }

  .boss-panel {
    left: 16px;
    right: 16px;
    bottom: max(14px, env(safe-area-inset-bottom));
    width: auto;
  }

  .attack {
    left: 16%;
    bottom: 23%;
  }

  .stat {
    min-width: 67px;
    padding-inline: 9px;
  }

}

@media (orientation: landscape) and (max-height: 600px) {
  .game-shell,
  .battlefield {
    height: 100dvh;
    min-height: 0;
  }

  .question-card {
    top: 52%;
    left: max(10px, env(safe-area-inset-left));
    width: min(390px, 44vw);
    padding: 11px 13px;
    border-radius: 20px;
    transform: translateY(-50%);
  }

  .question-card.attacking {
    transform: translateY(-50%) scale(.96);
  }

  .category {
    font-size: .62rem;
  }

  .direction {
    margin-top: 5px;
    font-size: .75rem;
  }

  .word {
    margin: 1px 0 8px;
    font-size: clamp(1.35rem, 4.5vh, 2rem);
  }

  #answer {
    height: 42px;
    font-size: .9rem;
  }

  .attack-button,
  .skip-button {
    min-height: 40px;
    height: 40px;
    padding-inline: 12px;
    font-size: .76rem;
  }

  .feedback {
    min-height: 1.2em;
    margin-top: 7px;
    font-size: .72rem;
  }

  .status-bar {
    right: auto;
  }

  .stat {
    min-width: 62px;
    padding: 4px 8px;
  }

  .stat span {
    font-size: .56rem;
  }

  .stat strong {
    font-size: .9rem;
  }

  .round-button {
    min-height: 37px;
    margin-left: 0;
    padding-inline: 10px;
    font-size: .75rem;
  }

  .hero {
    left: 44%;
    bottom: 8%;
    transform: scale(.72);
  }

  .attack {
    left: 47%;
    bottom: 28%;
  }

  .boss-panel {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: auto;
    width: 43vw;
  }

  .potion-button {
    left: max(10px, env(safe-area-inset-left));
    bottom: max(8px, env(safe-area-inset-bottom));
    min-height: 42px;
    padding: 4px 8px;
  }

  .potion-button small {
    display: none;
  }

  .potion-icon {
    transform: scale(.7);
  }
}

@media (orientation: portrait) and (min-width: 761px) {
  .question-card {
    top: 52%;
    left: clamp(18px, 4vw, 55px);
    width: min(390px, 45vw);
    padding: 22px;
  }

  .word {
    font-size: clamp(2rem, 5vw, 3rem);
  }

  .hero {
    left: 44%;
  }

  .attack {
    left: 49%;
  }

  .boss-panel {
    width: min(390px, 47vw);
  }
}

@media (orientation: portrait) and (max-width: 760px) {
  .game-shell,
  .battlefield {
    height: 100dvh;
    min-height: 0;
  }

  .question-card {
    top: 49%;
    left: 12px;
    width: calc(100% - 24px);
    max-width: 440px;
    padding: 16px;
    border-radius: 24px;
  }

  .question-card.attacking {
    transform: translateY(-50%) scale(.96);
  }

  .direction {
    margin-top: 8px;
  }

  .word {
    margin-bottom: 12px;
    font-size: clamp(1.75rem, 8vw, 2.5rem);
  }

  .feedback {
    margin-top: 10px;
  }

  .hero {
    left: 8%;
    bottom: 13%;
    transform: scale(.7);
  }

  .attack {
    left: 16%;
    bottom: 26%;
  }

  .potion-button {
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 62px);
    left: auto;
    min-height: 46px;
  }

  .boss-panel {
    right: 16px;
    bottom: max(14px, env(safe-area-inset-bottom));
    left: 16px;
    width: auto;
  }
}

@media (max-height: 650px) {
  .question-card {
    top: 47%;
    padding-block: 12px;
  }

  .word {
    font-size: 1.7rem;
    margin-bottom: 10px;
  }

  .feedback {
    margin-top: 8px;
  }

  #answer,
  .attack-button {
    height: 45px;
  }
}

@media (max-width: 760px) {
  .status-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    right: max(12px, env(safe-area-inset-right));
    align-items: stretch;
    gap: 6px;
  }

  .stat {
    min-width: 0;
    padding: 5px 6px;
  }

  .stat span {
    font-size: .58rem;
    letter-spacing: .03em;
  }

  .stat strong {
    font-size: .9rem;
    overflow-wrap: anywhere;
  }

  .shop-button,
  .home-button,
  .round-button,
  .install-button {
    min-width: 0;
    min-height: 44px;
    margin-left: 0;
    padding-inline: 6px;
    font-size: .78rem;
  }

  .shop-button,
  .home-button,
  .round-button {
    grid-column: span 1;
  }

  .install-button {
    grid-column: span 2;
  }
}

@media (orientation: landscape) and (max-width: 760px) {
  .status-bar {
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto auto auto auto;
  }

  .shop-button,
  .home-button,
  .round-button,
  .install-button {
    grid-column: auto;
  }

  .question-card {
    top: max(80px, calc(env(safe-area-inset-top) + 70px));
    transform: none;
  }

  .question-card.attacking {
    transform: scale(.96);
  }

  .answer-actions button {
    flex-basis: 100px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
