:root {
  --bg0: #060a10;
  --bg1: #132833;
  --ink: #e8eef4;
  --muted: #8aa0b5;
  --accent: #2ec4b6;
  --accent2: #ffd166;
  --line: rgba(255, 255, 255, 0.12);
  --danger: #ff6b6b;
  --font: "Segoe UI", "Trebuchet MS", "Avenir Next", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(ellipse 90% 60% at 20% 10%, rgba(46, 196, 182, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 85% 15%, rgba(255, 209, 102, 0.12), transparent 50%),
    radial-gradient(ellipse 80% 55% at 50% 100%, rgba(116, 143, 252, 0.1), transparent 55%),
    linear-gradient(180deg, #1a3a4a 0%, #0b1520 45%, #060a10 100%);
  color: var(--ink);
  font-family: var(--font);
  user-select: none;
}

#bgWash {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 120%, rgba(46, 196, 182, 0.08), transparent 45%),
    linear-gradient(180deg, transparent 55%, rgba(6, 10, 16, 0.35) 100%);
  mix-blend-mode: screen;
  opacity: 0.85;
  animation: washPulse 12s ease-in-out infinite alternate;
}

@keyframes washPulse {
  from { opacity: 0.55; }
  to { opacity: 0.9; }
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

#canvasHost {
  position: absolute;
  inset: 0;
  z-index: 0;
}

#canvasHost canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.mute {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  z-index: 8;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(12, 18, 24, 0.65);
  color: var(--ink);
  cursor: pointer;
  font-size: 1rem;
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

.mute.muted {
  color: var(--muted);
}

.mute:hover {
  background: rgba(46, 196, 182, 0.18);
}

.screen {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.screen > * {
  pointer-events: auto;
}

.screen.hidden {
  display: none;
}

/* ---- Menu ---- */
#screen-menu {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
  background: radial-gradient(circle at 50% 30%, rgba(46, 196, 182, 0.12), transparent 55%);
}

.logo {
  font-size: clamp(2.6rem, 10vw, 4.8rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 0.95;
  background: linear-gradient(110deg, #2ec4b6, #ffd166 55%, #ff8c42);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin-top: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  font-size: 0.95rem;
}

.cta {
  margin-top: 1.4rem;
  min-width: 12rem;
  padding: 0.85rem 1.6rem;
  border: none;
  border-radius: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  color: #0c1218;
  background: linear-gradient(90deg, #2ec4b6, #ffd166);
  transition: transform 0.12s ease;
}

.cta:hover {
  transform: scale(1.04);
}

.cta.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.cta.ghost:hover {
  background: rgba(255, 255, 255, 0.06);
}

#levelPanel {
  margin-top: 1.2rem;
  width: min(28rem, 92vw);
  max-height: 40vh;
  overflow: auto;
  padding: 0.4rem;
}

#levelPanel.hidden {
  display: none;
}

#levelGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.level-btn {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 0.1rem 0.55rem;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(21, 32, 43, 0.85);
  color: var(--ink);
  cursor: pointer;
}

.level-btn .n {
  grid-row: span 2;
  align-self: center;
  font-weight: 900;
  color: var(--accent);
  font-size: 1.1rem;
}

.level-btn .nm {
  font-weight: 700;
  font-size: 0.85rem;
}

.level-btn .df {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.level-btn.done {
  border-color: rgba(46, 196, 182, 0.45);
}

.level-btn.done .n::after {
  content: " ✓";
  color: var(--accent);
}

/* ---- Game HUD ---- */
#screen-game {
  pointer-events: none;
}

#gameHud {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
}

#gameHud .left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  max-width: min(28rem, 75vw);
}

#gameHud .titles {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

#levelTitle {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

#levelMeta,
#status {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

#status {
  margin-top: 0.35rem;
  color: var(--accent2);
}

#gameHud .right {
  display: flex;
  gap: 0.45rem;
}

.iconbtn {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(12, 18, 24, 0.65);
  color: var(--ink);
  cursor: pointer;
  font-size: 1rem;
  backdrop-filter: blur(6px);
}

.iconbtn:hover {
  background: rgba(46, 196, 182, 0.18);
}

#hintBar {
  pointer-events: none;
  margin-top: auto;
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---- Win ---- */
#screen-win {
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(8, 14, 20, 0.32);
  backdrop-filter: blur(1.5px);
}

#winTitle {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: 900;
  margin-bottom: 0.4rem;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}

#winSub {
  color: var(--muted);
  margin-bottom: 1.2rem;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.5);
}

#confettiCanvas {
  position: fixed;
  inset: 0;
  z-index: 40;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

#confettiCanvas.active {
  opacity: 1;
}
