:root {
  --bg-1: #3a3562;
  --bg-2: #1d1631;
  --cream: #f2f5f8;
  --accent: #ffb300;
  --accent-dark: #c98600;
  --panel: rgba(24, 20, 44, 0.92);

  --font-display: "Baloo 2", "Segoe UI", sans-serif;
  --font-body: "Poppins", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg-2);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.game-frame {
  position: relative;
  width: 100vw;
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  overflow: hidden;
}

html.ksz-fullscreen .game-frame {
  height: 100vh;
  height: 100dvh;
}

.play-area {
  position: relative;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at 50% 0%, var(--bg-1), var(--bg-2) 75%);
  touch-action: none;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

/* ---------------- Screens ---------------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

#screen-start { background: rgba(14, 10, 28, 0.62); backdrop-filter: blur(2px); }
.screen--overlay { background: rgba(14, 10, 28, 0.55); }
#screen-game { pointer-events: none; align-items: flex-start; padding: 0; overflow: visible; }
#screen-game .hud { pointer-events: auto; }

.start-content {
  max-width: 560px;
  text-align: center;
  color: var(--cream);
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.2rem, 8vw, 3.6rem);
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 3px 0 rgba(0,0,0,0.35);
  margin: 0 0 18px;
}

.hint {
  font-size: 0.96rem;
  line-height: 1.6;
  color: rgba(242,245,248,0.88);
  margin: 0 0 22px;
}

.controls-help {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 22px;
  margin: 0 0 26px;
  font-size: 0.9rem;
  color: var(--cream);
}
.controls-help div { display: flex; align-items: center; gap: 6px; }
.controls-help span { opacity: 0.7; margin-left: 4px; }
.controls-help .touch-only { display: none; }
@media (pointer: coarse) {
  .controls-help div:not(.touch-only) { display: none; }
  .controls-help .touch-only { display: flex; }
}

kbd {
  display: inline-block;
  min-width: 26px;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.1);
  font-family: var(--font-body);
  font-size: 0.8rem;
  text-align: center;
}

.btnrow {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-primary, .btn-secondary {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  padding: 14px 28px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn-primary {
  background: var(--accent);
  color: #2b1a00;
  box-shadow: 0 4px 0 var(--accent-dark);
}
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-secondary {
  background: transparent;
  color: var(--cream);
  border: 2px solid rgba(242,245,248,0.6);
}

.btn-primary:active, .btn-secondary:active { transform: translateY(2px); }
.btn-primary:hover:not(:disabled), .btn-secondary:hover { filter: brightness(1.08); }

/* ---------------- Panel (game over) ---------------- */
.panel {
  background: var(--panel);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 28px 32px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  color: var(--cream);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}

.panel-title {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 1.7rem;
  margin: 0 0 10px;
}
.panel-title--lose { color: #ff6b6b; }

.big-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 4rem;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 3px 0 rgba(0,0,0,0.35);
  margin: 4px 0 8px;
}

.win-time { font-size: 1rem; margin: 0 0 18px; color: rgba(242,245,248,0.85); }
.new-best { font-weight: 600; color: var(--accent); margin: -6px 0 18px; }

/* ---------------- Fullscreen button ---------------- */
.fullscreen-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 50;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.35);
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.fullscreen-btn svg { width: 20px; height: 20px; }
.fullscreen-icon--exit { display: none; }
.fullscreen-btn.is-fullscreen .fullscreen-icon--enter { display: none; }
.fullscreen-btn.is-fullscreen .fullscreen-icon--exit { display: block; }

/* ---------------- HUD ---------------- */
.hud {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 40;
}

.hud-pill {
  background: rgba(0,0,0,0.35);
  border-radius: 999px;
  padding: 6px 16px;
  display: flex;
  gap: 8px;
  align-items: baseline;
  color: var(--cream);
}

.hud-label { font-size: 0.72rem; opacity: 0.75; }
.hud-value { font-family: var(--font-display); font-weight: 700; font-size: 1rem; }

.hud-controls { margin-left: auto; display: flex; gap: 8px; }

.hud-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.35);
  color: var(--cream);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hud-icon-btn:active { transform: translateY(1px); }

@media (max-width: 640px) {
  .hint { font-size: 0.88rem; }
  .hud { gap: 6px; }
  .hud-pill { padding: 5px 10px; gap: 5px; }
  .hud-pill--best { display: none; }
  .hud-icon-btn { width: 32px; height: 32px; }
  .hud-controls { gap: 6px; }
}
