:root {
  color-scheme: dark;
  --page: #08090c;
  --rim: #222834;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 14%, rgba(82, 150, 151, 0.18), transparent 26rem),
    radial-gradient(circle at 85% 88%, rgba(173, 82, 67, 0.18), transparent 26rem),
    var(--page);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.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;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#game {
  display: block;
  width: min(100vw, 460px);
  height: 100dvh;
  max-height: 940px;
  background: #10131a;
  border-left: 1px solid rgba(244, 226, 184, 0.16);
  border-right: 1px solid rgba(244, 226, 184, 0.16);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04),
    0 24px 80px rgba(0, 0, 0, 0.58);
  cursor: crosshair;
  touch-action: none;
}

.settings-button {
  position: fixed;
  top: max(12px, calc(env(safe-area-inset-top) + 10px));
  left: max(12px, calc(env(safe-area-inset-left) + 10px));
  z-index: 12;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(255, 238, 194, 0.22);
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.68);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.36);
  color: rgba(255, 247, 224, 0.84);
  font: inherit;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  backdrop-filter: blur(9px);
}

.game-instructions-button {
  position: fixed;
  top: max(12px, calc(env(safe-area-inset-top) + 10px));
  left: 50%;
  z-index: 8;
  min-height: 34px;
  padding: 0 16px;
  border: 1px solid rgba(255, 238, 194, 0.22);
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.68);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.36);
  color: rgba(255, 247, 224, 0.84);
  font: inherit;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  transform: translateX(-50%);
  backdrop-filter: blur(9px);
}

.music-toggle {
  position: fixed;
  top: max(12px, calc(env(safe-area-inset-top) + 10px));
  right: max(12px, calc(env(safe-area-inset-right) + 10px));
  z-index: 8;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(255, 238, 194, 0.22);
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.68);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.36);
  color: rgba(255, 247, 224, 0.84);
  font: inherit;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  backdrop-filter: blur(9px);
}

.settings-button[hidden],
.music-toggle[hidden] {
  display: none;
}

.music-toggle.is-muted {
  border-color: rgba(255, 146, 119, 0.34);
  color: rgba(255, 202, 189, 0.82);
}

.game-instructions-button[hidden] {
  display: none;
}

.settings-button:focus-visible,
.game-instructions-button:focus-visible,
.music-toggle:focus-visible {
  outline: 2px solid #dfffd9;
  outline-offset: 3px;
}

.command-controls {
  position: fixed;
  left: 50%;
  bottom: max(12px, calc(env(safe-area-inset-bottom) + 10px));
  z-index: 8;
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(82vw, 340px);
  transform: translateX(-50%);
}

.command-controls.has-wave .command-wave-row {
  border-color: rgba(190, 255, 195, 0.34);
  box-shadow:
    0 14px 38px rgba(0, 0, 0, 0.42),
    0 0 24px rgba(104, 232, 137, 0.16);
}

.command-controls[hidden] {
  display: none;
}

.command-row {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.command-wave-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(76vw, 320px);
  padding: 6px;
  border: 1px solid rgba(255, 238, 194, 0.24);
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.72);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(9px);
}

.command-lane-row {
  position: fixed;
  left: 50%;
  bottom: max(88px, calc(env(safe-area-inset-bottom) + 86px));
  z-index: 9;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 168px;
  justify-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translateX(-50%);
  pointer-events: auto;
}

.command-button {
  position: relative;
  min-width: 0;
  min-height: 38px;
  border: 1px solid rgba(255, 238, 194, 0.18);
  border-radius: 999px;
  background: rgba(23, 25, 31, 0.76);
  color: rgba(255, 247, 224, 0.74);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}

.command-button.has-wave::after {
  content: attr(data-count);
  position: absolute;
  right: -4px;
  top: -7px;
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border: 1px solid rgba(255, 245, 210, 0.72);
  border-radius: 999px;
  background: rgba(18, 12, 9, 0.92);
  color: #ffe8a8;
  box-shadow: 0 0 14px rgba(104, 232, 137, 0.36);
  font-size: 0.62rem;
  line-height: 1;
  letter-spacing: 0;
}

