/* Alexia's World v2.
   Everything lives on a 1600x1000 logical stage that platform.js scales to
   the screen (Samsung Galaxy Tab S11+ in landscape is the target). Sizes in
   here are stage pixels, so a 120px button is a 120px button on every device.
   Constraints:
   - nothing tappable is smaller than 120 stage px
   - no text is required to play; words are decoration over pictures
   - motion is soft; nothing flashes or strobes */

:root {
  --sun:   #FFC94A;
  --sky:   #7FD4F5;
  --leaf:  #7BD389;
  --berry: #FF8DA1;
  --grape: #B79CED;
  --ink:   #3B3054;
  --cream: #FFF3DF;
  --paper: #FFFBF3;
  --shadow: 0 8px 0 rgba(59, 48, 84, 0.15);
  --scale: 1;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  background: #FFE9C2;
  color: var(--ink);
  font-family: "Baloo 2", "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif;
  font-weight: 800;
  user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; }
img { -webkit-user-drag: none; }

/* ---------- stage ---------- */

#app { position: fixed; inset: 0; background: #FFE9C2; }
#stage {
  position: absolute; left: 50%; top: 50%;
  width: 1600px; height: 1000px;
  transform: translate(-50%, -50%) scale(var(--scale));
  transform-origin: center;
  background: linear-gradient(180deg, #FFE9C2 0%, var(--cream) 45%, #FFF7E8 100%);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(59,48,84,.06);
}
.scene {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  animation: scene-in 320ms cubic-bezier(.2,.8,.3,1) both;
}
@keyframes scene-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: scale(1); } }

.rotate {
  position: fixed; inset: 0; z-index: 100;
  background: var(--ink); color: #fff;
  display: grid; place-items: center; text-align: center;
  font-size: 28px;
}
.rotate-glyph { font-size: 96px; animation: spin 2.4s ease-in-out infinite; }
@keyframes spin { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(90deg); } }

/* ---------- characters (cutout or placeholder disc) ---------- */

.char {
  position: relative; height: var(--h); width: calc(var(--h) * .62);
  display: grid; place-items: end center;
  flex: 0 0 auto;
}
.char-img { height: var(--h); width: auto; max-width: none; object-fit: contain; filter: drop-shadow(0 10px 0 rgba(59,48,84,.12)); }
.char-fallback {
  width: calc(var(--h) * .62); height: var(--h);
  border-radius: 45% 45% 40% 40% / 35% 35% 50% 50%;
  background: var(--c);
  border: 6px solid rgba(255,255,255,.7);
  box-shadow: var(--shadow);
  display: grid; place-items: center; gap: 0;
  color: var(--ink);
}
.char-glyph { font-size: calc(var(--h) * .38); line-height: 1; }
.char-initial { font-size: calc(var(--h) * .18); line-height: 1; opacity: .6; }
.char.has-art .char-fallback { display: none; }
.bob { animation: bob 2.6s ease-in-out infinite; }
.bob.d1 { animation-delay: -.4s } .bob.d2 { animation-delay: -.8s } .bob.d3 { animation-delay: -1.2s } .bob.d4 { animation-delay: -1.6s }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-14px) rotate(-1.5deg); } }
.cheer { animation: cheer 700ms cubic-bezier(.3,1.6,.4,1) infinite alternate; }
@keyframes cheer { from { transform: translateY(0) scale(1); } to { transform: translateY(-30px) scale(1.06); } }

.face {
  width: var(--s); height: var(--s); border-radius: 50%;
  background: var(--c); border: 5px solid #fff; box-shadow: var(--shadow);
  display: grid; place-items: center; font-size: calc(var(--s) * .55); overflow: hidden; position: relative;
}
.face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* ---------- buttons ---------- */

