:root {
  --bg: #0b1220;
  --bg-soft: #111c30;
  --panel: rgba(14, 24, 40, 0.92);
  --panel-2: rgba(18, 31, 52, 0.88);
  --border: rgba(165, 192, 230, 0.16);
  --text: #edf5ff;
  --muted: #a9bed8;
  --accent: #63d2ff;
  --accent-2: #78ffb3;
  --gold: #ffd166;
  --danger: #ff6b7a;
  --shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  background: #08101d;
  color: var(--text);
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  display: flex;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(6, 12, 22, 0.52) 0%, rgba(7, 12, 22, 0.68) 100%),
    url("assets/background/background.png") center center / cover no-repeat;
  z-index: -2;
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top, rgba(99, 210, 255, 0.12), transparent 30%),
    radial-gradient(circle at bottom right, rgba(120, 255, 179, 0.08), transparent 24%);
  z-index: -1;
  pointer-events: none;
}

button {
  font: inherit;
}


.audio-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 60;
}

.audio-controls.is-floating {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
}

.audio-controls.is-inline {
  position: static;
}

.audio-toggle {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(7, 15, 26, 0.18);
  color: rgba(237, 245, 255, 0.94);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, opacity 0.14s ease;
}

.audio-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(7, 15, 26, 0.28);
}

.audio-toggle:active {
  transform: translateY(0);
}

.audio-toggle-icon {
  font-size: 1.08rem;
  line-height: 1;
}

.audio-toggle.is-off {
  opacity: 0.72;
}

.audio-toggle.is-off::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 2px;
  background: rgba(255, 107, 122, 0.95);
  border-radius: 999px;
  transform: rotate(-45deg);
}

.preload-screen {
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at top, rgba(99, 210, 255, 0.16), transparent 32%),
    linear-gradient(180deg, rgba(7, 14, 27, 0.94), rgba(8, 16, 28, 0.96));
  z-index: 140;
}

.preload-panel {
  width: min(420px, calc(100vw - 32px));
  padding: 28px 24px;
  border-radius: 24px;
  border: 1px solid rgba(165, 192, 230, 0.18);
  background: linear-gradient(180deg, rgba(16, 26, 43, 0.96), rgba(10, 18, 31, 0.96));
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.38);
  display: grid;
  justify-items: center;
  gap: 14px;
}

.preload-logo {
  width: min(72vw, 300px);
  max-width: 100%;
  height: auto;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.3));
}

.preload-spinner {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 4px solid rgba(99, 210, 255, 0.18);
  border-top-color: rgba(99, 210, 255, 0.92);
  animation: rr-spin 0.85s linear infinite;
}

.preload-text {
  margin: 0;
  color: #dfeeff;
  font-weight: 700;
  letter-spacing: 0.04em;
}

@keyframes rr-spin {
  to { transform: rotate(360deg); }
}

body.is-preloading #audioControls {
  opacity: 0;
  pointer-events: none;
}


/* ══════════════════════════════════════════════
   SCREEN SYSTEM
══════════════════════════════════════════════ */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.38s ease, transform 0.38s ease;
  transform: translateY(12px);
  z-index: 1;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: none;
  z-index: 10;
}

/* ══════════════════════════════════════════════
   MENU SCREEN
══════════════════════════════════════════════ */
.menu-screen {
  background:
    linear-gradient(180deg, rgba(6, 14, 28, 0.58) 0%, rgba(10, 21, 38, 0.74) 100%);
  overflow: hidden;
}

.menu-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("assets/art/menuart.png") center center / cover no-repeat;
  opacity: 0.22;
  pointer-events: none;
  z-index: 0;
}

.menu-bg-rail {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(180deg, rgba(6, 14, 28, 0.28), rgba(10, 21, 38, 0.44)),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 60px,
      rgba(165, 192, 230, 0.04) 60px,
      rgba(165, 192, 230, 0.04) 61px
    ),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 60px,
      rgba(165, 192, 230, 0.04) 60px,
      rgba(165, 192, 230, 0.04) 61px
    );
  z-index: 1;
}

