:root {
  --bg-1: #fef6e4;
  --bg-2: #ffe8cc;
  --ink: #2b2c34;
  --wall: #5a6acf;
  --wall-soft: #8b97e6;
  --floor: #fffaf2;
  --accent: #ff8ba7;
  --accent-2: #ffc6c7;
  --gold: #f6c453;
  --good: #3ddc97;
  --panel: #fffaf2;
  --shadow: rgba(90, 106, 207, 0.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  font-family: 'Baloo 2', 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 30% 20%, var(--bg-2), var(--bg-1) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
}

.back-link {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  z-index: 50;
  text-decoration: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  padding: 8px 14px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 4px 14px var(--shadow);
  backdrop-filter: blur(6px);
  transition: transform 0.12s ease, background 0.12s ease;
}
.back-link:hover { transform: translateY(-1px); background: #fff; }

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(94vw, 94vh, 720px);
}

.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  padding: 10px 14px;
  box-shadow: 0 6px 20px var(--shadow);
  backdrop-filter: blur(6px);
}
.hud-item { display: flex; flex-direction: column; line-height: 1.1; margin-right: 6px; }
.hud-label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.6; font-weight: 600; }
.hud-val { font-size: 22px; font-weight: 800; }
.peek-btn {
  margin-left: auto;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--gold), #ffd980);
  color: #5a4500;
  font-weight: 800;
  font-family: inherit;
  font-size: 15px;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(246, 196, 83, 0.5);
  transition: transform 0.1s ease, filter 0.1s ease;
}
.peek-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.peek-btn:active { transform: translateY(0); }
.peek-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 26px;
  overflow: hidden;
  box-shadow: 0 18px 50px var(--shadow);
  background: var(--floor);
}

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

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(255, 246, 228, 0.86);
  backdrop-filter: blur(4px);
  transition: opacity 0.25s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.panel {
  text-align: center;
  padding: 26px 30px;
  max-width: 88%;
}
.logo { font-size: 64px; line-height: 1; margin-bottom: 6px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.panel h1 {
  font-family: 'Fredoka', 'Baloo 2', sans-serif;
  font-size: clamp(34px, 8vw, 56px);
  margin: 4px 0 6px;
  color: var(--wall);
  letter-spacing: -0.5px;
}
.panel h2 { font-size: clamp(26px, 6vw, 38px); margin: 4px 0 8px; color: var(--good); }
.tagline { margin: 0 0 18px; font-size: 16px; opacity: 0.8; font-weight: 500; }

.play-btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  font-size: 22px;
  color: #fff;
  padding: 14px 42px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #ff6f91);
  box-shadow: 0 10px 24px rgba(255, 111, 145, 0.45);
  transition: transform 0.12s ease, filter 0.12s ease;
}
.play-btn:hover { transform: translateY(-2px) scale(1.02); filter: brightness(1.05); }
.play-btn:active { transform: translateY(0) scale(0.99); }

.best { margin: 16px 0 4px; font-weight: 700; font-size: 16px; opacity: 0.85; }
.howto { margin: 4px 0 0; font-size: 14px; opacity: 0.65; font-weight: 500; }
.win-stats { font-size: 17px; font-weight: 600; margin: 6px 0 20px; opacity: 0.85; line-height: 1.6; }

.touch-hint {
  font-size: 13px;
  opacity: 0.55;
  font-weight: 600;
  display: none;
}
@media (hover: none) and (pointer: coarse) {
  .touch-hint { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .logo { animation: none; }
  .play-btn:hover, .peek-btn:hover, .back-link:hover { transform: none; }
}