.lane-button {
  display: grid;
  align-items: center;
  justify-items: center;
  width: 48px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border-color: rgba(255, 222, 154, 0.54);
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 42% 35%, rgba(246, 188, 102, 0.88), rgba(146, 82, 41, 0.92) 44%, rgba(64, 34, 21, 0.95) 78%),
    linear-gradient(115deg, rgba(255, 214, 140, 0.18), rgba(65, 33, 19, 0.18)),
    rgba(10, 13, 17, 0.78);
  box-shadow:
    0 8px 16px rgba(0, 0, 0, 0.38),
    inset 0 0 0 3px rgba(53, 27, 16, 0.58),
    inset 0 0 0 6px rgba(255, 225, 157, 0.13),
    inset -8px -7px 12px rgba(28, 15, 11, 0.34),
    inset 7px 5px 10px rgba(255, 216, 145, 0.18);
  color: #fff0b8;
  font-size: 1.1rem;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.lane-button::before,
.lane-button::after {
  content: "";
  position: absolute;
  inset: 7px 9px;
  border-radius: 50%;
  pointer-events: none;
}

.lane-button::before {
  border-left: 2px solid rgba(54, 28, 17, 0.42);
  border-right: 2px solid rgba(255, 220, 145, 0.24);
  transform: rotate(12deg);
}

.lane-button::after {
  border-top: 2px solid rgba(255, 222, 154, 0.42);
  border-bottom: 2px solid rgba(47, 24, 15, 0.58);
  transform: rotate(-10deg);
}

.lane-button.is-active {
  color: #1b1009;
  box-shadow:
    inset 0 0 0 3px rgba(255, 245, 188, 0.46),
    inset 0 0 0 7px rgba(88, 43, 20, 0.24),
    inset -7px -6px 12px rgba(91, 43, 18, 0.28),
    0 0 0 2px rgba(255, 238, 194, 0.2),
    0 0 24px rgba(105, 255, 177, 0.36),
    0 8px 16px rgba(0, 0, 0, 0.38);
}

.command-controls[data-lane="left"] .lane-button[data-lane-mode="left"],
.command-controls[data-lane="center"] .lane-button[data-lane-mode="center"],
.command-controls[data-lane="right"] .lane-button[data-lane-mode="right"] {
  transform: translateY(-2px);
}

@media (max-height: 720px) {
  .command-controls {
    gap: 5px;
    bottom: max(8px, calc(env(safe-area-inset-bottom) + 6px));
  }

  .command-wave-row {
    padding: 4px;
  }

  .command-button {
    min-height: 34px;
    font-size: 0.72rem;
  }

  .lane-button {
    width: 44px;
    height: 38px;
    min-height: 38px;
    font-size: 1.05rem;
  }
}

.settings-screen {
  position: fixed;
  inset: 0;
  z-index: 26;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 22%, rgba(98, 255, 166, 0.13), transparent 21rem),
    rgba(3, 5, 8, 0.66);
  backdrop-filter: blur(10px);
}

.settings-panel {
  display: grid;
  gap: 11px;
  width: min(90vw, 380px);
  padding: 20px;
  border: 1px solid rgba(255, 238, 194, 0.25);
  border-radius: 14px;
  background: rgba(9, 11, 15, 0.9);
  color: #fff5d9;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.54);
}

.settings-panel h2 {
  margin: 0 0 4px;
  font-family: Papyrus, Copperplate, Georgia, "Times New Roman", serif;
  font-size: 2rem;
  line-height: 1;
  color: #ffe8a8;
}

.settings-toggle {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 231, 173, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  font-weight: 800;
}

.settings-toggle input {
  width: 20px;
  height: 20px;
  accent-color: #94ffaf;
}

body.large-hud .game-instructions-button,
body.large-hud .music-toggle,
body.large-hud .settings-button {
  min-height: 44px;
  font-size: 0.72rem;
}

body.large-hud .command-controls {
  width: min(90vw, 410px);
}

body.large-hud .command-button {
  min-height: 48px;
  font-size: 0.82rem;
}

body.large-hud .lane-button {
  width: 48px;
  height: 54px;
  min-height: 54px;
  font-size: 1.28rem;
}