.big-button {
  border: none; border-radius: 28px;
  min-height: 120px; min-width: 300px; padding: 0 44px;
  font-size: 40px; font-weight: 800;
  background: var(--paper); color: var(--ink);
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform 120ms ease;
}
.big-button.primary { background: var(--berry); color: #fff; }
.big-button:active, .pressed { transform: translateY(6px) scale(.97); }
.chip {
  width: 110px; height: 110px; flex: 0 0 auto;
  border: none; border-radius: 50%;
  background: var(--paper); box-shadow: var(--shadow);
  font-size: 48px; display: grid; place-items: center; cursor: pointer;
  transition: transform 120ms ease;
}
.chip:active { transform: translateY(6px) scale(.96); }

/* ---------- loading ---------- */

.loading { align-items: center; justify-content: center; gap: 28px; }
.loading-cast { display: flex; align-items: flex-end; gap: 36px; height: 320px; }
.loading-title { margin: 0; font-size: 84px; text-shadow: 0 5px 0 rgba(255,255,255,.8); }
.loading-note { font-size: 26px; opacity: .6; }
.rainbow {
  width: 640px; height: 34px; border-radius: 999px;
  background: rgba(255,255,255,.7); box-shadow: inset 0 3px 0 rgba(59,48,84,.08);
  overflow: hidden;
}
.rainbow.small { width: 420px; height: 24px; }
.rainbow-fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--berry), var(--sun), var(--leaf), var(--sky), var(--grape));
  transition: width 200ms linear;
}
.rainbow-fill.grow { animation: grow 1.4s ease-out forwards; }
@keyframes grow { to { width: 100%; } }

/* ---------- welcome ---------- */

.welcome { flex-direction: row; align-items: center; justify-content: space-between; padding: 40px 80px; }
.welcome-art { display: flex; align-items: flex-end; gap: 10px; height: 600px; }
.welcome-panel { display: flex; flex-direction: column; gap: 22px; align-items: stretch; width: 560px; }
.welcome-panel h1 { margin: 0; font-size: 82px; line-height: 1; text-shadow: 0 5px 0 rgba(255,255,255,.8); }
.welcome-sub { margin: 0 0 12px; font-size: 26px; opacity: .7; font-weight: 700; }

/* ---------- who's playing ---------- */

.who { align-items: center; justify-content: center; gap: 30px; }
.who h1 { margin: 0; font-size: 70px; }
.who-row { display: flex; gap: 60px; align-items: flex-end; }
.who-tile {
  border: none; border-radius: 40px; padding: 30px 50px 24px;
  background: var(--paper); box-shadow: var(--shadow); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: transform 120ms ease;
}
.who-tile:active { transform: translateY(8px) scale(.97); }
.who-name { font-size: 46px; }
.who-parent {
  border: none; background: rgba(255,255,255,.55); color: var(--ink);
  border-radius: 999px; padding: 14px 30px; font-size: 24px; font-weight: 700; opacity: .75; cursor: pointer;
}

/* ---------- Play home ---------- */

.home-top {
  flex: 0 0 auto; height: 140px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 40px; gap: 20px;
}
.home-title { font-size: 54px; flex: 1 1 auto; text-align: center; }
.avatar-btn {
  border: none; background: transparent; display: flex; align-items: center; gap: 14px; cursor: pointer; padding: 0;
}
.avatar-name { font-size: 30px; }
.home-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: 0 0 160px; scroll-behavior: smooth;
}
.row-section { margin: 0 0 22px; }
.row-title { margin: 0 40px 12px; font-size: 34px; }
.row-scroll {
  display: flex; gap: 26px; padding: 8px 40px 20px;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x proximity; scroll-padding-inline: 40px; scrollbar-width: none;
}
.row-scroll::-webkit-scrollbar { display: none; }
.row-scroll > * { scroll-snap-align: start; }

.tile {
  --c: var(--grape); --hc: var(--sky);
  position: relative; flex: 0 0 auto;
  width: 300px; height: 300px;
  border-radius: 34px; background: var(--paper);
  box-shadow: var(--shadow); overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column;
  transition: transform 120ms ease;
}
.tile.pressed { transform: translateY(6px) scale(.97); }
.tile-big { width: 440px; height: 380px; }
.tile-art {
  flex: 1 1 auto; position: relative; overflow: hidden;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 70%, #fff), var(--c));
  display: flex; align-items: flex-end; justify-content: flex-end; padding: 0 16px;
}
.tile-glyph { position: absolute; left: 22px; top: 18px; font-size: 92px; line-height: 1; filter: drop-shadow(0 6px 0 rgba(59,48,84,.15)); }
.tile-big .tile-glyph { font-size: 120px; }
.tile-host { margin-bottom: -6px; }
.tile-label { flex: 0 0 auto; padding: 12px 20px 16px; display: flex; flex-direction: column; line-height: 1.1; }
.tile-name { font-size: 30px; }
.tile-big .tile-name { font-size: 36px; }
.tile-skin { font-size: 22px; opacity: .65; font-weight: 700; }
.tile-new {
  position: absolute; top: 16px; right: 16px;
  background: var(--berry); color: #fff; font-size: 20px; letter-spacing: .08em;
  padding: 6px 14px; border-radius: 999px; box-shadow: 0 4px 0 rgba(59,48,84,.15);
}