.menu-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
  z-index: 2;
}

.menu-eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
  opacity: 0.85;
}

.menu-title {
  margin: 0 0 18px;
  font-size: clamp(3.5rem, 8vw, 6.5rem);
  line-height: 0.92;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #edf5ff 0%, #63d2ff 55%, #78ffb3 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.menu-subtitle {
  margin: 0 0 52px;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 340px;
}

.menu-buttons {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
}

.menu-story-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.menu-endless-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.menu-mini-btn {
  appearance: none;
  border: 1px solid rgba(255, 107, 122, 0.22);
  background: rgba(255, 107, 122, 0.08);
  color: #ffd6db;
  padding: 9px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.menu-mini-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 107, 122, 0.42);
  background: rgba(255, 107, 122, 0.12);
}

.menu-mini-btn-blue {
  border-color: rgba(99, 210, 255, 0.28);
  background: rgba(99, 210, 255, 0.1);
  color: #d7f3ff;
}

.menu-mini-btn-blue:hover {
  border-color: rgba(99, 210, 255, 0.52);
  background: rgba(99, 210, 255, 0.16);
}

.menu-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.02) 100%);
  color: var(--text);
  padding: 22px 32px;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 180px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.menu-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.36);
}

.menu-btn:active {
  transform: translateY(0) scale(0.98);
}

.menu-btn-story {
  border-color: rgba(255, 209, 102, 0.38);
  background: linear-gradient(180deg, rgba(255, 209, 102, 0.16) 0%, rgba(255, 209, 102, 0.05) 100%);
  box-shadow: 0 12px 36px rgba(255, 209, 102, 0.12);
}

.menu-btn-story:hover {
  border-color: rgba(255, 209, 102, 0.65);
  box-shadow: 0 20px 50px rgba(255, 209, 102, 0.2);
}

.menu-btn-endless {
  border-color: rgba(99, 210, 255, 0.38);
  background: linear-gradient(180deg, rgba(99, 210, 255, 0.16) 0%, rgba(99, 210, 255, 0.05) 100%);
  box-shadow: 0 12px 36px rgba(99, 210, 255, 0.12);
}

.menu-btn-endless:hover {
  border-color: rgba(99, 210, 255, 0.65);
  box-shadow: 0 20px 50px rgba(99, 210, 255, 0.22);
}

.menu-btn-icon {
  font-size: 2rem;
  line-height: 1;
}

.menu-btn-label {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.menu-btn-sub {
  font-size: 0.8rem;
  color: var(--muted);
}


.menu-btn.is-locked {
  cursor: default;
  filter: saturate(0.78) brightness(0.88);
}

.menu-btn.is-locked::before {
  filter: grayscale(0.18) brightness(0.92);
}

.menu-btn.is-locked:hover,
.menu-btn.is-locked:focus-visible,
.menu-btn:disabled:hover,
.menu-btn:disabled:focus-visible {
  transform: none;
  outline: none;
}

.menu-btn.is-locked:hover::before,
.menu-btn.is-locked:focus-visible::before,
.menu-btn:disabled:hover::before,
.menu-btn:disabled:focus-visible::before {
  transform: none;
  filter: grayscale(0.18) brightness(0.92);
}

.menu-btn-label-lock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.menu-inline-star {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.menu-exit-btn {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 3;
  min-width: 96px;
}

/* ══════════════════════════════════════════════
   LEVEL SELECT SCREEN
══════════════════════════════════════════════ */
.level-select-screen {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 209, 102, 0.10) 0%, transparent 55%),
    linear-gradient(180deg, rgba(6, 14, 28, 0.38) 0%, rgba(10, 21, 38, 0.56) 100%);
  padding: 8px 24px 24px;
  gap: 22px;
  justify-content: flex-start;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  max-width: 1480px;
  min-height: 40px;
}

.ls-left-group {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex-wrap: wrap;
}

