:root {
  --bg-deep: #18243a;
  --bg-mid: #31496d;
  --panel: rgba(12, 20, 32, 0.82);
  --panel-soft: rgba(255, 245, 225, 0.1);
  --ink: #f8f1e7;
  --accent: #ffcc6e;
  --accent-strong: #ff8b4d;
  --accent-green: #b8ec8f;
  --danger: #ff6b70;
  --shadow: rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 204, 110, 0.2), transparent 28%),
    radial-gradient(circle at top right, rgba(184, 236, 143, 0.15), transparent 26%),
    linear-gradient(180deg, #243654 0%, #18243a 50%, #0e1522 100%);
}

.app-shell {
  width: min(1760px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.title-bar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 20px;
}

.title-bar h1 {
  margin: 0;
  font-family: Georgia, "Palatino Linotype", serif;
  font-size: clamp(2rem, 3vw, 3.3rem);
  letter-spacing: 0.02em;
}

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

.title-copy {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
}

.title-copy span {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.07);
}

.game-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.info-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.canvas-panel,
.card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 16px 48px var(--shadow);
  backdrop-filter: blur(10px);
}

.canvas-panel {
  position: relative;
  padding: 14px;
  border-radius: 24px;
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 16px;
  background: linear-gradient(180deg, #8eb5d5 0%, #536d90 62%, #233247 100%);
}

.hud {
  position: absolute;
  inset: 24px 24px auto;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
  z-index: 2;
}

.hud-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.hud-pill {
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(11, 16, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.overlay {
  position: absolute;
  inset: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.overlay.active {
  pointer-events: auto;
}

.overlay-panel {
  width: min(760px, 100%);
  padding: 28px;
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(16, 25, 42, 0.92), rgba(9, 15, 27, 0.94)),
    radial-gradient(circle at top, rgba(255, 204, 110, 0.18), transparent 40%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

.overlay-panel h2 {
  margin: 0 0 10px;
  font-family: Georgia, "Palatino Linotype", serif;
  font-size: clamp(1.9rem, 3vw, 2.8rem);
}

.overlay-panel p {
  color: rgba(248, 241, 231, 0.9);
}

.menu-panel {
  width: min(1120px, 100%);
  max-height: 100%;
  padding: 14px;
  display: grid;
  gap: 14px;
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(15, 24, 41, 0.96), rgba(7, 12, 24, 0.97)),
    radial-gradient(circle at top right, rgba(255, 198, 108, 0.12), transparent 34%);
}

.menu-hero {
  position: relative;
  min-height: 220px;
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.menu-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(6, 11, 22, 0.88) 0%, rgba(9, 15, 27, 0.68) 44%, rgba(10, 14, 25, 0.28) 100%),
    linear-gradient(180deg, rgba(9, 14, 24, 0.04), rgba(9, 14, 24, 0.7));
}

.menu-hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.menu-hero-copy {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  padding: 22px 22px 24px;
}

.menu-kicker {
  margin-bottom: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 214, 142, 0.92);
}

.menu-hero-copy h2 {
  margin: 0 0 12px;
  font-size: clamp(2.2rem, 4.3vw, 3.7rem);
  line-height: 0.96;
}

.menu-hero-copy p {
  max-width: 32ch;
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.4;
}

.menu-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.menu-pill {
  border-radius: 999px;
  padding: 9px 13px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(248, 241, 231, 0.92);
  backdrop-filter: blur(10px);
}

.menu-hero-actions {
  margin-top: 14px;
}

.menu-section {
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.menu-section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 12px;
}

.menu-section-head h3 {
  margin: 0;
  font-size: 1.25rem;
}

.menu-section-head p {
  margin: 0;
  max-width: 34ch;
  text-align: right;
  color: rgba(248, 241, 231, 0.7);
}

.victory-panel {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  background:
    radial-gradient(circle at top left, rgba(255, 207, 108, 0.24), transparent 34%),
    linear-gradient(180deg, rgba(22, 29, 48, 0.95), rgba(8, 13, 25, 0.97));
}

.victory-art-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 320px;
  border-radius: 22px;
  background:
    radial-gradient(circle at center, rgba(255, 204, 110, 0.18), rgba(255, 204, 110, 0.03) 52%, transparent 72%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.victory-art {
  display: block;
  width: min(100%, 340px);
  max-height: 420px;
  object-fit: contain;
  filter: drop-shadow(0 20px 34px rgba(0, 0, 0, 0.32));
}

.victory-copy h2 {
  margin-bottom: 14px;
}

.victory-copy p {
  margin: 0 0 12px;
  line-height: 1.55;
}

.button-row,
.level-grid,
.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.menu-level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

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

button,
input[type="range"] {
  pointer-events: auto;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  font: inherit;
  color: #172335;
  background: linear-gradient(180deg, #ffd57d 0%, #ffb55b 100%);
  box-shadow: 0 10px 24px rgba(255, 140, 77, 0.22);
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(255, 140, 77, 0.28);
}

button.secondary {
  background: linear-gradient(180deg, #dce8f2 0%, #afc4d6 100%);
}

button.ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  transform: none;
  box-shadow: none;
}

.card {
  border-radius: 22px;
  padding: 18px;
}

.card h2 {
  margin-top: 0;
  font-family: Georgia, "Palatino Linotype", serif;
}

.card p {
  margin: 0 0 12px;
  line-height: 1.5;
}

.card code {
  font-family: Consolas, monospace;
  color: var(--accent);
}

.setting {
  min-width: 240px;
  padding: 14px;
  border-radius: 16px;
  background: var(--panel-soft);
}

.setting label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.setting small {
  color: rgba(248, 241, 231, 0.76);
}

.level-card {
  min-height: 172px;
  display: flex;
  flex-direction: column;
  padding: 16px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.025)),
    radial-gradient(circle at top right, rgba(255, 199, 110, 0.08), transparent 42%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.level-card h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.level-card p {
  margin: 0;
  color: rgba(248, 241, 231, 0.78);
  line-height: 1.35;
  font-size: 0.96rem;
}

.level-card-eyebrow {
  margin-bottom: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 214, 142, 0.82);
}

.level-card-actions {
  margin-top: auto;
}

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

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

  .title-bar {
    flex-direction: column;
    align-items: start;
  }

  .canvas-panel {
    padding: 10px;
    border-radius: 18px;
  }

  .overlay {
    inset: 10px;
  }

  .overlay-panel {
    padding: 20px;
  }

  .menu-panel {
    padding: 12px;
  }

  .menu-hero {
    min-height: 240px;
  }

  .menu-hero-copy {
    width: 100%;
    padding: 22px 20px 24px;
  }

  .menu-hero-copy h2 {
    font-size: clamp(2.05rem, 9vw, 3rem);
  }

  .menu-hero-copy p {
    max-width: none;
  }

  .menu-section-head {
    align-items: start;
    flex-direction: column;
  }

  .menu-section-head p {
    text-align: left;
  }

  .menu-level-grid,
  .menu-settings-grid {
    grid-template-columns: 1fr;
  }

  .victory-panel {
    grid-template-columns: 1fr;
  }

  .victory-art-wrap {
    min-height: 240px;
  }

  .victory-art {
    width: min(100%, 280px);
    max-height: 320px;
  }

  .hud {
    inset: 18px 18px auto;
    gap: 10px;
  }

  .hud-pill {
    padding: 8px 12px;
    font-size: 0.92rem;
  }
}