body.high-contrast {
  --page: #030405;
  --rim: #f7e4ae;
}

body.high-contrast #game {
  border-color: rgba(255, 244, 205, 0.62);
  box-shadow:
    0 0 0 2px rgba(255, 244, 205, 0.25),
    0 24px 80px rgba(0, 0, 0, 0.68);
}

body.high-contrast .settings-button,
body.high-contrast .game-instructions-button,
body.high-contrast .music-toggle,
body.high-contrast .command-controls {
  border-color: rgba(255, 244, 205, 0.56);
  background: rgba(0, 0, 0, 0.82);
  color: #fffbe8;
}

.command-button.is-active {
  border-color: rgba(255, 230, 166, 0.72);
  background: linear-gradient(180deg, rgba(248, 220, 151, 0.98), rgba(189, 126, 69, 0.96));
  color: #1b120d;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 226, 0.56),
    0 0 24px rgba(104, 232, 137, 0.18);
}

.command-button:focus-visible {
  outline: 2px solid #dfffd9;
  outline-offset: 3px;
}

.splash-screen,
.practice-screen,
.instructions-screen,
.end-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.splash-screen {
  cursor: pointer;
  background: #08090c;
  touch-action: manipulation;
}

.splash-screen:focus-visible {
  outline: 2px solid #f4dc9e;
  outline-offset: -8px;
}

.splash-art {
  width: min(100vw, 460px);
  height: 100dvh;
  max-height: 940px;
  object-fit: cover;
  border-left: 1px solid rgba(244, 226, 184, 0.18);
  border-right: 1px solid rgba(244, 226, 184, 0.18);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 24px 80px rgba(0, 0, 0, 0.64);
}

.splash-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(8, 9, 12, 0.12), rgba(8, 9, 12, 0.08) 42%, rgba(8, 9, 12, 0.48)),
    radial-gradient(circle at 50% 86%, rgba(113, 229, 144, 0.22), transparent 15rem);
  pointer-events: none;
}

.splash-copy {
  position: absolute;
  left: 50%;
  bottom: max(34px, calc(env(safe-area-inset-bottom) + 28px));
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(92vw, 460px);
  transform: translateX(-50%);
  text-align: center;
  color: #fff4d6;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.86);
  pointer-events: none;
}

.splash-copy h1 {
  position: relative;
  display: inline-block;
  isolation: isolate;
  margin: 0;
  padding: 0 10px 15px;
  font-family: Papyrus, Copperplate, Georgia, "Times New Roman", serif;
  font-size: clamp(2.8rem, 13vw, 4.6rem);
  font-variant-caps: small-caps;
  font-weight: 900;
  line-height: 0.78;
  letter-spacing: 0;
  text-transform: uppercase;
  color: transparent;
  background:
    linear-gradient(180deg, #ffffdd 0%, #ffd761 27%, #9d4d28 52%, #ffe9ac 66%, #52200f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-stroke: 1.2px rgba(49, 22, 19, 0.98);
  paint-order: stroke fill;
  transform: perspective(420px) rotateX(8deg) skewX(-5deg);
  text-shadow:
    0 1px 0 #fff1b8,
    0 3px 0 #7b351f,
    0 5px 0 rgba(30, 10, 14, 0.98),
    0 11px 20px rgba(0, 0, 0, 0.84),
    0 0 22px rgba(148, 236, 122, 0.52),
    0 0 34px rgba(217, 101, 232, 0.28);
}

.splash-copy h1::before {
  content: attr(data-title);
  position: absolute;
  inset: 0;
  z-index: -1;
  padding: 0 10px 15px;
  color: rgba(18, 11, 13, 0.96);
  -webkit-text-stroke: 8px rgba(16, 9, 12, 0.98);
  text-shadow:
    0 2px 0 rgba(252, 226, 175, 0.32),
    0 0 34px rgba(112, 255, 144, 0.34),
    0 16px 26px rgba(0, 0, 0, 0.86);
  transform: translateY(4px) scaleY(1.05);
}

.splash-copy h1::after {
  content: "";
  position: absolute;
  left: 11%;
  right: 11%;
  bottom: 0;
  height: 3px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, transparent, rgba(116, 246, 146, 0.78), #ffe6a1, rgba(210, 102, 230, 0.68), transparent);
  box-shadow:
    0 0 14px rgba(116, 246, 146, 0.58),
    0 0 26px rgba(210, 102, 230, 0.3);
}

@media (min-width: 390px) {
  .splash-copy h1 {
    font-size: clamp(3.35rem, 11vw, 5.05rem);
  }
}

.splash-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  margin: 18px 0 0;
  padding: 8px 18px;
  border: 1px solid rgba(252, 226, 175, 0.48);
  border-radius: 999px;
  background: rgba(11, 12, 17, 0.68);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.42);
  color: #fff4d6;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  text-decoration: none;
}