.chips { display: flex; gap: 16px; padding: 4px 40px 12px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-topic {
  --c: var(--grape);
  flex: 0 0 auto; border: 4px solid var(--c); background: var(--paper);
  border-radius: 999px; min-height: 84px; padding: 0 30px; font-size: 28px; cursor: pointer;
  transition: transform 120ms ease;
}
.chip-topic.on { background: var(--c); color: #fff; }
.chip-topic:active { transform: scale(.96); }

.world {
  flex: 0 0 auto; width: 200px; display: flex; flex-direction: column; align-items: center; gap: 10px; cursor: pointer;
  transition: transform 120ms ease;
}
.world.pressed { transform: scale(.94); }
.world-glyph {
  width: 170px; height: 170px; border-radius: 50%; display: grid; place-items: center;
  font-size: 84px; background: var(--paper); box-shadow: var(--shadow);
}
.world-name { font-size: 26px; }

.star-meter { display: flex; gap: 6px; background: rgba(255,255,255,.6); border-radius: 999px; padding: 10px 20px; }
.star { font-size: 40px; filter: grayscale(1); opacity: .35; transition: transform 300ms cubic-bezier(.3,1.6,.4,1), filter 300ms, opacity 300ms; }
.star.lit { filter: none; opacity: 1; transform: scale(1.12); }

.home-right { display: flex; align-items: center; gap: 16px; }
.album-btn {
  position: absolute; bottom: 28px; right: 32px; border: none; cursor: pointer;
  width: 150px; height: 150px; font-size: 80px;
  border-radius: 50%; background: var(--paper); box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.album-btn.has-pack { animation: bounce 900ms cubic-bezier(.3,1.6,.4,1) infinite; background: var(--sun); }
.gear {
  width: 72px; height: 72px; border: none; border-radius: 50%; cursor: pointer;
  background: rgba(255,255,255,.6); font-size: 34px; opacity: .6; display: grid; place-items: center;
}
.badge {
  position: absolute; top: -6px; right: -6px;
  min-width: 52px; height: 52px; padding: 0 12px; border-radius: 999px;
  background: var(--berry); color: #fff; font-size: 30px; display: grid; place-items: center;
  box-shadow: 0 4px 0 rgba(59,48,84,.2);
}
@keyframes bounce { 0%, 100% { transform: scale(1); } 45% { transform: scale(1.14) rotate(-4deg); } }

/* ---------- game frame ---------- */

.game { --hc: var(--sky); }
.interstitial {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 60px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--hc) 45%, #fff), var(--cream));
}
.inter-text { display: flex; flex-direction: column; align-items: flex-start; }
.inter-glyph { font-size: 140px; line-height: 1; }
.inter-text h1 { margin: 10px 0 0; font-size: 84px; line-height: 1; }
.inter-text p { margin: 8px 0 30px; font-size: 40px; opacity: .7; }
.game-frame { position: absolute; inset: 0; display: flex; flex-direction: column; }
.topbar {
  flex: 0 0 auto; height: 140px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 40px;
}
.game-title { flex: 1 1 auto; text-align: center; font-size: 46px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; padding: 0 40px 20px; }
.host-corner { position: absolute; left: 30px; bottom: 0; pointer-events: none; }

/* placeholder activity */
.ph-prompt { margin: 0 0 20px; font-size: 54px; }
.ph-grid { display: flex; gap: 30px; align-items: flex-end; justify-content: center; }
.ph-card {
  border: none; border-radius: 36px; background: var(--paper); box-shadow: var(--shadow);
  padding: 30px 26px 18px; cursor: pointer; transition: transform 120ms ease;
}
.ph-card:active { transform: translateY(6px) scale(.97); }
.ph-card.found { background: var(--leaf); }
.ph-note { margin: 26px 0 0; font-size: 22px; opacity: .55; font-weight: 700; max-width: 900px; text-align: center; }
.wobble { animation: wobble 420ms ease; }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } 75% { transform: rotate(-3deg); } }