.ls-controls-slot {
  display: flex;
  align-items: center;
}

.ls-controls-slot .audio-toggle {
  width: 38px;
  height: 38px;
}

.level-select-screen button {
  font-family: "Luckiest Guy", "Trebuchet MS", sans-serif;
  letter-spacing: 0.04em;
}

.ls-title {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffd166, #ff9966);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.back-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: color 0.14s, border-color 0.14s, transform 0.14s;
  white-space: nowrap;
}

.back-btn:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateX(-2px);
}

.ls-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 1480px;
  padding-bottom: 18px;
}

.level-card {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%);
  border-radius: 14px;
  padding: 10px 6px 8px;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  position: relative;
  overflow: hidden;
}

.level-card.unlocked {
  border-color: rgba(255, 209, 102, 0.35);
  background: linear-gradient(180deg, rgba(255, 209, 102, 0.13) 0%, rgba(255, 209, 102, 0.04) 100%);
}

.level-card.unlocked:hover {
  transform: translateY(-5px);
  border-color: rgba(255, 209, 102, 0.65);
  box-shadow: 0 18px 40px rgba(255, 209, 102, 0.18);
}

.level-card.completed {
  border-color: rgba(120, 255, 179, 0.45);
  background: linear-gradient(180deg, rgba(120, 255, 179, 0.14) 0%, rgba(120, 255, 179, 0.04) 100%);
}

.level-card.completed:hover {
  transform: translateY(-5px);
  border-color: rgba(120, 255, 179, 0.7);
  box-shadow: 0 18px 40px rgba(120, 255, 179, 0.18);
}

.level-card.locked {
  border-color: rgba(255, 255, 255, 0.06);
  opacity: 0.45;
  cursor: not-allowed;
}

.level-card-number {
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
}

.level-card.unlocked .level-card-number { color: #ffd166; }
.level-card.completed .level-card-number { color: #78ffb3; }
.level-card.locked .level-card-number { color: var(--muted); }

.level-card-name {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: center;
  line-height: 1.1;
}

.level-card-stars {
  margin-top: auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 28px;
  width: 100%;
}

.level-card-stars-image {
  max-width: 72%;
  max-height: 24px;
  object-fit: contain;
}

.level-card-action {
  margin-top: auto;
  font-size: 0.7rem;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(237, 245, 255, 0.92);
}

.level-star {
  font-size: 0.82rem;
  line-height: 1;
}

.level-star.filled {
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 209, 102, 0.28);
}

.level-star.empty {
  color: rgba(169, 190, 216, 0.28);
}

.level-card-status {
  font-size: 0.9rem;
  line-height: 1;
}

.ls-hint {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(169, 190, 216, 0.55);
  text-align: center;
}

.ls-stars-summary {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--gold);
  font-size: 1rem;
  font-weight: 800;
  white-space: nowrap;
}

.ls-stars-summary img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex: 0 0 auto;
}

.ls-stars-count {
  color: #fff2c7;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.menu-modal-layer {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 10, 18, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 30;
}

.menu-modal-layer.is-open {
  display: flex;
}

.menu-modal-panel {
  width: min(420px, calc(100vw - 32px));
  border-radius: 22px;
  border: 1px solid rgba(165, 192, 230, 0.18);
  background: linear-gradient(180deg, rgba(17, 29, 49, 0.98), rgba(10, 18, 31, 0.98));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  padding: 22px 20px 20px;
}

.menu-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.menu-modal-title {
  margin: 0;
  font-size: 1.32rem;
  color: #fff4cf;
}

.menu-modal-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.menu-modal-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-danger {
  background: linear-gradient(180deg, rgba(255, 107, 122, 0.3), rgba(255, 107, 122, 0.14));
  border-color: rgba(255, 107, 122, 0.56);
  color: #ffe3e7;
  box-shadow: 0 10px 24px rgba(255, 107, 122, 0.18);
}

.btn-danger:hover {
  border-color: rgba(255, 107, 122, 0.74);
}