.splash-pill + .splash-pill {
  margin-left: 0;
  margin-top: 8px;
}

.splash-secondary-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 430px);
  margin-top: 8px;
  pointer-events: auto;
}

.splash-secondary-actions .splash-pill {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding-inline: 12px;
  font-size: 0.72rem;
}

.splash-subtitle {
  margin: -10px 0 18px;
  color: rgba(255, 231, 164, 0.92);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.95rem, 3vw, 1.35rem);
  font-weight: 900;
  letter-spacing: 0.28em;
  text-align: center;
  text-shadow:
    0 0 12px rgba(100, 255, 177, 0.24),
    0 2px 10px rgba(0, 0, 0, 0.7);
}

.splash-pill-secondary {
  border-color: rgba(174, 238, 255, 0.34);
  background: rgba(17, 20, 29, 0.72);
  color: rgba(226, 249, 255, 0.92);
}

.splash-pill-secondary.is-danger {
  border-color: rgba(255, 146, 119, 0.52);
  background: rgba(45, 14, 12, 0.76);
  color: #ffd2c2;
}

.splash-pill:focus-visible {
  outline: 2px solid #dfffd9;
  outline-offset: 3px;
}

.end-screen {
  z-index: 12;
  background:
    radial-gradient(circle at 50% 30%, rgba(244, 211, 150, 0.12), transparent 18rem),
    rgba(6, 7, 10, 0.78);
  backdrop-filter: blur(7px);
}

.splash-screen[hidden],
.practice-screen[hidden],
.instructions-screen[hidden],
.end-screen[hidden] {
  display: none;
}

.practice-screen {
  z-index: 11;
  align-items: center;
  background:
    radial-gradient(circle at 50% 12%, rgba(116, 246, 146, 0.13), transparent 19rem),
    radial-gradient(circle at 50% 92%, rgba(210, 102, 230, 0.13), transparent 20rem),
    rgba(5, 7, 10, 0.9);
  backdrop-filter: blur(8px);
}

.practice-panel {
  display: grid;
  grid-template-rows: auto auto minmax(230px, 1fr) auto auto;
  gap: 10px;
  width: min(92vw, 430px);
  height: min(88dvh, 760px);
  color: #fff5d9;
}

.practice-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.practice-header h2 {
  margin: 0;
  font-family: Papyrus, Copperplate, Georgia, "Times New Roman", serif;
  font-size: clamp(1.9rem, 7vw, 3rem);
  line-height: 0.92;
  text-transform: uppercase;
  color: #ffe8a8;
  text-shadow:
    0 2px 0 rgba(103, 52, 34, 0.9),
    0 10px 22px rgba(0, 0, 0, 0.72),
    0 0 20px rgba(114, 239, 158, 0.24);
}

.practice-header .splash-pill {
  margin: 0;
}

.practice-target,
.practice-result {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 231, 173, 0.18);
  border-radius: 8px;
  background: rgba(11, 13, 18, 0.76);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.practice-glyph {
  width: 82px;
  height: 58px;
}

.practice-copy strong,
.practice-copy span,
.practice-result strong,
.practice-result span {
  display: block;
  text-align: left;
}

