/* ===== Unicorn Sparkles — kid-friendly responsive layout ===== */

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

:root {
  --sky: #7ec8ff;
  --pink: #ff7eb6;
  --purple: #9b6dff;
  --yellow: #ffd23f;
  --green: #5fd068;
  --ink: #2b2350;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: #1b1340;
  font-family: "Comic Sans MS", "Chalkboard SE", "Baloo", system-ui, sans-serif;
  color: var(--ink);
  /* stop iOS/Android pull-to-refresh, double-tap zoom, text select */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* Game stage keeps a 16:9 box centered and as large as possible */
#game {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#canvas {
  background: var(--sky);
  width: min(100vw, calc(100vh * (16 / 9)));
  height: min(100vh, calc(100vw * (9 / 16)));
  display: block;
  border-radius: 0;
  image-rendering: auto;
}

.hidden { display: none !important; }

/* Player character — DOM emoji overlaid on the canvas (reliable on iOS Safari) */
#playerSprite {
  position: absolute;
  top: 0;
  left: 0;
  line-height: 1;
  pointer-events: none;
  transform-origin: center bottom;
  will-change: transform, left, top;
  z-index: 2;
  /* a soft drop shadow that DOES work on DOM emoji (unlike canvas) */
  filter: drop-shadow(0 4px 4px rgba(0,0,0,0.35));
}

/* ===== Overlays (select + game over) ===== */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.8vmin;
  text-align: center;
  padding: 4vmin;
  overflow-y: auto;
  z-index: 10;
  background: radial-gradient(circle at 50% 25%, rgba(150,110,235,0.45), rgba(40,20,80,0.2)),
              linear-gradient(160deg, #2c1a5e 0%, #4a2b9c 55%, #6a3fb0 100%);
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.25);
}

.title {
  font-size: clamp(28px, 7vmin, 64px);
  letter-spacing: 1px;
}
.subtitle { font-size: clamp(16px, 3.4vmin, 30px); opacity: 0.95; }
.hint {
  font-size: clamp(11px, 2.2vmin, 18px);
  opacity: 0.92;
  max-width: 90%;
  margin-top: 1vmin;
}

/* Character cards */
.char-row { display: flex; gap: 3vmin; flex-wrap: wrap; justify-content: center; }
.char-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5vmin;
  background: rgba(255,255,255,0.9);
  border: 4px solid transparent;
  border-radius: 22px;
  padding: 2.4vmin 3.4vmin;
  cursor: pointer;
  transition: transform .1s, border-color .1s, box-shadow .1s;
  box-shadow: 0 6px 0 rgba(0,0,0,0.18);
  color: var(--ink);
}
.char-card:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,0.18); }
.char-card.selected {
  border-color: var(--yellow);
  box-shadow: 0 6px 0 rgba(0,0,0,0.18), 0 0 0 6px rgba(255,210,63,0.5);
  transform: translateY(-4px) scale(1.04);
}
.char-emoji { font-size: clamp(40px, 11vmin, 96px); line-height: 1; }
.char-name { font-size: clamp(13px, 2.6vmin, 22px); font-weight: bold; }

/* Game mode selector */
.mode-section { display: flex; flex-direction: column; align-items: center; gap: 1.3vmin; }
.mode-label { font-size: clamp(14px, 3vmin, 24px); opacity: 0.95; }
.mode-row, .opt-row { display: flex; gap: 2vmin; flex-wrap: wrap; justify-content: center; }
.mode-btn, .opt-btn {
  font-family: inherit;
  font-size: clamp(13px, 2.6vmin, 22px);
  font-weight: bold;
  color: var(--ink);
  background: rgba(255,255,255,0.85);
  border: 3px solid transparent;
  border-radius: 999px;
  padding: 1vmin 3vmin;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,0.18);
  transition: transform .08s, border-color .1s, box-shadow .08s;
}
.mode-btn:active, .opt-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.18); }
.mode-btn.selected, .opt-btn.selected {
  border-color: var(--yellow);
  background: #fff;
  box-shadow: 0 4px 0 rgba(0,0,0,0.18), 0 0 0 4px rgba(255,210,63,0.55);
}

/* Buttons */
.big-btn {
  font-family: inherit;
  font-size: clamp(20px, 4.2vmin, 36px);
  font-weight: bold;
  color: var(--ink);
  background: var(--yellow);
  border: none;
  border-radius: 999px;
  padding: 1.6vmin 6vmin;
  cursor: pointer;
  box-shadow: 0 6px 0 #c99e1f;
  transition: transform .08s, box-shadow .08s, opacity .2s;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #c99e1f; }
.big-btn:disabled { opacity: 0.45; box-shadow: 0 6px 0 #c99e1f; cursor: default; }

.text-btn {
  font-family: inherit;
  font-size: clamp(13px, 2.6vmin, 20px);
  color: #fff;
  background: transparent;
  border: none;
  text-decoration: underline;
  cursor: pointer;
  opacity: 0.9;
}

/* Subtle engraved signature — carved into the background, no plate */
.credit-plate {
  margin-top: 1vmin;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(10px, 1.9vmin, 14px);
  letter-spacing: 3px;
  text-transform: uppercase;
  /* debossed look: faint light glint below, soft dark cut above */
  color: rgba(255,255,255,0.18);
  text-shadow: 0 -1px 1px rgba(0,0,0,0.35), 0 1px 0 rgba(255,255,255,0.10);
}
.more-link {
  font-size: clamp(13px, 2.4vmin, 17px);
  color: #fff;
  opacity: 0.85;
  text-decoration: none;
  border-bottom: 2px solid var(--yellow);
  padding-bottom: 1px;
}
.more-link:hover, .more-link:focus-visible { opacity: 1; }
.more-link:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; border-radius: 4px; }
.credit-mini {
  font-size: clamp(9px, 1.6vmin, 12px);
  letter-spacing: 2px;
  opacity: 0.85;
}

.result-emoji { font-size: clamp(50px, 14vmin, 120px); animation: bounce 0.8s infinite alternate ease-in-out; }
.big-score { font-size: clamp(22px, 5vmin, 40px); font-weight: bold; }
.best-score { font-size: clamp(15px, 3vmin, 26px); }
#newBest { color: var(--yellow); font-weight: bold; }

@keyframes bounce { from { transform: translateY(0) } to { transform: translateY(-12px) } }

/* ===== HUD ===== */
#hud {
  position: absolute;
  top: max(2vmin, env(safe-area-inset-top));
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 2vmin;
  pointer-events: none;
  z-index: 5;
}
.hud-pill {
  font-family: inherit;
  font-size: clamp(16px, 3.4vmin, 30px);
  font-weight: bold;
  color: var(--ink);
  background: rgba(255,255,255,0.92);
  border-radius: 999px;
  padding: 0.8vmin 2.4vmin;
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
  min-width: 14vmin;
  text-align: center;
}
.icon-btn { pointer-events: auto; border: none; cursor: pointer; min-width: auto; }