.menu-modal-close {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.menu-modal-close:hover {
  transform: translateY(-1px);
  border-color: rgba(99, 210, 255, 0.45);
  background: rgba(255, 255, 255, 0.1);
}

.options-panel {
  width: min(460px, calc(100vw - 32px));
}

.options-row {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.options-label {
  color: #ecf6ff;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.options-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.options-slider {
  width: 100%;
  accent-color: #63d2ff;
  cursor: pointer;
}

.options-value {
  min-width: 52px;
  text-align: right;
  color: #fff2c7;
  font-weight: 800;
}

/* ══════════════════════════════════════════════
   GAME SCREEN (wraps existing layout)
══════════════════════════════════════════════ */
.game-screen {
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  background: linear-gradient(180deg, rgba(6, 14, 28, 0.18) 0%, rgba(10, 21, 38, 0.34) 100%);
}

.app-shell {
  width: 100%;
  height: 100dvh;
  padding: 64px 12px 12px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 0;
}


.title-group {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.story-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.story-title-row h1 {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-level-number,
.story-inline-audio {
  display: none;
}

.story-level-number {
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 209, 102, 0.2);
  background: rgba(255, 209, 102, 0.08);
  color: var(--gold);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16);
}

.story-inline-audio {
  align-items: center;
  gap: 8px;
}

.story-inline-toggle {
  width: 36px;
  height: 36px;
  background: rgba(7, 15, 26, 0.28);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 1.5vw + 1rem, 2.45rem);
  line-height: 1;
}

.header-actions,
.difficulty-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
  align-items: stretch;
  min-height: 0;
}

.game-panel,
.card {
  background: linear-gradient(180deg, rgba(16, 26, 43, 0.94), rgba(10, 18, 31, 0.94));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.game-panel {
  padding: 12px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
}

.story-timer {
  display: none;
  justify-self: center;
  min-width: 112px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 209, 102, 0.22);
  background: rgba(255, 209, 102, 0.08);
  color: #fff2c7;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.game-screen.story-mode .story-timer {
  display: block;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  align-self: center;
  border-radius: 18px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(9, 17, 31, 0.24), rgba(8, 17, 29, 0.34)),
    url("assets/background/background.png") center center / cover no-repeat;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}

.sidebar {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  align-content: start;
}

.card {
  padding: 14px;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 0.96rem;
}

.card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.95rem;
}

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

.label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.status-grid strong {
  font-size: 1.08rem;
}

.btn,
.chip {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  color: var(--text);
  padding: 9px 13px;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.btn:hover,
.chip:hover {
  transform: translateY(-1px);
  border-color: rgba(99, 210, 255, 0.45);
}

.btn:active,
.chip:active {
  transform: translateY(1px) scale(0.985);
}

.btn-primary,
.chip.is-active {
  background: linear-gradient(180deg, rgba(99, 210, 255, 0.28), rgba(99, 210, 255, 0.13));
  border-color: rgba(99, 210, 255, 0.55);
  box-shadow: 0 10px 24px rgba(99, 210, 255, 0.18);
}

.legend-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.legend-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  flex: 0 0 auto;
}

.swatch.start {
  background: rgba(120, 255, 179, 0.75);
}

.swatch.goal {
  background: rgba(255, 209, 102, 0.8);
}

.swatch.current {
  background: rgba(99, 210, 255, 0.8);
}

.swatch.next {
  background: rgba(255, 255, 255, 0.32);
}

.swatch.warning {
  background: rgba(255, 107, 122, 0.85);
}

body.story-ui-active #audioControls {
  opacity: 0;
  pointer-events: none;
}

.game-screen.story-mode .app-shell,
.game-screen.endless-mode .app-shell {
  padding: 12px;
  gap: 10px;
}

.game-screen.story-mode .topbar,
.game-screen.endless-mode .topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.game-screen.story-mode .eyebrow,
.game-screen.endless-mode .eyebrow {
  display: none;
}