.practice-copy strong,
.practice-result strong {
  color: #ffe2a8;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.practice-copy span,
.practice-result span {
  margin-top: 4px;
  color: rgba(255, 247, 226, 0.78);
  font-size: 0.84rem;
  line-height: 1.35;
}

.practice-result {
  grid-template-columns: 1fr;
  min-height: 64px;
}

.practice-result.is-good {
  border-color: rgba(116, 246, 146, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 24px rgba(116, 246, 146, 0.12);
}

.practice-result.is-miss {
  border-color: rgba(255, 146, 119, 0.42);
}

.practice-pad-wrap {
  position: relative;
  min-height: 230px;
  border: 1px solid rgba(255, 231, 173, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 231, 173, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 231, 173, 0.055) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, rgba(116, 246, 146, 0.1), transparent 13rem),
    rgba(5, 8, 12, 0.58);
  background-size: 18px 18px, 18px 18px, auto, auto;
  overflow: hidden;
}

.practice-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.practice-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 238, 194, 0.18);
  border-radius: 999px;
  background: rgba(5, 7, 10, 0.82);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(10px);
}

.practice-actions .splash-pill {
  margin-top: 0;
}

.instructions-screen {
  z-index: 11;
  align-items: center;
  background:
    radial-gradient(circle at 50% 18%, rgba(103, 216, 198, 0.13), transparent 18rem),
    radial-gradient(circle at 50% 88%, rgba(211, 99, 230, 0.13), transparent 18rem),
    rgba(5, 7, 10, 0.88);
  backdrop-filter: blur(8px);
}

.instructions-panel {
  width: min(92vw, 430px);
  max-height: min(88dvh, 760px);
  overflow: auto;
  padding: 22px 14px calc(88px + env(safe-area-inset-bottom));
  color: #fff5d9;
  text-align: center;
}

.instructions-panel h2 {
  margin: 0 0 14px;
  font-family: Papyrus, Copperplate, Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 8vw, 3.2rem);
  line-height: 0.9;
  text-transform: uppercase;
  color: #ffe8a8;
  text-shadow:
    0 2px 0 rgba(103, 52, 34, 0.9),
    0 12px 26px rgba(0, 0, 0, 0.74),
    0 0 22px rgba(114, 239, 158, 0.28);
}

.spellbook-hint {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 58px;
  margin: -4px auto 14px;
  max-width: 34rem;
  padding: 10px 13px;
  border: 1px solid rgba(255, 231, 173, 0.2);
  border-radius: 999px;
  background: rgba(11, 13, 18, 0.68);
  color: rgba(255, 247, 226, 0.84);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
}

.spellbook-hint span {
  grid-area: 1 / 1;
  opacity: 0;
  animation: spellbookHintRotate 10s infinite;
}

.spellbook-hint span:nth-child(2) {
  animation-delay: 5s;
}

@keyframes spellbookHintRotate {
  0%,
  44% {
    opacity: 1;
  }

  50%,
  94% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spellbook-hint span {
    animation: none;
  }

  .spellbook-hint span:first-child {
    opacity: 1;
  }
}

body.reduced-motion .spellbook-hint span,
body.quiet-effects .spellbook-hint span {
  animation: none;
}

body.reduced-motion .spellbook-hint span:first-child,
body.quiet-effects .spellbook-hint span:first-child {
  opacity: 1;
}

body.reduced-motion .spellbook-hint span:nth-child(2),
body.quiet-effects .spellbook-hint span:nth-child(2) {
  opacity: 0;
}

body.reduced-motion .sigil-awakening,
body.reduced-motion .result-pill,
body.reduced-motion .result-pill::after,
body.reduced-motion .result-pill + .end-primary-actions::before,
body.quiet-effects .sigil-awakening,
body.quiet-effects .result-pill::after,
body.quiet-effects .result-pill + .end-primary-actions::before {
  animation: none;
}

.spell-list {
  display: grid;
  gap: 8px;
}

.spell-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 231, 173, 0.18);
  border-radius: 8px;
  background: rgba(11, 13, 18, 0.74);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  text-align: left;
}

