* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep: #0a0e1a;
  --panel: #131a2b;
  --panel-2: #1c2740;
  --cyan: #5ad1e6;
  --blue: #2f8fd6;
  --yellow: #ffcc33;
  --orange: #ff9933;
  --pink: #ff4d6d;
  --text: #eaf2ff;
  --text-dim: #8fa3c4;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

/* ===================== MENU ===================== */

#menu-screen {
  background: radial-gradient(ellipse at 50% 20%, #1a2a4a 0%, #0a0e1a 70%);
}

.menu-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.floaty {
  position: absolute;
  opacity: 0.16;
  filter: blur(0.5px);
  animation: floatUp 14s linear infinite;
}
.floaty.sq { border-radius: 6px; }
.floaty.circ { border-radius: 50%; }
.floaty.tri {
  width: 0; height: 0; background: none !important;
  border-left: 26px solid transparent;
  border-right: 26px solid transparent;
  border-bottom: 46px solid var(--pink);
}

.c1 { left: 8%;  width: 60px; height: 60px; background: var(--cyan); animation-duration: 16s; animation-delay: 0s; }
.c2 { left: 22%; animation-duration: 12s; animation-delay: 2s; }
.c3 { left: 42%; width: 40px; height: 40px; background: var(--yellow); animation-duration: 18s; animation-delay: 4s; }
.c4 { left: 62%; width: 50px; height: 50px; background: var(--pink); animation-duration: 15s; animation-delay: 1s; }
.c5 { left: 78%; width: 34px; height: 34px; background: var(--blue); animation-duration: 20s; animation-delay: 6s; }
.c6 { left: 90%; animation-duration: 13s; animation-delay: 3s; }

@keyframes floatUp {
  from { transform: translateY(110vh) rotate(0deg); }
  to   { transform: translateY(-15vh) rotate(360deg); }
}

.menu-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 24px;
  text-align: center;
}

.game-title {
  font-size: clamp(2.2rem, 7vw, 4.2rem);
  font-weight: 900;
  letter-spacing: 4px;
  line-height: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-shadow: 0 0 24px rgba(90, 209, 230, 0.55);
}
.game-title span { color: var(--text); }
.game-title .accent {
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.level-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(88vw, 380px);
  padding: 14px 18px;
  border-radius: 14px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 2px solid rgba(90, 209, 230, 0.35);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.06);
}

.level-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  flex: none;
  border-radius: 10px;
  background: linear-gradient(160deg, #244a6b, #0e2338);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb-shape {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: linear-gradient(160deg, var(--cyan), var(--blue));
  box-shadow: 0 0 12px rgba(90,209,230,0.7);
  transform: rotate(15deg);
}
.thumb-shape2 {
  position: absolute;
  width: 0; height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 18px solid var(--pink);
  right: 10px; bottom: 8px;
  background: none;
  box-shadow: none;
}

.level-info { text-align: left; }
.level-info h2 { font-size: 1.2rem; font-weight: 800; }
.level-info p { font-size: 0.8rem; color: var(--text-dim); margin-top: 2px; }
.stars { margin-top: 6px; font-size: 0.85rem; color: var(--yellow); font-weight: 700; }
.diff { color: var(--cyan); margin-left: 6px; letter-spacing: 1px; }

.btn-play {
  width: min(70vw, 260px);
  padding: 16px 0;
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 3px;
  color: #0a0e1a;
  background: linear-gradient(160deg, #ffe066, var(--orange));
  border: none;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 6px 0 #b3661a, 0 10px 24px rgba(255, 153, 51, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn-play:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #b3661a, 0 6px 14px rgba(255, 153, 51, 0.3);
}

.menu-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-dim);
  font-size: 0.9rem;
}
.best-pct span { color: var(--cyan); font-weight: 700; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(255,255,255,0.12); }

.credits {
  max-width: 420px;
  font-size: 0.7rem;
  color: rgba(143, 163, 196, 0.6);
  line-height: 1.4;
}

/* ===================== GAME ===================== */

#game-screen {
  background: #000;
  flex-direction: column;
}

#canvas-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

#game-canvas {
  display: block;
  touch-action: none;
  background: #0a0e1a;
  border-radius: 4px;
}

.hint {
  position: absolute;
  bottom: 14%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(0.75rem, 2vw, 1rem);
  letter-spacing: 2px;
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.35);
  padding: 8px 16px;
  border-radius: 20px;
  pointer-events: none;
  animation: hintPulse 1.6s ease-in-out infinite;
  transition: opacity 0.3s ease;
}
.hint.hidden { opacity: 0; }
@keyframes hintPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

#progress-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: rgba(255,255,255,0.08);
  z-index: 5;
}
#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--yellow));
  box-shadow: 0 0 10px rgba(90,209,230,0.6);
  transition: width 0.08s linear;
}

#hud {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 18px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-dim);
  letter-spacing: 1px;
  z-index: 5;
  pointer-events: none;
}
#pct-counter { color: var(--text); font-size: 1rem; }

.hud-pause {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 6;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 16, 0.72);
  backdrop-filter: blur(3px);
  z-index: 10;
}
.overlay.hidden { display: none; }

.overlay-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px 36px;
  border-radius: 16px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 2px solid rgba(90, 209, 230, 0.35);
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  min-width: 240px;
}
.overlay-panel h2 { font-size: 1.4rem; font-weight: 900; letter-spacing: 1px; }
.complete-title {
  background: linear-gradient(90deg, var(--yellow), var(--orange));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
#complete-stats { color: var(--text-dim); font-size: 0.9rem; text-align: center; }

.btn {
  width: 100%;
  padding: 12px 0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: #0a0e1a;
  background: linear-gradient(160deg, var(--cyan), var(--blue));
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 0 #1c5a86;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #1c5a86; }
.btn-secondary {
  background: linear-gradient(160deg, #3a4560, #232d45);
  color: var(--text);
  box-shadow: 0 4px 0 #131a2b;
}