.game-screen.story-mode .story-level-number,
.game-screen.endless-mode .story-level-number {
  display: inline-flex;
}

.game-screen.story-mode .story-inline-audio,
.game-screen.endless-mode .story-inline-audio {
  display: inline-flex;
}

.game-screen.story-mode .title-group,
.game-screen.endless-mode .title-group {
  justify-self: start;
}

.game-screen.story-mode .header-actions,
.game-screen.endless-mode .header-actions {
  justify-self: end;
  justify-content: flex-end;
}

.game-screen.story-mode .story-title-row h1,
.game-screen.endless-mode .story-title-row h1 {
  font-size: clamp(1.05rem, 0.9vw + 0.7rem, 1.55rem);
}

.game-screen.story-mode .header-actions .btn,
.game-screen.endless-mode .header-actions .btn {
  padding: 8px 12px;
}

.game-screen.story-mode .layout,
.game-screen.endless-mode .layout {
  grid-template-columns: minmax(0, 1fr);
}

.game-screen.story-mode .sidebar,
.game-screen.endless-mode .sidebar {
  display: none;
}

.game-screen.story-mode .game-panel,
.game-screen.endless-mode .game-panel {
  padding: 8px;
  gap: 0;
}

.game-screen.story-mode .canvas-wrap,
.game-screen.endless-mode .canvas-wrap {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}



.game-screen.endless-mode .story-level-number {
  display: none;
}

.game-screen.endless-mode #difficultyRow {
  display: inline-flex;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  gap: 8px;
  flex-wrap: wrap;
}

.game-screen.endless-mode #difficultyRow .chip {
  min-width: 78px;
}

.game-screen.endless-mode .header-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Story mode: hide difficulty picker and new puzzle */
.story-mode #difficultyRow {
  display: none;
}

.story-mode #newPuzzleBtn {
  display: none;
}

/* Level complete overlay next-level button */
.next-level-hint {
  font-size: 13px;
  color: rgba(237, 245, 255, 0.6);
  margin-top: 2px;
}

@media (max-width: 1040px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
  }

  .layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .game-panel {
    min-height: min(72vh, 760px);
  }

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

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions .btn {
    flex: 1;
  }

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

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

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

  .game-screen.story-mode .topbar,
.game-screen.endless-mode .topbar {
    grid-template-columns: 1fr;
  }

  .game-screen.story-mode .title-group,
  .game-screen.story-mode .story-timer,
  .game-screen.story-mode .header-actions,
.game-screen.endless-mode .header-actions {
    justify-self: stretch;
  }

  .menu-buttons {
    flex-direction: column;
    align-items: stretch;
    width: min(340px, 90vw);
  }

  .menu-story-group,
  .menu-endless-group {
    width: 100%;
  }
}


@media (max-width: 900px) {
  .ls-header {
    max-width: 680px;
    flex-wrap: wrap;
  }

  .ls-left-group {
    width: 100%;
    justify-content: center;
  }

  .ls-stars-summary {
    margin-left: 0;
  }
}


@media (max-width: 1400px) {
  .ls-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .ls-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}


@media (max-width: 900px) {
  .ls-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .ls-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ══════════════════════════════════════════════
   ARTWORK BUTTON REFRESH
══════════════════════════════════════════════ */
.menu-title {
  margin: 0 0 28px;
  line-height: 1;
  background: none;
  -webkit-text-fill-color: initial;
}

.menu-logo {
  display: block;
  width: min(54vw, 480px);
  max-width: 100%;
  height: auto;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.36));
}

.menu-btn,
.level-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: none;
  background: transparent;
  box-shadow: none;
}

.menu-btn::before,
.level-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("assets/art/button.png") center center / 100% 100% no-repeat;
  z-index: 0;
  transition: transform 0.18s ease, filter 0.18s ease;
  pointer-events: none;
}

.menu-btn > *,
.level-card > * {
  position: relative;
  z-index: 1;
}