/* ---------- celebration ---------- */

.celebrate {
  position: absolute; inset: 0; z-index: 30;
  background: rgba(255, 243, 223, .94);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
  animation: scene-in 260ms ease both;
}
.celebrate-text { text-align: center; }
.celebrate-text h1 { margin: 0; font-size: 84px; }
.celebrate-text p { margin: 6px 0 0; font-size: 34px; opacity: .75; }
.star-pop { font-size: 140px; line-height: 1; animation: pop 600ms cubic-bezier(.3,1.6,.4,1) both; }
@keyframes pop { from { transform: scale(0) rotate(-30deg); } to { transform: scale(1) rotate(0); } }
.win-buttons { display: flex; gap: 30px; flex-wrap: wrap; justify-content: center; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span {
  position: absolute; top: -60px; left: calc(var(--i) * 3.6%);
  font-size: 44px; animation: fall 2.8s linear infinite; animation-delay: calc(var(--i) * -.13s);
}
@keyframes fall { to { transform: translateY(1100px) rotate(360deg); } }

/* ---------- album ---------- */

.album-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 40px 60px; }
.album-body h2 { font-size: 34px; margin: 20px 0 12px; }
.album-note { font-size: 26px; opacity: .7; }
.pack-row { display: flex; align-items: center; gap: 30px; font-size: 30px; }
.pack {
  position: relative; width: 170px; height: 170px; border-radius: 34px;
  background: var(--sun); box-shadow: var(--shadow); font-size: 90px;
  display: grid; place-items: center; cursor: pointer; animation: bounce 900ms cubic-bezier(.3,1.6,.4,1) infinite;
}
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, 150px); gap: 18px; }
.sticker {
  width: 150px; height: 150px; border-radius: 26px; background: var(--paper); box-shadow: var(--shadow);
  display: grid; place-items: center; overflow: hidden;
}
.sticker .char { height: 120px; }
.sticker.dim { opacity: .28; filter: grayscale(1); }
.sticker-glyph { font-size: 80px; }
.drawn { display: flex; gap: 40px; }
.drawn-item { display: flex; flex-direction: column; align-items: center; gap: 12px; animation: pop 600ms cubic-bezier(.3,1.6,.4,1) both; animation-delay: calc(var(--i) * .35s); }
.drawn-item .sticker { width: 260px; height: 260px; }
.drawn-item .sticker .char { height: 220px; }
.drawn-item .sticker-glyph { font-size: 150px; }
.drawn-name { font-size: 28px; }

/* ---------- veil / sheet / gate ---------- */

