:root {
  --bg: #1a1230;
  --text: #fdf6ff;
  --muted: #c9b8e0;
  --accent: #ff7fb0;
  --accent-dim: #d65f90;
  --panel: rgba(40, 24, 70, 0.92);
  --grid: #4a3470;
}

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

html, body {
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  overflow: hidden;
}

.wrap {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.wrap:fullscreen, .wrap:-webkit-full-screen { width: 100vw; height: 100vh; }

.bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
}
.bar h1 { font-size: 18px; font-weight: 800; letter-spacing: 0.3px; }
.scores { display: flex; align-items: center; gap: 12px; }
.score { font-size: 14px; color: var(--muted); }
.score strong { color: var(--text); margin-left: 2px; }
#hearts { font-size: 14px; letter-spacing: 1px; }

.icon {
  background: transparent;
  border: 1px solid var(--grid);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  width: 34px;
  height: 30px;
  cursor: pointer;
}
.icon:active { background: var(--grid); }

.stage {
  flex: 0 0 auto;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 6px;
}
.stage strong { color: var(--accent); }

.board {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 8px 6px;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid var(--grid);
  background: #88c8ff;
}
#game { display: block; width: 100%; height: 100%; touch-action: none; }

/* Overlays ------------------------------------------------------------------ */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: 12px;
  padding: 18px;
  text-align: center;
  background: var(--panel);
  backdrop-filter: blur(3px);
  overflow-y: auto;
  z-index: 5;
}
.overlay.hidden { display: none; }
#select-title, #overlay-title {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 2px 0 rgba(0,0,0,0.25);
}
#select-sub, #overlay-sub { font-size: 14px; color: var(--muted); max-width: 320px; }

.chars { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.char {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.06);
  border: 2px solid var(--grid);
  border-radius: 14px;
  padding: 10px 14px;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, transform .15s, background .15s;
}
.char:hover { transform: translateY(-2px); }
.char.selected { border-color: var(--accent); background: rgba(255,127,176,0.18); }
.char-canvas { image-rendering: pixelated; }
.char-name { font-size: 16px; font-weight: 800; }
.char-blurb { font-size: 11px; color: var(--muted); }

.princess {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0.95;
}
#alula-preview { image-rendering: pixelated; }

.play {
  background: var(--accent);
  border: none;
  border-radius: 12px;
  color: #3a0d22;
  font-size: 17px;
  font-weight: 800;
  padding: 12px 34px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--accent-dim);
  transition: transform .08s;
}
.play:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-dim); }

/* Touch controls (move pad bottom-left, jump bottom-right) ------------------ */
.touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.touch.hidden { display: none; }
.pad {
  position: absolute;
  left: clamp(12px, 3vw, 28px);
  bottom: clamp(12px, 3vh, 28px);
  display: flex;
  gap: clamp(10px, 2.4vw, 18px);
  pointer-events: none;
}
.tbtn {
  pointer-events: auto;
  width: clamp(60px, 14vmin, 92px);
  height: clamp(60px, 14vmin, 92px);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(40, 24, 70, 0.42);
  color: #fff;
  font-size: clamp(24px, 5.5vmin, 38px);
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  backdrop-filter: blur(2px);
}
.tbtn:active { background: rgba(255, 127, 176, 0.6); }
.tbtn.jump {
  position: absolute;
  right: clamp(12px, 3vw, 28px);
  bottom: clamp(12px, 3vh, 28px);
  width: clamp(74px, 17vmin, 110px);
  height: clamp(74px, 17vmin, 110px);
  background: rgba(127, 200, 255, 0.34);
}

.hint {
  flex: 0 0 auto;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 2px 8px 4px;
}
.foot { flex: 0 0 auto; text-align: center; font-size: 10px; color: var(--muted); padding-bottom: 4px; }

/* Return to games list */
.icon.home { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