.menu-btn {
  min-width: 180px;
  min-height: 132px;
  padding: 24px 20px 22px;
  justify-content: center;
  gap: 6px;
}

.menu-btn-story,
.menu-btn-endless,
.menu-btn-story:hover,
.menu-btn-endless:hover {
  border: none;
  background: transparent;
  box-shadow: none;
}

.menu-btn:hover,
.menu-btn:focus-visible {
  transform: translateY(-4px);
  outline: none;
}

.menu-btn:hover::before,
.menu-btn:focus-visible::before,
.level-card:hover::before,
.level-card:focus-visible::before {
  transform: scale(1.015);
  filter: brightness(1.08);
}

.menu-btn-story:hover,
.menu-btn-story:focus-visible {
  filter: drop-shadow(0 0 18px rgba(255, 209, 102, 0.55)) drop-shadow(0 16px 26px rgba(0, 0, 0, 0.28));
}

.menu-btn-endless:hover,
.menu-btn-endless:focus-visible {
  filter: drop-shadow(0 0 18px rgba(99, 210, 255, 0.55)) drop-shadow(0 16px 26px rgba(0, 0, 0, 0.28));
}

.menu-btn-label,
.menu-btn-sub,
.level-card-number,
.level-card-name,
.level-card-action {
  color: #ffffff;
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.95),
    1px 0 0 rgba(0, 0, 0, 0.95),
    -1px 0 0 rgba(0, 0, 0, 0.95),
    0 -1px 0 rgba(0, 0, 0, 0.95),
    1px 1px 0 rgba(0, 0, 0, 0.85),
    -1px 1px 0 rgba(0, 0, 0, 0.85),
    1px -1px 0 rgba(0, 0, 0, 0.85),
    -1px -1px 0 rgba(0, 0, 0, 0.85);
  -webkit-text-stroke: 0.65px rgba(0, 0, 0, 0.92);
}

.menu-btn-label {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.menu-btn-sub {
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0.98;
}

.level-card {
  min-height: 104px;
  padding: 9px 8px 10px;
  justify-content: flex-start;
  gap: 2px;
}

.level-card.unlocked,
.level-card.completed,
.level-card.locked {
  border: none;
  background: transparent;
  box-shadow: none;
}

.level-card.unlocked:hover,
.level-card.unlocked:focus-visible {
  transform: translateY(-5px);
  box-shadow: none;
  filter: drop-shadow(0 0 14px rgba(255, 209, 102, 0.55)) drop-shadow(0 12px 18px rgba(0, 0, 0, 0.26));
  outline: none;
}

.level-card.completed:hover,
.level-card.completed:focus-visible {
  transform: translateY(-5px);
  box-shadow: none;
  filter: drop-shadow(0 0 14px rgba(120, 255, 179, 0.55)) drop-shadow(0 12px 18px rgba(0, 0, 0, 0.26));
  outline: none;
}

.level-card.locked {
  opacity: 0.46;
}

.level-card.locked::before {
  filter: brightness(0.82);
}

.level-card.unlocked .level-card-number,
.level-card.completed .level-card-number,
.level-card.locked .level-card-number {
  color: #ffffff;
}

.level-card-number {
  font-size: 1.32rem;
  font-weight: 900;
  line-height: 1;
  margin-top: 1px;
}

.level-card-name {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  line-height: 1.08;
  min-height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.level-card-stars {
  margin-top: auto;
  min-height: 24px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
}

.level-card-stars-image {
  display: block;
  max-width: 72%;
  max-height: 24px;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.level-card-action {
  margin-top: auto;
  font-size: 0.67rem;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.07em;
}

@media (max-width: 720px) {
  .menu-logo {
    width: min(76vw, 420px);
  }
}


@media (max-width: 900px) {
  .ls-header {
    flex-wrap: wrap;
    justify-content: center;
  }

  .ls-left-group {
    justify-content: center;
  }

  .ls-stars-summary {
    width: 100%;
    justify-content: center;
    margin-left: 0;
  }
}