.veil {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(43, 36, 81, .72);
  display: grid; place-items: center; padding: 20px;
  animation: scene-in 200ms ease both; overflow-y: auto;
}
.sheet {
  background: var(--paper); border-radius: 36px; padding: 36px;
  width: 640px; max-height: 940px; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  display: flex; flex-direction: column; gap: 16px; font-weight: 700;
}
.sheet h2 { margin: 0; font-size: 36px; }
.sheet p { margin: 0; font-size: 22px; line-height: 1.4; opacity: .8; }
.sheet button {
  font-weight: 800; border: none; border-radius: 18px;
  padding: 14px 24px; min-height: 64px; font-size: 24px;
  background: var(--grape); color: #fff; cursor: pointer;
}
.sheet button.subtle { background: #E7E1F3; color: var(--ink); }
.gate-display { font-size: 64px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.gate-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.gate-key { background: var(--sky) !important; color: var(--ink) !important; font-size: 34px !important; min-height: 84px !important; }
.gate-key.ghost { background: #E7E1F3 !important; }
.gate-key.ok { background: var(--leaf) !important; }
.gate-hint { font-size: 20px; }

/* ---------- parent area (ported from v1) ---------- */

.dash { font-weight: 700; }
.dash-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 40px 60px; }
.dash-h1 { font-size: 40px; margin: 30px 0 0; }
.dash-label { font-size: 18px; letter-spacing: .06em; text-transform: uppercase; opacity: .6; margin: 14px 0 6px; }
.dash-input { font: inherit; font-size: 22px; padding: 10px 16px; border-radius: 14px; border: 2px solid #E7E1F3; background: #fff; min-height: 56px; }
.dash-filters { display: flex; flex-wrap: wrap; gap: 12px 20px; padding: 6px 0 14px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; background: var(--paper); padding: 6px; border-radius: 999px; box-shadow: var(--shadow); }
.seg button {
  border: none; background: transparent; color: var(--ink);
  font: inherit; font-size: 20px; font-weight: 700;
  padding: 10px 18px; min-height: 48px; border-radius: 999px; cursor: pointer; opacity: .65;
}
.seg button.on { background: var(--grape); color: #fff; opacity: 1; }
.dash-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.tile-stat { background: var(--paper); border-radius: 22px; padding: 18px 20px; box-shadow: var(--shadow); }
.stat-value { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 16px; letter-spacing: .08em; text-transform: uppercase; opacity: .6; margin-top: 2px; }
.stat-note  { font-size: 16px; opacity: .7; margin-top: 6px; }
.dash-section { margin-top: 26px; }
.dash-section h2 { margin: 0 0 10px; font-size: 28px; }
.dash-note { font-size: 18px; line-height: 1.5; opacity: .75; margin: 10px 0 0; max-width: 80ch; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding: 10px 12px 28px; background: var(--paper); border-radius: 22px; box-shadow: var(--shadow); position: relative; }
.bar-col { flex: 1 1 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; min-width: 0; }
.bar { width: 70%; background: var(--grape); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bar-label { position: absolute; bottom: -22px; font-size: 13px; opacity: .55; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; background: var(--paper); border-radius: 22px; box-shadow: var(--shadow); }
.dash-table { width: 100%; border-collapse: collapse; font-size: 18px; font-variant-numeric: tabular-nums; }
.dash-table th, .dash-table td { text-align: left; padding: 12px 14px; white-space: nowrap; }
.dash-table th { font-size: 14px; letter-spacing: .08em; text-transform: uppercase; opacity: .55; border-bottom: 2px solid #EFE9F7; }
.dash-table tbody tr + tr td { border-top: 1px solid #F1ECF8; }
.trend.faster { color: #2E9E5B; } .trend.slower { color: #D9772A; } .trend.steady { opacity: .6; }
.letter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.letter-cell { --h: 130; background: hsl(var(--h) 60% 88%); border: 2px solid hsl(var(--h) 55% 70%); border-radius: 16px; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.letter-cell.none { background: #F4F0F9; border-color: #E7E1F3; opacity: .55; }
.letter-cell .lc { font-size: 28px; font-weight: 800; }
.letter-cell .ln { font-size: 12px; opacity: .7; white-space: nowrap; }
.dash-empty { text-align: center; padding: 30px 20px; opacity: .8; font-size: 22px; }
.dash-empty p { max-width: 46ch; margin: 0 auto; line-height: 1.5; }
.win-glyph { font-size: 120px; }
.dash .row { display: flex; gap: 12px; align-items: center; }
.dash .row.wrap { flex-wrap: wrap; }
.dash button:not(.chip):not(.seg button) {
  font: inherit; font-weight: 800; border: none; border-radius: 16px;
  padding: 12px 20px; min-height: 56px; background: var(--grape); color: #fff; cursor: pointer; font-size: 20px;
}
.dash button.subtle { background: #E7E1F3; color: var(--ink); }

/* ---------- sparkle ---------- */

.spark { position: fixed; pointer-events: none; font-size: 32px; z-index: 60; animation: spark 1s ease-out forwards; }
@keyframes spark { 0% { transform: translate(0,0) scale(.4); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(1.3); opacity: 0; } }
.dragging { z-index: 20; transition: none !important; filter: drop-shadow(0 14px 12px rgba(59,48,84,.3)); }
.springing { transition: transform 260ms cubic-bezier(.3,1.4,.4,1) !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