.spell-glyph {
  width: 74px;
  height: 52px;
  padding: 5px;
  border: 1px solid rgba(95, 255, 142, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(rgba(117, 255, 151, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(117, 255, 151, 0.07) 1px, transparent 1px),
    rgba(4, 12, 8, 0.58);
  background-size: 14px 14px;
  filter:
    drop-shadow(0 0 5px rgba(96, 255, 138, 0.32))
    drop-shadow(0 0 13px rgba(96, 255, 138, 0.2));
  overflow: visible;
}

.spell-glyph path,
.spell-glyph circle {
  fill: none;
  stroke: #79ff96;
  stroke-width: 4.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.spell-glyph .sigil-awakening {
  opacity: 1;
  transform-origin: center;
  animation: sigil-breathe 2.1s ease-in-out infinite;
}

.spell-glyph .sigil-awakened {
  stroke: #f3ffe2;
  stroke-width: 3.2;
  opacity: 0.98;
}

.spell-glyph .sigil-awakened-soft {
  stroke: #a3ff9b;
  stroke-width: 2.4;
  opacity: 0.76;
}

.spell-glyph .sigil-awakened-dot {
  fill: rgba(244, 255, 226, 0.96);
  stroke: rgba(244, 255, 226, 1);
  stroke-width: 1.8;
}

.spell-glyph circle {
  fill: rgba(121, 255, 150, 0.2);
}

.spell-glyph .sigil-awakened-dot {
  fill: rgba(208, 255, 212, 0.82);
}

@keyframes sigil-breathe {
  0%,
  100% {
    opacity: 0.72;
    filter:
      drop-shadow(0 0 5px rgba(121, 255, 150, 0.44))
      drop-shadow(0 0 12px rgba(121, 255, 150, 0.22));
  }

  50% {
    opacity: 1;
    filter:
      drop-shadow(0 0 8px rgba(243, 255, 226, 0.86))
      drop-shadow(0 0 18px rgba(121, 255, 150, 0.48));
  }
}

.spell-copy strong,
.spell-copy span {
  display: block;
}

.spell-copy strong {
  color: #ffe2a8;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.spell-copy span {
  margin-top: 4px;
  color: rgba(255, 247, 226, 0.78);
  font-size: 0.84rem;
  line-height: 1.35;
}

@media (max-width: 360px) {
  .spell-card {
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 8px;
    padding: 9px 10px;
  }

  .spell-glyph {
    width: 62px;
    height: 46px;
  }
}

.instructions-actions {
  position: fixed;
  z-index: 13;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(92vw, 430px);
  padding: 10px;
  gap: 8px;
  border: 1px solid rgba(255, 238, 194, 0.18);
  border-radius: 999px;
  background: rgba(5, 7, 10, 0.82);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.48);
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}

.instructions-actions.has-practice {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.instructions-actions .splash-pill {
  width: 100%;
  min-width: 0;
  margin-top: 0;
  padding-inline: 12px;
}

.end-panel {
  width: min(92vw, 420px);
  max-height: min(88dvh, 760px);
  overflow: auto;
  padding: 24px 16px 18px;
  color: #fff5d9;
  text-align: center;
}

.result-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
  min-width: clamp(224px, 68vw, 326px);
  min-height: 64px;
  padding: 13px 34px 17px;
  border: 1px solid rgba(249, 223, 166, 0.62);
  border-radius: 999px;
  background: rgba(13, 14, 18, 0.82);
  box-shadow:
    0 0 30px rgba(104, 232, 137, 0.2),
    0 16px 46px rgba(0, 0, 0, 0.52);
  color: transparent;
  font-family: Papyrus, Copperplate, Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 8vw, 3.05rem);
  font-variant-caps: small-caps;
  font-weight: 900;
  line-height: 0.82;
  text-transform: uppercase;
  white-space: nowrap;
  animation: result-summon 720ms cubic-bezier(0.2, 1.05, 0.2, 1) both;
}

.result-pill .result-sparks,
.result-pill > span {
  display: none;
}

.result-pill::before,
.result-pill::after {
  content: attr(data-result);
  position: absolute;
  left: 50%;
  top: 50%;
  letter-spacing: 0;
  line-height: 0.82;
  text-transform: uppercase;
  transform: translate(-50%, -49%) perspective(380px) rotateX(8deg) skewX(-5deg);
  white-space: nowrap;
  pointer-events: none;
}

.result-pill::before {
  z-index: 0;
  color: rgba(19, 11, 12, 0.98);
  -webkit-text-stroke: 7px rgba(15, 8, 11, 0.98);
  text-shadow:
    0 2px 0 rgba(255, 239, 184, 0.28),
    0 0 26px rgba(116, 246, 146, 0.36),
    0 13px 24px rgba(0, 0, 0, 0.84);
}

.result-pill::after {
  z-index: 1;
  color: transparent;
  background:
    linear-gradient(180deg, #ffffdf 0%, #ffd965 27%, #9d4d28 52%, #fff0b6 67%, #52200f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-stroke: 1px rgba(49, 22, 19, 0.98);
  paint-order: stroke fill;
  text-shadow:
    0 1px 0 #fff1b8,
    0 3px 0 #7b351f,
    0 5px 0 rgba(30, 10, 14, 0.98),
    0 10px 19px rgba(0, 0, 0, 0.82),
    0 0 20px rgba(148, 236, 122, 0.46),
    0 0 31px rgba(217, 101, 232, 0.24);
  animation: result-letter-glow 1.9s ease-in-out infinite;
}

.result-pill.is-vanquished {
  border-color: rgba(244, 154, 131, 0.58);
  box-shadow:
    0 0 30px rgba(213, 103, 91, 0.26),
    0 16px 46px rgba(0, 0, 0, 0.52);
}

.result-pill.is-vanquished::before {
  -webkit-text-stroke-color: rgba(23, 6, 9, 0.98);
  text-shadow:
    0 2px 0 rgba(255, 202, 166, 0.22),
    0 0 24px rgba(213, 82, 91, 0.38),
    0 13px 24px rgba(0, 0, 0, 0.84);
}

.result-pill.is-vanquished::after {
  background:
    linear-gradient(180deg, #ffe8c9 0%, #ff956a 26%, #8d242a 54%, #ffd1a5 70%, #31070c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-stroke-color: rgba(54, 10, 14, 0.98);
  text-shadow:
    0 1px 0 rgba(255, 218, 176, 0.88),
    0 3px 0 #78201f,
    0 5px 0 rgba(25, 5, 8, 0.98),
    0 10px 19px rgba(0, 0, 0, 0.82),
    0 0 20px rgba(226, 87, 82, 0.44),
    0 0 31px rgba(232, 142, 92, 0.24);
}

.result-pill + .end-primary-actions::before {
  content: "";
  position: fixed;
  left: 50%;
  top: 22%;
  width: min(72vw, 360px);
  height: 92px;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 58%, rgba(255, 238, 194, 0.76) 0 2px, transparent 3px),
    radial-gradient(circle at 82% 42%, rgba(122, 255, 180, 0.62) 0 2px, transparent 3px),
    radial-gradient(circle at 36% 18%, rgba(255, 181, 106, 0.66) 0 1.5px, transparent 3px),
    radial-gradient(circle at 64% 82%, rgba(218, 180, 255, 0.58) 0 1.5px, transparent 3px);
  filter: drop-shadow(0 0 8px rgba(255, 238, 194, 0.5));
  transform: translateX(-50%);
  animation: result-sparks 2.8s ease-in-out infinite;
}

@keyframes result-summon {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.92);
    filter: blur(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes result-sparks {
  0%,
  100% {
    opacity: 0.48;
    transform: translateX(-50%) translateY(8px) scale(0.98);
  }

  50% {
    opacity: 0.96;
    transform: translateX(-50%) translateY(-8px) scale(1.02);
  }
}

@keyframes result-letter-glow {
  0%,
  100% {
    filter: drop-shadow(0 0 2px rgba(255, 238, 194, 0.18));
  }

  50% {
    filter: drop-shadow(0 0 10px rgba(255, 238, 194, 0.64));
  }
}

.end-primary-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.72fr);
  gap: 8px;
  width: min(82vw, 330px);
  margin: 18px auto 20px;
}

.play-again {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 0;
  border: 1px solid rgba(252, 226, 175, 0.58);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(248, 221, 165, 0.95), rgba(188, 130, 72, 0.95));
  color: #19110c;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

.share-result {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 0;
  border: 1px solid rgba(174, 238, 255, 0.34);
  border-radius: 999px;
  background: rgba(17, 20, 29, 0.76);
  color: rgba(226, 249, 255, 0.92);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

@media (max-width: 340px) {
  .end-primary-actions {
    grid-template-columns: 1fr;
    width: min(78vw, 230px);
  }
}

.play-again:focus-visible,
.share-result:focus-visible {
  outline: 2px solid #dfffd9;
  outline-offset: 3px;
}

.high-score-form {
  margin: -8px auto 14px;
  padding: 12px;
  border: 1px solid rgba(255, 238, 194, 0.18);
  border-radius: 8px;
  background: rgba(10, 11, 15, 0.66);
}

.high-score-form label {
  display: block;
  color: rgba(255, 245, 217, 0.72);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.high-score-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 8px;
  margin-top: 8px;
}

.high-score-entry input,
.high-score-entry button {
  min-height: 38px;
  border-radius: 999px;
  font: inherit;
  font-weight: 800;
}

.high-score-entry input {
  min-width: 0;
  border: 1px solid rgba(255, 238, 194, 0.26);
  background: rgba(4, 6, 10, 0.72);
  color: #fff8e4;
  padding: 0 14px;
  text-align: center;
}

.high-score-entry input:focus-visible,
.high-score-entry button:focus-visible {
  outline: 2px solid #dfffd9;
  outline-offset: 3px;
}

.high-score-entry button {
  border: 1px solid rgba(252, 226, 175, 0.58);
  background: linear-gradient(180deg, rgba(176, 250, 195, 0.95), rgba(77, 162, 116, 0.95));
  color: #07130c;
  cursor: pointer;
}

.high-score-entry button:disabled {
  cursor: default;
  filter: grayscale(0.7);
  opacity: 0.58;
}

.high-score-status {
  min-height: 18px;
  margin-top: 7px;
  color: rgba(255, 245, 217, 0.72);
  font-size: 0.72rem;
  font-weight: 700;
}

.high-score-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 auto 12px;
}

.high-score-column {
  min-width: 0;
  padding: 9px 8px;
  border: 1px solid rgba(255, 238, 194, 0.18);
  border-radius: 8px;
  background: rgba(10, 11, 15, 0.62);
}

.high-score-column h3 {
  margin: 0 0 7px;
  color: #ffe2a8;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  line-height: 1.12;
  text-transform: uppercase;
}

.score-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.score-list li {
  padding: 5px 0;
  border-top: 1px solid rgba(255, 238, 194, 0.1);
  color: #fff8e4;
  font-size: 0.76rem;
  font-weight: 750;
}

.score-list li:first-child {
  border-top: 0;
}

.score-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.score-name {
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-time {
  color: rgba(255, 245, 217, 0.74);
}

.score-detail {
  margin-top: 2px;
  color: rgba(255, 245, 217, 0.58);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-align: left;
  text-transform: uppercase;
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  gap: 7px;
  margin: 0 auto 12px;
}

.stats-chip {
  min-width: 0;
  padding: 8px 6px;
  border: 1px solid rgba(255, 238, 194, 0.18);
  border-radius: 8px;
  background: rgba(10, 11, 15, 0.64);
}

.stats-chip strong {
  display: block;
  font-size: 1rem;
  line-height: 1.05;
}

.stats-chip span {
  display: block;
  margin-top: 3px;
  color: rgba(255, 245, 217, 0.72);
  font-size: 0.63rem;
  font-weight: 750;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid rgba(255, 238, 194, 0.18);
  border-radius: 8px;
  background: rgba(10, 11, 15, 0.66);
  font-size: clamp(0.68rem, 2.6vw, 0.82rem);
  table-layout: fixed;
}

.stats-table th,
.stats-table td {
  padding: 8px 5px;
  border-bottom: 1px solid rgba(255, 238, 194, 0.12);
}

.stats-table th {
  color: rgba(255, 245, 217, 0.74);
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stats-table td {
  color: #fff8e4;
  font-weight: 700;
}

.stats-table tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 520px) {
  #game,
  .splash-art {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border: 0;
  }

  .end-panel {
    width: 100%;
    padding-inline: 4px;
  }

  .high-score-board {
    grid-template-columns: 1fr;
  }
}
