/* Luna's Princess World – shared styles. Phone-first, touch-first. */
:root {
  --pink: #ff8fc8;
  --pink-dark: #e85aa6;
  --lav: #c9a7ff;
  --lav-dark: #9c6cf0;
  --mint: #a8f0dc;
  --sky: #bfe4ff;
  --cream: #fff7fb;
  --gold: #ffd36a;
  --ink: #5b3a6e;
  --shadow: 0 8px 0 rgba(120, 60, 140, .18), 0 14px 30px rgba(120, 60, 140, .18);
  --radius: 28px;
  --font: "Baloo 2", "Fredoka", "Comic Sans MS", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream);
  overflow: hidden;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
}
img { -webkit-user-drag: none; user-select: none; pointer-events: none; }

.scene {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background-size: cover; background-position: center top;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; gap: 10px; flex: 0 0 auto;
}
.topbar h1 {
  margin: 0; font-size: clamp(22px, 6vw, 34px); font-weight: 800;
  color: #fff; text-shadow: 0 3px 0 var(--pink-dark), 0 6px 14px rgba(0,0,0,.18);
  letter-spacing: .5px; flex: 1; text-align: center;
}

/* Big round touch buttons */
.btn {
  appearance: none; border: 0; cursor: pointer;
  min-width: 64px; min-height: 64px; padding: 0 20px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff 0%, #ffe3f3 100%);
  color: var(--ink); font: inherit; font-size: 22px; font-weight: 800;
  box-shadow: 0 6px 0 #e9bfe0, 0 10px 20px rgba(120,60,140,.18);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, box-shadow .08s ease;
  touch-action: manipulation;
}
.btn:active, .btn.pressed { transform: translateY(5px); box-shadow: 0 1px 0 #e9bfe0, 0 4px 10px rgba(120,60,140,.18); }
.btn.round { width: 64px; padding: 0; font-size: 30px; }
.btn.primary { background: linear-gradient(180deg, var(--pink) 0%, var(--pink-dark) 100%); color: #fff; box-shadow: 0 6px 0 #b63f82, 0 10px 20px rgba(120,60,140,.25); }
.btn.primary:active { box-shadow: 0 1px 0 #b63f82, 0 4px 10px rgba(120,60,140,.25); }
.btn.lav { background: linear-gradient(180deg, var(--lav) 0%, var(--lav-dark) 100%); color: #fff; box-shadow: 0 6px 0 #6f45c2, 0 10px 20px rgba(120,60,140,.25); }

/* Stage holds the SVG playfield */
.stage {
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 6px 10px;
  touch-action: none;
}
.stage svg { width: 100%; height: 100%; max-height: 100%; display: block; touch-action: none; }

/* Tool tray at bottom */
.tray {
  flex: 0 0 auto;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(10px);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -8px 30px rgba(120,60,140,.15);
  padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
}
.tabs { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.tab {
  appearance: none; border: 3px solid transparent; cursor: pointer;
  min-height: 54px; min-width: 54px; padding: 0 10px; border-radius: 18px;
  background: #fff; color: var(--ink); font: inherit; font-size: 17px; font-weight: 800;
  box-shadow: 0 4px 0 #e9d7f1; display: inline-flex; align-items: center; gap: 6px;
  touch-action: manipulation;
}
.tab.active { border-color: var(--pink-dark); background: #ffe3f3; transform: translateY(2px); box-shadow: 0 2px 0 #e9bfe0; }

.strip {
  display: flex; gap: 12px; overflow-x: auto; overflow-y: hidden;
  padding: 8px 6px 10px; scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch; touch-action: pan-x;
  scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }

.swatch {
  flex: 0 0 auto; width: 68px; height: 68px; border-radius: 50%;
  border: 5px solid #fff; box-shadow: 0 5px 0 rgba(0,0,0,.08), 0 8px 16px rgba(120,60,140,.18);
  scroll-snap-align: center; cursor: pointer; position: relative;
  display: flex; align-items: center; justify-content: center; font-size: 34px;
  touch-action: manipulation; background: #fff;
}
.swatch.selected { outline: 5px solid var(--pink-dark); outline-offset: 3px; transform: scale(1.08); }
.swatch.item { border-radius: 22px; width: 88px; height: 88px; background: #fff; }
.swatch.item svg { width: 76px; height: 76px; pointer-events: none; }

.sticker-anim { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(.2); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }

/* Celebration overlay */
.celebrate {
  position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(255, 240, 250, .85); backdrop-filter: blur(6px); z-index: 50; gap: 18px; padding: 20px; text-align: center;
}
.celebrate.show { display: flex; }
.celebrate img { width: min(70vw, 360px); animation: bounce 1.2s ease infinite; }
.celebrate h2 { margin: 0; font-size: clamp(30px, 9vw, 54px); color: var(--pink-dark); text-shadow: 0 3px 0 #fff; }
@keyframes bounce { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-18px) rotate(3deg); } }

/* Confetti bits */
.confetti { position: fixed; top: -20px; width: 14px; height: 14px; border-radius: 3px; z-index: 60; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .9; } }

/* Floating tap sparkle */
.tap-spark { position: fixed; pointer-events: none; z-index: 70; font-size: 28px; animation: sparkle .6s ease-out forwards; transform: translate(-50%, -50%); }
@keyframes sparkle { 0% { opacity: 1; transform: translate(-50%,-50%) scale(.4); } 100% { opacity: 0; transform: translate(-50%,-130%) scale(1.4); } }

/* ---------- Home ---------- */
.home { justify-content: flex-start; align-items: center; gap: 8px; overflow-y: auto; touch-action: pan-y; }
.home .logo { width: min(86vw, 520px); margin-top: 8px; filter: drop-shadow(0 8px 10px rgba(120,60,140,.25)); }
.home .mascot { width: min(34vw, 180px); margin-top: -10px; animation: bounce 2.2s ease-in-out infinite; }
.games { display: grid; grid-template-columns: 1fr; gap: 16px; width: min(92vw, 520px); padding: 6px 0 30px; }
@media (min-width: 640px) and (orientation: landscape) { .games { grid-template-columns: repeat(2, 1fr); width: min(94vw, 900px); } }
.game-card {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink);
  background: rgba(255,255,255,.88); border-radius: 30px; padding: 12px;
  box-shadow: var(--shadow); border: 4px solid #fff; transition: transform .1s ease;
  min-height: 120px; touch-action: manipulation;
}
.game-card:active { transform: scale(.97); }
.game-card img { width: 108px; height: 108px; border-radius: 24px; flex: 0 0 auto; object-fit: cover; }
.game-card .label { font-size: clamp(24px, 7vw, 32px); font-weight: 800; line-height: 1.1; }
.game-card .sub { font-size: 16px; opacity: .75; font-weight: 600; }
.game-card .go { margin-left: auto; font-size: 40px; }

/* ---------- Drag & drop ---------- */
.drag-ghost {
  position: fixed; z-index: 80; pointer-events: none;
  width: 96px; height: 96px; border-radius: 28px; border: 5px solid #fff;
  display: flex; align-items: center; justify-content: center; font-size: 48px;
  transform: translate(-50%, -60%) scale(1.15) rotate(-6deg);
  box-shadow: 0 16px 30px rgba(120,60,140,.35);
  transition: opacity .25s;
}
.drag-ghost svg { width: 80px; height: 80px; }
.drag-ghost img { width: 84px; height: 84px; object-fit: contain; }
.drag-ghost.back { transition: left .4s ease, top .4s ease, opacity .4s; opacity: 0; }
.drag-ghost.drop { animation: ghostdrop .25s ease forwards; }
@keyframes ghostdrop { to { transform: translate(-50%, -60%) scale(.2); opacity: 0; } }
.swatch.draggable { touch-action: pan-x; }
.swatch.draggable::after { content: '👆'; position: absolute; bottom: -6px; right: -6px; font-size: 20px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.2)); }

/* Target zones inside the SVG playfield */
.target { fill: rgba(255,255,255,.35); stroke: #ff5fb0; stroke-width: 6; stroke-dasharray: 18 12; opacity: 0; pointer-events: none; transition: opacity .2s; }
.target.show { opacity: 1; animation: pulse 1s ease-in-out infinite, dash 1.2s linear infinite; }
.target.hot { fill: rgba(255,215,106,.55); stroke: #ffb300; }
@keyframes pulse { 0%,100% { stroke-width: 6; } 50% { stroke-width: 12; } }
@keyframes dash { to { stroke-dashoffset: -60; } }
.target-hint { opacity: 0; pointer-events: none; font-size: 54px; transition: opacity .2s; }
.target-hint.show { opacity: 1; animation: point .7s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes point { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-22px); } }

.burst-bit { position: fixed; z-index: 90; pointer-events: none; font-size: 26px; transform: translate(-50%,-50%); animation: burstbit .8s ease-out forwards; }
@keyframes burstbit { 0% { opacity: 1; transform: translate(-50%,-50%) scale(.3); } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.3) rotate(180deg); } }

/* Mini colour row above a strip */
.mini { display: flex; gap: 10px; justify-content: center; flex-wrap: nowrap; overflow-x: auto; padding: 4px 6px; scrollbar-width: none; }
.mini::-webkit-scrollbar { display: none; }
.mini .swatch { width: 46px; height: 46px; border-width: 4px; font-size: 22px; }
.mini .swatch.selected { outline-width: 4px; transform: scale(1.1); }

.tool-hint { font-weight: 800; font-size: 17px; text-align: center; color: var(--ink); opacity: .85; }

/* Single scrolling row of tabs; Done lives in the top bar */
.tabs { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; padding: 2px 4px 6px; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tabs .tab { flex: 0 0 auto; }
.topbar h1 { font-size: clamp(18px, 5vw, 30px); }
.topbar .btn.primary.done { min-height: 56px; font-size: 17px; padding: 0 14px; }

/* ---------- Fill painting ---------- */
.paint-guide { opacity: 0; stroke: #ff5fb0; stroke-width: 5; stroke-dasharray: 10 8; transition: opacity .25s; vector-effect: non-scaling-stroke; }
.paint-guide.show { opacity: 1; animation: dash 1.2s linear infinite, guideglow 1s ease-in-out infinite; }
@keyframes guideglow { 0%,100% { stroke: #ff5fb0; } 50% { stroke: #ffd36a; } }
.paint-finish { animation: finishfade .5s ease forwards; opacity: 0; }
@keyframes finishfade { to { opacity: 1; } }
.meter { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); width: min(60vw, 260px); height: 18px; border-radius: 999px; background: rgba(255,255,255,.85); box-shadow: var(--shadow); overflow: hidden; z-index: 3; opacity: 0; transition: opacity .3s; pointer-events: none; }
.meter.show { opacity: 1; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ff8fc8, #ffd36a, #a8f0dc); border-radius: 999px; transition: width .15s; }

/* Instruction bubble docked in the tray (moved there by common.js) */
.hint.tray-hint { position: static !important; transform: none !important; opacity: 1 !important; transition: none !important;
  max-width: none !important; width: 100%; box-shadow: none !important; background: #fff0f8 !important; border: 3px dashed #ffb3d9;
  border-radius: 18px !important; padding: 6px 12px !important; font-size: 17px !important; font-weight: 800; text-align: center; min-height: 42px;
  display: flex; align-items: center; justify-content: center; color: var(--ink); }
.hint.tray-hint.bump { animation: hintbump .35s ease; }
@keyframes hintbump { 50% { transform: scale(1.04) !important; background: #ffe3f3; } }
