/* Alanna's Typing World
   Layout: one full-window app; island scene in the middle, game cards docked below,
   and each game is a full-screen stage with a big word display and the keyboard helper. */
:root {
  --ink: #3a2a4a;
  --ink-soft: #6b5a7d;
  --paper: #fffaf0;
  --paper-2: #fff1d6;
  --sky: #6fcdfb;
  --sea: #1d86bd;
  --sea-light: #3cc6e8;
  --sand: #fbe4ac;
  --coral: #ff6f91;
  --coral-dark: #e04a72;
  --sun: #ffd23f;
  --grape: #9b6bff;
  --mint: #3ccf7a;
  --good: #2bb673;
  --warn: #ff9f1c;
  --bad: #ff5a5f;
  --radius: 18px;
  --shadow: 0 6px 0 rgba(58, 42, 74, .25);
  --font: 'Baloo 2', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 18px;
  color: var(--ink);
  background: var(--sea);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
#app { height: 100%; display: flex; flex-direction: column; }
button { font-family: inherit; color: inherit; cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 4px solid var(--sun); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.1; text-wrap: balance; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  border: 3px solid var(--ink);
  background: var(--coral);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  padding: 10px 22px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  transition: transform .08s, box-shadow .08s;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .15);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(58, 42, 74, .25); }
.btn:disabled { background: #cfc6d6; color: #fff; cursor: not-allowed; transform: none; }
.btn.ghost { background: #fff; color: var(--ink); text-shadow: none; }
.btn.small { font-size: 16px; padding: 6px 14px; }
.btn.huge { font-size: 34px; padding: 14px 48px; }
.btn.danger-btn { background: var(--bad); }
.icon-btn { border: 3px solid var(--ink); background: #fff; border-radius: 50%; width: 46px; height: 46px; font-size: 22px; box-shadow: var(--shadow); display: inline-grid; place-items: center; padding: 0; flex: none; }
.chip { border: 3px solid var(--ink); background: #fff; border-radius: 999px; padding: 6px 16px; font-weight: 700; font-size: 18px; }
.chip.on { background: var(--sun); }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

/* ---------- money ---------- */
.pearl {
  display: inline-block; width: .95em; height: .95em; border-radius: 50%; vertical-align: -0.12em;
  background: radial-gradient(circle at 35% 30%, #fff 0 18%, #f3eefc 35%, #d9cdef 70%, #b8a8d8 100%);
  border: 2px solid var(--ink);
}
.cost-chip { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 1px 10px; font-weight: 800; }
.cost-chip + .cost-chip { margin-left: 4px; }
.cost-chip.big { font-size: 28px; padding: 4px 16px; }
.cost-chip.free { background: var(--mint); color: #fff; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px));
  background: linear-gradient(#fff6e0, #ffe9bd);
  border-bottom: 4px solid var(--ink);
  position: relative; z-index: 5;
}
.logo { font-size: 28px; font-weight: 800; color: var(--grape); letter-spacing: .5px; white-space: nowrap; }
.logo span { color: var(--coral); }
.money { display: flex; gap: 8px; margin-left: auto; }
.money-chip { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 2px 14px; font-size: 22px; font-weight: 800; box-shadow: 0 3px 0 rgba(58, 42, 74, .2); }
.money-chip b { font-variant-numeric: tabular-nums; min-width: 1.2em; text-align: center; }
.lvl { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px 6px; border-radius: 14px; font: inherit; }
.lvl:hover { background: rgba(155, 107, 255, .15); }
.lvl-badge { background: var(--grape); color: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 0 10px; font-weight: 800; box-shadow: 0 3px 0 rgba(58, 42, 74, .25); }
.lvl-badge small { font-size: .7em; opacity: .85; margin-left: 1px; }
/* the level ladder */
.levels-modal { text-align: center; }
.ladder { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; max-height: min(58vh, 520px); overflow: auto; padding: 4px; }
.rung { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; text-align: left; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 6px 12px; box-shadow: 0 3px 0 rgba(58, 42, 74, .2); }
.rung:not([disabled]):hover { transform: translateY(-2px); background: #fff8e6; }
.rung-n { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--grape); color: #fff; font-weight: 800; font-size: 20px; border: 3px solid var(--ink); }
.rung-text { display: flex; flex-direction: column; line-height: 1.2; }
.rung-text span { font-size: 14px; color: var(--ink-soft); }
.rung-text i { font-style: normal; font-weight: 800; color: var(--ink); background: #fff4c2; border-radius: 6px; padding: 0 5px; white-space: nowrap; }
.rung-note { font-size: 13px; font-weight: 800; color: var(--ink-soft); white-space: nowrap; }
.rung.now { background: var(--sun); }
.rung.now .rung-note { color: var(--ink); }
.rung.next, .rung.later { background: #eee9f2; box-shadow: none; }
.rung.next .rung-n, .rung.later .rung-n { background: #b9adc7; }
.rung.later { opacity: .6; }
.level-tip { background: #fff4c2; border: 3px dashed var(--ink); border-radius: 16px; padding: 8px 14px; margin: 8px auto 0; max-width: 520px; }
.level-tip p { margin: 0 0 6px; font-weight: 700; }
.lvl-name { font-weight: 700; white-space: nowrap; }
.xp-bar { width: 110px; height: 14px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.xp-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--sun)); }

/* ---------- island hub ---------- */
.hub { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.scene-wrap { flex: 1; min-height: 0; position: relative; background: #6fcdfb; }
#scene { width: 100%; height: 100%; display: block; }
.progress-pill {
  position: absolute; top: 12px; left: max(16px, env(safe-area-inset-left, 0px));
  display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, .92);
  border: 3px solid var(--ink); border-radius: 999px; padding: 4px 16px; font-weight: 800; box-shadow: var(--shadow);
}
.back-chip { position: absolute; top: 66px; left: max(16px, env(safe-area-inset-left, 0px)); border: 3px solid var(--ink); border-radius: 999px; background: var(--paper);
  padding: 2px 14px; font: inherit; font-weight: 800; font-size: 16px; color: var(--ink); box-shadow: 0 3px 0 rgba(58, 42, 74, .25); cursor: pointer; }
.back-chip:hover { transform: translateY(-2px); }
.back-chip[hidden] { display: none; }
.pill-bar { width: 120px; height: 14px; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; background: #eee; }
.pill-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--coral), var(--sun)); }
.dock {
  display: flex; gap: 16px; align-items: stretch; justify-content: center; flex-wrap: wrap;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: linear-gradient(#c98a4b, #a86b34);
  border-top: 4px solid var(--ink);
}
.games, .places { display: flex; gap: 12px; }
.games.pulse .game-card { animation: pulse .5s 3; }
.game-card {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left;
  border: 3px solid var(--ink); border-radius: var(--radius); padding: 8px 18px; min-width: 200px; box-shadow: var(--shadow); color: #fff;
  transition: transform .1s;
}
.game-card:hover { transform: translateY(-3px) rotate(-1deg); }
.gc-emoji { grid-row: span 2; font-size: 40px; }
.gc-name { font-size: 22px; font-weight: 800; text-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.gc-sub { font-size: 15px; font-weight: 600; opacity: .95; }
.g-rhythm { background: linear-gradient(135deg, #9b6bff, #6b4bd8); }
.g-bakery { background: linear-gradient(135deg, #ff7eb6, #ff5a8a); }
.g-racer { background: linear-gradient(135deg, #3fa9f5, #1d7fd0); }
.place-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--paper); border: 3px solid var(--ink); border-radius: var(--radius); padding: 4px 14px; font-weight: 800; font-size: 16px; box-shadow: var(--shadow); min-width: 96px; }
.place-btn span { font-size: 30px; line-height: 1.1; }
.place-btn:hover { background: #fff; transform: translateY(-2px); }

/* area switch arrow */
.area-nav {
  position: absolute; bottom: 14px; z-index: 2;
  display: flex; align-items: center; gap: 8px; border: 4px solid var(--ink); border-radius: 999px;
  background: var(--sun); padding: 8px 18px; font-weight: 800; font-size: 20px; box-shadow: var(--shadow);
  animation: nudge 1.8s ease-in-out infinite;
}
.area-nav b { font-size: 26px; }
.area-nav.to-right { right: max(12px, env(safe-area-inset-right, 0px)); }
.area-nav.to-left { left: max(12px, env(safe-area-inset-left, 0px)); }
.area-nav:hover { background: #fff; }
.scene-wrap.slide-in-r #scene { animation: slideInR .45s ease-out; }
.scene-wrap.slide-in-l #scene { animation: slideInL .45s ease-out; }
#ball { transition: transform .85s cubic-bezier(.2, .8, .3, 1); cursor: pointer; }
#ball.rolling .ball-spin { animation: spinball .85s linear; }
.ball-spin { transform-box: fill-box; transform-origin: center; }
.net-shake { animation: netshake .5s ease-in-out 2; transform-box: fill-box; transform-origin: center; }

/* Play a Game card + arcade menu */
.play-card {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center; text-align: left;
  border: 3px solid var(--ink); border-radius: var(--radius); padding: 8px 22px; box-shadow: var(--shadow); color: #fff; min-width: 300px;
  background: linear-gradient(135deg, #ff5a8a, #9b6bff 55%, #3fa9f5);
}
.play-card:hover { transform: translateY(-3px) rotate(-1deg); }
.pc-emojis { grid-row: span 2; display: grid; grid-template-columns: repeat(5, 1fr); font-size: 20px; line-height: 1.15; background: rgba(255, 255, 255, .25); border-radius: 12px; padding: 4px 6px; }
.pc-emojis span { animation: bob 2.4s ease-in-out infinite; }
.pc-emojis span:nth-child(2n) { animation-delay: -1.2s; }
.pc-name { font-size: 28px; font-weight: 800; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.pc-sub { font-size: 16px; font-weight: 700; opacity: .95; }
.arcade-modal { width: min(980px, 100%); }
.arcade { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-top: 10px; }
.arcade-sec + .arcade-sec { margin-top: 22px; }
.arcade-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 6px 4px 0; font-size: 24px; color: var(--grape); }
.arcade-head small { font-size: 15px; font-weight: 700; color: var(--ink-soft); }
.arcade-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 10px 12px;
  border: 4px solid var(--ink); border-radius: 22px; color: #fff; box-shadow: var(--shadow);
  background: linear-gradient(160deg, color-mix(in srgb, var(--gc) 80%, #fff), var(--gc));
  transition: transform .1s;
}
.arcade-card:hover { transform: translateY(-4px) rotate(-1.5deg); }
.arcade-card:nth-child(2n):hover { transform: translateY(-4px) rotate(1.5deg); }
.ac-emoji { font-size: 54px; line-height: 1.1; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .2)); }
.ac-name { font-size: 21px; font-weight: 800; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); line-height: 1.1; }
.ac-sub { font-size: 14px; font-weight: 700; opacity: .95; }
.new-tag { position: absolute; top: -10px; right: -8px; background: var(--sun); color: var(--ink); border: 3px solid var(--ink); border-radius: 999px; padding: 0 8px; font-size: 13px; font-weight: 800; transform: rotate(8deg); animation: badge 1.4s ease-in-out infinite; }

/* world map: a big world that drags and scrolls */
.map-screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.map-wrap { flex: 1; min-height: 0; background: #3cb4e0; position: relative; overflow: hidden; touch-action: none; cursor: grab; }
.map-wrap.dragging { cursor: grabbing; }
#worldmap { width: 100%; height: 100%; display: block; user-select: none; }
.map-place.open, .map-place.soon { cursor: pointer; }
.map-mini { transition: transform .2s ease-out; transform-box: fill-box; transform-origin: 50% 100%; }
.map-place:hover .map-mini { transform: translateY(-8px) scale(1.04); }
.map-place.picked .map-mini { animation: picked .35s ease-out; }
.map-hero { pointer-events: none; }
.map-zoom { position: absolute; right: 12px; top: 12px; z-index: 2; display: flex; flex-direction: column; gap: 8px; }
.map-zoom .icon-btn { font-size: 26px; font-weight: 800; line-height: 1; }
.map-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 2; margin: 0; background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 4px 16px; font-weight: 800; box-shadow: var(--shadow); pointer-events: none; animation: maphint 1.8s ease-in-out infinite; }
.map-dock { justify-content: space-between; align-items: center; }
.map-count { font-weight: 800; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.map-back { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.place-chip { border: 3px solid var(--ink); border-radius: 999px; background: var(--paper); padding: 4px 12px; font: inherit; font-weight: 800; font-size: 16px; color: var(--ink); box-shadow: 0 3px 0 rgba(58, 42, 74, .25); cursor: pointer; }
.place-chip:hover { transform: translateY(-2px); }
.map-home { pointer-events: none; }
.map-btn { background: #fff4c2; }
@keyframes maphint { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -6px); } }
@keyframes picked { 0% { transform: scale(1); } 40% { transform: translateY(-14px) scale(1.12); } 100% { transform: scale(1); } }
.map-preview { border: 4px solid var(--ink); border-radius: 16px; overflow: hidden; margin: 10px auto; max-width: 560px; aspect-ratio: 16 / 9; }
.map-preview svg { width: 100%; height: 100%; display: block; }

/* scene bits */
.fixable { cursor: pointer; }
.fixable:hover { filter: brightness(1.08) drop-shadow(0 0 10px #fff8b0); }
.fix-badge { transform-box: fill-box; transform-origin: center; }
/* the ones she can afford now bounce, glow and have a gold price tag; the rest wait quietly */
.badge-spot.can .fix-badge { animation: badge 1.6s ease-in-out infinite; filter: drop-shadow(0 0 6px #ffe14d) drop-shadow(0 0 3px #fff3a0); }
.badge-spot.can .fix-price rect { fill: #fff3a0; }
.badge-spot:not(.can) .fix-badge, .badge-spot:not(.can) .fix-price { opacity: .82; }
.decor { cursor: grab; }
.decor.dragging { cursor: grabbing; filter: drop-shadow(0 10px 6px rgba(0, 0, 0, .3)); }
.bob { animation: bob 3s ease-in-out infinite; transform-box: fill-box; transform-origin: bottom center; }
#hero { transition: transform 1.2s ease-in-out; cursor: pointer; }
#hero.walking .hero-bob { animation: walkbob .3s ease-in-out infinite; }
.friend { transition: transform 2.2s ease-in-out; cursor: pointer; }
.friend > g { transition: transform .2s; transform-box: fill-box; transform-origin: center; }
.hop { animation: hop 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: bottom center; }
.hop.jump { animation: jumpy .6s ease-out 2; }
.cloud.c1 { animation: drift 60s linear infinite; }
.cloud.c2 { animation: drift 80s linear infinite reverse; }
.sun { animation: sunpulse 4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.waves { animation: wave 3s linear infinite; }
.foam { animation: foam 4s ease-in-out infinite; }
.palm { animation: palm 5s ease-in-out infinite; transform-box: fill-box; transform-origin: bottom center; }
.palm.p2 { animation-delay: -2s; }
.twinkle { animation: twinkle 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.glow { animation: twinkle 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.far-island { cursor: pointer; }
.comic { font-family: var(--font); font-weight: 800; font-size: 76px; fill: var(--sun); stroke: var(--ink); stroke-width: 6px; paint-order: stroke; animation: comic 1.4s ease-out forwards; transform-box: fill-box; transform-origin: center; }
.poof { animation: poof .8s ease-out forwards; transform-box: fill-box; transform-origin: center; }
.splat { animation: splat .9s ease-out forwards; transform-box: fill-box; transform-origin: center; }
.dust { animation: dust 1s ease-out forwards; transform-box: fill-box; transform-origin: center; }
.spark { animation: spark 1.2s ease-out forwards; opacity: 0; transform-box: fill-box; transform-origin: center; }

/* ---------- modals ---------- */
.modal-wrap {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(30, 40, 80, .45); padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px));
  opacity: 0; transition: opacity .2s;
}
.modal-wrap.in { opacity: 1; }
.modal {
  position: relative; background: var(--paper); border: 4px solid var(--ink); border-radius: 26px; box-shadow: 0 10px 0 rgba(58, 42, 74, .3);
  width: min(760px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 24px 28px; text-align: center;
  transform: scale(.9) translateY(20px); transition: transform .25s cubic-bezier(.2, 1.4, .4, 1);
}
.modal-wrap.in .modal { transform: none; }
.modal h2 { font-size: 34px; color: var(--grape); margin-bottom: 8px; }
.modal h3 { font-size: 22px; margin: 14px 0 6px; }
.modal p { margin: 6px auto; max-width: 56ch; line-height: 1.4; }
.modal .sub { color: var(--ink-soft); }
.big-p { font-size: 22px; }
.small-p { font-size: 15px; color: var(--ink-soft); }
.hint { color: var(--coral-dark); font-weight: 700; }
.modal-x { position: absolute; top: 10px; right: 12px; border: 3px solid var(--ink); background: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; font-weight: 800; }
.intro-art { font-size: 90px; line-height: 1; }
.sell-emoji { font-size: 96px; line-height: 1.1; }

/* fix card */
.fix-pics { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 10px 0; }
.fix-pics .preview { width: 44%; max-height: 200px; background: linear-gradient(#c9f0ff, #e7f8d8 70%); border: 3px solid var(--ink); border-radius: 16px; padding: 6px; }
.fix-pics.single .preview { width: 70%; max-height: 260px; }
.fix-pics .arrow { font-size: 40px; font-weight: 800; color: var(--coral); }
.step-verb { color: var(--coral-dark); font-size: 26px !important; }
.swatches { display: flex; gap: 10px; justify-content: center; margin: 10px 0; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--ink); background: var(--c); }
.swatch.on { box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--ink); transform: scale(1.1); }
.buy-row { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 12px; font-size: 22px; }

/* results + level up */
.results-title { font-size: 40px !important; }
.results { list-style: none; padding: 0; margin: 12px 0; font-size: 20px; display: grid; gap: 6px; }
.earned { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 22px; font-weight: 700; margin: 10px 0; }
.stars { font-size: 56px; display: flex; justify-content: center; gap: 10px; }
.stars span { filter: grayscale(1) opacity(.3); }
.stars span.on { filter: none; animation: starpop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.levelup-burst { font-size: 100px; animation: spin 2s ease-in-out infinite; display: inline-block; }

/* closet */
.closet { display: grid; grid-template-columns: 240px 1fr; gap: 18px; text-align: left; margin-top: 8px; }
.closet-me { background: linear-gradient(#c9f0ff, #fff1d6); border: 3px solid var(--ink); border-radius: 20px; display: grid; place-items: center; padding: 10px; }
.avatar-svg.big { width: 200px; height: 320px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tab { border: 3px solid var(--ink); background: #fff; border-radius: 999px; padding: 2px 12px; font-weight: 700; font-size: 16px; }
.tab.on { background: var(--sun); }
.closet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; max-height: 360px; overflow: auto; padding: 4px; }
.closet-item { border: 3px solid var(--ink); background: #fff; border-radius: 16px; padding: 4px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 14px; font-weight: 700; }
.closet-item.on { background: #e9fff1; box-shadow: 0 0 0 3px var(--mint); }
.closet-item.locked .avatar-svg { opacity: .75; }
.avatar-svg.mini { width: 70px; height: 110px; }
.ci-name { line-height: 1.1; text-align: center; }
.ci-tag { background: var(--mint); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 13px; }
.ci-cost .cost-chip { font-size: 13px; padding: 0 6px; }

/* trading post */
.trading .crab { font-size: 110px; line-height: 1; display: inline-block; }
.trading .crab.snip { animation: snip .5s ease-in-out; }
.trading .bubble { background: #fff; border: 3px solid var(--ink); border-radius: 20px; padding: 10px 16px; display: inline-block; max-width: 520px; font-size: 19px; position: relative; margin-bottom: 14px; }
.trades { display: grid; gap: 12px; }
.trade-row { display: grid; grid-template-columns: auto auto auto auto 1fr; align-items: center; gap: 14px; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 10px 16px; font-size: 22px; }
.trade-row .arrow { font-size: 28px; color: var(--coral); font-weight: 800; }
.trade-have { color: var(--ink-soft); font-size: 16px; text-align: right; }
.trade-head { margin: 4px 0 -4px; font-weight: 800; color: var(--ink-soft); font-size: 17px; }
.trade-row.down { background: #f6f2ff; }

/* island shop */
.decor-shop h3 { text-align: left; }
.decor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.decor-item { border: 3px solid var(--ink); background: #fff; border-radius: 16px; padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 700; font-size: 14px; }
.decor-item:hover { transform: translateY(-2px); }
.decor-item.locked { opacity: .6; }
.di-emoji { font-size: 44px; line-height: 1.1; }
.di-cost .cost-chip { font-size: 13px; padding: 0 6px; }

/* settings */
.settings { text-align: left; display: grid; gap: 10px; max-width: 520px; margin: 0 auto; }
.set-row { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 600; }
.set-row input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--coral); }
.set-row select, .set-row input[type=range] { font-family: inherit; font-size: 16px; flex: 1; }
.danger { margin-top: 12px; display: grid; gap: 8px; }
.danger-row { justify-content: flex-start; margin-top: 0; }
/* grown-ups only: what it does, a sum to answer, then the button (Settings and safety copies) */
.gu { border: 3px solid var(--bad); border-radius: 14px; padding: 10px 14px; background: #fff5f5; display: grid; gap: 8px; text-align: left; }
.gu[hidden] { display: none; }
.gu-warn { margin: 0; font-weight: 700; }
.gu-q { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 700; }
.gu-answer { font: inherit; font-size: 18px; font-weight: 800; width: 4.5em; padding: 2px 10px; border: 3px solid var(--ink); border-radius: 10px; user-select: text; }
.gu-buttons { justify-content: flex-start; margin-top: 0; }
.gu .btn.danger-btn:disabled { background: #cfc6d6; box-shadow: none; }
.gu-oops { margin: 0; }
.copies { display: grid; gap: 8px; text-align: left; margin: 10px 0; }
.copy-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 3px solid var(--ink); border-radius: 14px; padding: 8px 12px; background: #fff; }
.copy-row .btn { flex: none; white-space: nowrap; }
.gu-sum { white-space: nowrap; }
.start-copies { position: relative; z-index: 1; }

/* ---------- start screen ---------- */
.start { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: linear-gradient(#6fcdfb, #c9f0ff 55%, #3cc6e8 55%, #1d86bd); position: relative; overflow: hidden; }
.start-title { font-size: clamp(40px, 7vw, 88px); font-weight: 800; color: #fff; text-shadow: 0 5px 0 var(--grape), 0 9px 0 var(--ink); text-align: center; position: relative; z-index: 1; }
.start-title span { color: var(--sun); }
.start-avatar { width: 160px; height: 250px; animation: bob 2.4s ease-in-out infinite; }
.start-hint { color: #fff; font-weight: 700; margin: 0; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.start-sky .s-cloud { position: absolute; top: 8%; left: 8%; font-size: 90px; animation: drift 40s linear infinite; }
.start-sky .s-cloud.two { top: 18%; left: 70%; font-size: 70px; animation-duration: 55s; }
.start-sea { position: absolute; bottom: 4%; display: flex; gap: 22vw; font-size: 54px; }
.start-sea span { animation: bob 2.8s ease-in-out infinite; }
.start-sea span:nth-child(2) { animation-delay: -.8s; }

/* ---------- dragons: eggs, hatching and pet cards ---------- */
.pet-modal { text-align: center; }
.pet-hero { display: flex; justify-content: center; margin: 4px auto; }
.pet-pic { width: 230px; height: 180px; overflow: visible; }
.pet-pic.egg-pic { width: 130px; height: 110px; }
.pet-sub { margin: 2px 0 0; font-weight: 800; color: var(--grape); }
.pet-traits { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 6px 0 10px; }
.pet-traits span { background: #fff4c2; border: 2px solid var(--ink); border-radius: 999px; padding: 1px 10px; font-weight: 700; font-size: 15px; }
.pet-bar { width: min(360px, 80%); height: 18px; margin: 6px auto; border: 3px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.pet-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff9f1c, #ffd23f); }
.pet-name-row { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 6px; }
.pet-name-row .np-name { max-width: 240px; }
.pet-modal .np-help { text-align: center; margin: 4px 0; }
.pet-buddy-tag { font-weight: 800; color: var(--good); align-self: center; }
.pet-rename { margin-top: 8px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.pet-rename .np-name { max-width: 220px; }
.toast-pic svg { width: 56px; height: 48px; vertical-align: middle; }
.egg-mini { width: 46px; height: 48px; vertical-align: middle; }
.egg-row .trade-get { display: inline-flex; align-items: center; gap: 6px; }
.egg-row .trade-get b { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.egg-row .trade-get small { font-size: 14px; font-weight: 700; color: var(--grape); }

/* ---------- special dragons ---------- */
.pill-egg { position: relative; display: grid; place-items: center; width: 34px; height: 36px; margin: -6px -8px -6px 0; padding: 0; border: 0; background: none; cursor: pointer; }
.pill-egg svg { width: 34px; height: 38px; overflow: visible; animation: pillegg 2.4s ease-in-out infinite; transform-origin: 50% 100%; }
.pill-egg:not(.won) svg { filter: drop-shadow(0 0 4px #fff3a0); }
.pill-egg i { position: absolute; right: -4px; bottom: -2px; width: 18px; height: 18px; border-radius: 50%; background: var(--mint); color: #fff; border: 2px solid var(--ink); font-size: 11px; font-style: normal; display: grid; place-items: center; }
.pill-sp { border: 2px solid var(--ink); border-radius: 999px; background: linear-gradient(90deg, #fff3b0, #ffd6ee); padding: 0 12px; font: inherit; font-weight: 800; cursor: pointer; }
.pill-sp b { color: var(--grape); }
.sp-news { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 6px 0; }
.sp-news-egg { display: flex; flex-direction: column; align-items: center; font-weight: 800; color: var(--grape); width: 120px; }
.sp-news-egg .egg-pic { width: 110px; height: 100px; animation: pillegg 2.4s ease-in-out infinite; }
.sp-news-egg:nth-child(2n) .egg-pic { animation-delay: -1.2s; }
.sp-modal .modal { width: min(900px, 100%); }
.sp-count { font-weight: 700; margin: 2px 0 10px; }
.sp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.sp-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 6px 8px; border: 3px solid var(--ink); border-radius: 18px; background: #fff; font: inherit; color: var(--ink); box-shadow: 0 4px 0 rgba(58, 42, 74, .2); }
.sp-card .pet-pic { width: 100%; height: 110px; }
.sp-card .egg-pic { width: 100%; height: 110px; }
.sp-card b { font-size: 16px; }
.sp-card span { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.sp-card.won { background: radial-gradient(circle at 50% 35%, #fff8d6, #fff 70%); cursor: pointer; }
.sp-card.won span { color: var(--grape); }
.sp-card.egg { background: radial-gradient(circle at 50% 40%, #fff3b0, #fff 70%); }
.sp-card.egg .egg-pic { animation: pillegg 2.4s ease-in-out infinite; }
.sp-card.locked { background: #f4f0fa; cursor: pointer; }
.sp-card.locked > i { position: absolute; top: 36px; left: 50%; translate: -50% 0; font-size: 38px; font-weight: 800; font-style: normal; color: #fff; text-shadow: 0 3px 0 var(--grape), 0 5px 0 var(--ink); }
.sp-card.locked .pet-bar { width: 86%; height: 12px; margin: 4px auto 0; border-width: 2px; }
.sp-shadow { filter: brightness(0) opacity(.18); }
.sp-shadow .dr-glow, .sp-shadow .cr-shadow { display: none; }
.map-sp-bob { animation: mapspbob 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
.map-sp:not(.won) .map-sp-bob { filter: drop-shadow(0 0 6px #fff3a0); }
.pill-dg { background: linear-gradient(90deg, #e2f7d8, #d6ecff); }
.cave-door { cursor: pointer; }
/* My Dragons: the valley above, the cozy cave below */
.dg-modal .modal { width: min(900px, 100%); }
.dg-help { font-weight: 700; margin: 0 0 10px; }
.dg-body section { border: 3px solid var(--ink); border-radius: 22px; padding: 8px 12px 12px; margin-bottom: 12px; }
.dg-body h3 { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; font-size: 22px; margin: 0 0 8px; }
.dg-body h3 b { background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 0 10px; font-size: 17px; }
.dg-valley { background: linear-gradient(#e6f6ff, #e4f8d8); }
.dg-cave { background: radial-gradient(ellipse at 50% 0%, #ffcf8f, #f2a96a 60%, #c97c4a); color: #fff; }
.dg-cave h3 { color: #fff; text-shadow: 0 2px 0 var(--ink); }
.dg-cave h3 b { color: var(--ink); text-shadow: none; }
.dg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.dg-card { display: flex; flex-direction: column; align-items: center; gap: 2px; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 4px 6px 8px; color: var(--ink); box-shadow: 0 4px 0 rgba(58, 42, 74, .2); }
.dg-cave .dg-card { background: #fff6ea; }
.dg-pic { width: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
.dg-pic .pet-pic { width: 100%; height: 96px; }
.dg-card b { font-size: 17px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-card span { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-bottom: 4px; }
.dg-empty { grid-column: 1 / -1; font-weight: 700; margin: 6px 0; }
.dg-note { font-weight: 800; color: var(--coral-dark); margin: -2px 0 8px; }
@keyframes pillegg { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg) translateY(-2px); } }
@keyframes mapspbob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
[data-egg] { cursor: pointer; }
.hatch-wobble { animation: hatchwob .14s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
.hatch-top { animation: hatchtop 1.2s ease-out forwards; transform-box: fill-box; transform-origin: 50% 100%; }
.hatch-bottom { animation: hatchfade 1.2s ease-in .8s forwards; }
.hatch-baby { animation: hatchbaby .6s cubic-bezier(.2, 1.6, .4, 1) .15s both; transform-box: fill-box; transform-origin: 50% 100%; }
.hatch-burst { animation: hatchburst .9s ease-out forwards; transform-box: fill-box; transform-origin: 50% 50%; }
@keyframes hatchwob { from { transform: rotate(-9deg); } to { transform: rotate(9deg); } }
@keyframes hatchtop { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(40px, -110px) rotate(70deg); opacity: 0; } }
@keyframes hatchfade { to { opacity: 0; } }
@keyframes hatchbaby { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes hatchburst { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

/* ---------- players: who's playing, and making a new player ---------- */
.players { position: relative; z-index: 1; text-align: center; }
.players-q { margin: 2px 0 6px; color: #fff; font-weight: 800; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.player-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; max-width: 92vw; }
.player { display: flex; flex-direction: column; align-items: center; gap: 0; background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 4px 12px 6px; font-weight: 800; font-size: 16px; box-shadow: var(--shadow); min-width: 84px; }
.player:hover { transform: translateY(-2px); }
.player.on { background: var(--sun); }
.player .avatar-head { width: 50px; height: 50px; }
.player.add b { display: grid; place-items: center; width: 50px; height: 50px; font-size: 34px; color: var(--grape); }
.start-new { justify-content: flex-start; padding: 24px 16px 90px; overflow: auto; }
.np-card { position: relative; z-index: 1; background: var(--paper); border: 4px solid var(--ink); border-radius: 24px; padding: 16px 22px; box-shadow: var(--shadow); max-width: min(760px, 94vw); }
.np-modal .np-card { border: 0; box-shadow: none; padding: 0; background: none; }
.new-player { display: flex; gap: 22px; align-items: center; text-align: left; }
.np-me { text-align: center; flex: none; }
.np-avatar { width: 130px; height: 210px; }
.np-hi { margin: 0; font-weight: 800; font-size: 22px; color: var(--grape); }
.np-form { display: flex; flex-direction: column; gap: 8px; }
.np-label { font-size: 24px; font-weight: 800; }
.np-name { font: inherit; font-size: 26px; font-weight: 800; color: var(--ink); padding: 4px 14px; border: 3px solid var(--ink); border-radius: 14px; width: 100%; max-width: 340px; box-sizing: border-box; user-select: text; }
.np-form .np-help { margin: -4px 0 2px; font-size: 14px; color: var(--ink-soft); text-align: left; }
.np-form .np-help.np-oops, .np-oops { color: var(--coral-dark); font-weight: 800; }
.np-row { display: flex; align-items: center; gap: 10px; }
.np-row > span { width: 90px; flex: none; font-weight: 800; }
.np-row > div { display: flex; gap: 6px; flex-wrap: wrap; }
.np-pick { border: 3px solid var(--ink); background: #fff; border-radius: 12px; padding: 3px 12px; font-weight: 800; font-size: 16px; min-height: 38px; }
.np-pick.on { background: var(--sun); box-shadow: 0 0 0 3px var(--grape); }
.np-dot { display: block; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--ink); }
.np-hairs .np-pick { padding: 1px 3px; }
.np-hairs .avatar-head { width: 40px; height: 40px; display: block; }
.np-form .row { justify-content: flex-start; margin-top: 6px; }
.set-name { font: inherit; font-weight: 800; padding: 2px 10px; border: 3px solid var(--ink); border-radius: 10px; width: 10em; user-select: text; }

/* ---------- games: shared ---------- */
.game { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; overflow: hidden; }
.game-top {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px));
  background: rgba(255, 250, 240, .95); border-bottom: 4px solid var(--ink); position: relative; z-index: 3;
}
.game-top h2 { font-size: 28px; color: var(--grape); }
.game-top > :first-child { justify-self: start; }
.hud { justify-self: end; display: flex; gap: 10px; font-weight: 800; font-size: 22px; }
.hud span { background: #fff; color: var(--ink); border: 3px solid var(--ink); border-radius: 999px; padding: 0 14px; font-variant-numeric: tabular-nums; }
.hud span:empty { display: none; }

/* keyboard helper */
.kb { display: grid; gap: 5px; justify-content: center; padding: 10px 16px 14px; background: rgba(255, 250, 240, .9); border-top: 4px solid var(--ink); position: relative; z-index: 3; color: var(--ink); }
.kb-row { display: flex; gap: 5px; justify-content: center; transform: translateX(calc(var(--indent) * 22px)); }
.kb-key { width: 44px; height: 42px; border: 3px solid var(--ink); border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 20px; background: #fff; position: relative; transition: transform .08s; }
.kb-key .bump { position: absolute; bottom: 4px; width: 12px; height: 3px; border-radius: 2px; background: var(--ink); }
.kb-space { width: 300px; font-size: 15px; }
/* the whole keyboard (levels 6 and up): a little smaller so four rows fit */
.kb-full .kb-key { width: 40px; height: 38px; font-size: 18px; }
.kb-full .kb-shift { width: 70px; font-size: 13px; }
.kb-full .kb-space { width: 280px; font-size: 15px; }
.kb-full .kb-row { transform: translateX(calc(var(--indent) * 20px)); }
/* short screens: a more compact full keyboard so the games get more room */
@media (max-height: 640px) {
  .kb-full { padding: 6px 16px 8px; gap: 4px; }
  .kb-full .kb-row { gap: 4px; }
  .kb-full .kb-key { height: 32px; }
}
.f-lp { background: #ffe0ec; } .f-lr { background: #ffeccc; } .f-lm { background: #fff7c2; } .f-li { background: #dcf7e3; }
.f-ri { background: #d8eeff; } .f-rm { background: #e6dcff; } .f-rr { background: #ffdcf4; } .f-rp { background: #ffe0d6; } .f-th { background: #f1f1f1; }
.kb-key.next { background: var(--sun); transform: translateY(-4px) scale(1.12); box-shadow: 0 0 0 4px #fff, 0 0 18px 6px rgba(255, 210, 63, .9); z-index: 1; }
.kb-key.hit { animation: keyhit .25s; }
.kb-key.miss { animation: keymiss .3s; }
/* tapping the keys (phones and tablets): no double-tap zoom or text selection, Shift lights up while it's on */
.kb { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.kb-key { cursor: pointer; }
.kb-key:active { transform: scale(.9); }
.kb.shifted .kb-shift { background: var(--sun); box-shadow: 0 0 0 3px #fff; }
.kb-touch { display: none; width: 64px; font-size: 20px; }
@media (hover: none), (pointer: coarse) { .kb-touch { display: grid; } }

/* ---------- Ocean Beats ---------- */
.rhythm { background: linear-gradient(#2fb7e0, #155c9e 70%, #0f3f78); color: #fff; }
.under-sea { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.under-sea::before, .under-sea::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .6); bottom: -30px; left: 20%; animation: bubble 7s linear infinite; }
.under-sea::after { left: 72%; width: 12px; height: 12px; animation-duration: 9s; animation-delay: -3s; }
.under-sea .fish { position: absolute; font-size: 46px; animation: swim 16s linear infinite; }
.under-sea .fish.f1 { top: 18%; } .under-sea .fish.f2 { top: 64%; animation-duration: 22s; animation-delay: -8s; } .under-sea .fish.f3 { top: 40%; animation-duration: 27s; animation-delay: -14s; font-size: 36px; }
.weed { position: absolute; bottom: -10px; font-size: 90px; animation: palm 4s ease-in-out infinite; transform-origin: bottom center; }
.weed.w1 { left: 4%; } .weed.w2 { right: 6%; animation-delay: -2s; }
.song-select { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; position: relative; z-index: 1; padding: 16px; text-align: center; }
.songs { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.song-card { width: 220px; border: 4px solid var(--ink); border-radius: 22px; background: var(--paper); padding: 14px; display: flex; flex-direction: column; align-items: center; box-shadow: var(--shadow); color: var(--ink); }
.song-card:hover:not(:disabled) { transform: translateY(-4px) rotate(1deg); }
.song-card.locked { opacity: .65; cursor: not-allowed; }
.sc-emoji { font-size: 60px; } .sc-name { font-size: 24px; font-weight: 800; } .sc-sub { font-size: 16px; color: var(--ink-soft); }
.mode-pick { display: flex; gap: 10px; }
.mode-pick .chip { color: var(--ink); }
.rhythm-stage { flex: 1; position: relative; display: flex; flex-direction: column; justify-content: center; min-height: 0; }
.word-show { text-align: center; font-size: 64px; font-weight: 800; letter-spacing: 6px; min-height: 90px; position: relative; z-index: 1; text-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.word-show span { display: inline-block; opacity: .55; }
.word-show span.done { opacity: 1; color: var(--sun); }
.word-show span.now { opacity: 1; color: #fff; transform: scale(1.25); text-decoration: underline 5px var(--sun); text-underline-offset: 8px; }
.lane { position: relative; height: 150px; margin: 10px 0; background: rgba(255, 255, 255, .14); border-top: 4px solid rgba(255, 255, 255, .5); border-bottom: 4px solid rgba(255, 255, 255, .5); }
.hit-zone { position: absolute; left: 14%; top: 50%; transform: translate(-50%, -50%); width: 128px; height: 128px; border-radius: 50%; border: 6px dashed var(--sun); display: grid; place-items: center; background: rgba(255, 210, 63, .18); }
.clam { font-size: 64px; }
.dolphin { position: absolute; top: -70px; font-size: 54px; }
.dolphin.jump { animation: dolphin .5s ease-out; }
.notes { position: absolute; inset: 0; }
.note { position: absolute; top: 50%; left: 0; width: 92px; height: 92px; margin-left: -46px; border-radius: 50%; display: grid; place-items: center; font-size: 52px; font-weight: 800; color: var(--ink); background: radial-gradient(circle at 35% 30%, #fff 0 20%, #d9f6ff 60%, #9fe3ff); border: 4px solid var(--ink); box-shadow: 0 4px 0 rgba(0, 0, 0, .25); will-change: transform; }
.note.space { width: 130px; margin-left: -65px; border-radius: 40px; font-size: 26px; }
.note.hit { animation: notehit .3s ease-out forwards; }
.note.hit.perfect { background: radial-gradient(circle at 35% 30%, #fff 0 20%, #fff3a0 60%, #ffd23f); }
.note.missed { opacity: .35; filter: grayscale(1); }
.judge { position: absolute; left: 14%; top: -46px; transform: translateX(-50%); font-size: 40px; font-weight: 800; opacity: 0; text-shadow: 0 3px 0 var(--ink); white-space: nowrap; }
.judge.show.pop { animation: judge .6s ease-out forwards; }
.judge.perfect { color: var(--sun); } .judge.great { color: #8cff9e; } .judge.good { color: #bfe9ff; } .judge.miss { color: #ffb3c0; }
.get-ready { text-align: center; font-size: 34px; font-weight: 800; min-height: 50px; position: relative; z-index: 1; }

/* ---------- Bakery Rush ---------- */
.bakery { background: #ffe9d2; }
.bakery-scene { flex: 1; position: relative; min-height: 0; background: repeating-linear-gradient(90deg, #ffe2ec 0 40px, #fff0f5 40px 80px); overflow: hidden; }
.bk-window { position: absolute; top: 4%; right: 5%; width: 220px; height: 140px; border: 8px solid #fff; outline: 4px solid var(--ink); border-radius: 12px; background: linear-gradient(#8fdcff 60%, #2fb7e0 60%); overflow: hidden; }
.bk-sun { position: absolute; top: 8px; left: 14px; font-size: 40px; }
.bk-boat { position: absolute; bottom: 22px; font-size: 40px; animation: sail 18s linear infinite; }
.bk-sign { position: absolute; top: 4%; left: 50%; transform: translateX(-50%) rotate(-2deg); background: var(--coral); color: #fff; border: 4px solid var(--ink); border-radius: 16px; padding: 4px 22px; font-size: 30px; font-weight: 800; box-shadow: var(--shadow); white-space: nowrap; }
.bk-shelf { position: absolute; top: 30%; left: 4%; font-size: 40px; background: #c98a4b; border: 4px solid var(--ink); border-radius: 10px; padding: 0 10px; letter-spacing: 4px; }
.bk-baker { position: absolute; left: 3%; bottom: 60px; width: 150px; z-index: 1; }
.bk-baker .avatar-svg { width: 150px; height: 240px; }
.bk-baker.bounce { animation: jumpy .4s ease-out; }
.counter { position: absolute; left: 0; right: 0; bottom: 0; height: 110px; background: linear-gradient(#ffb3c7 0 18px, #c98a4b 18px); border-top: 4px solid var(--ink); z-index: 2; }
.customers { position: absolute; left: 22%; right: 3%; bottom: 90px; display: grid; grid-template-columns: repeat(var(--slots, 3), minmax(0, 1fr)); gap: 12px; align-items: end; z-index: 1; }
.slot { min-height: 280px; display: flex; align-items: flex-end; justify-content: center; }
.customer { display: flex; flex-direction: column; align-items: center; position: relative; max-width: 100%; }
.customer.arrive { animation: arrive .5s cubic-bezier(.2, 1.4, .4, 1); }
.customer.leave-happy { animation: leaveHappy .7s ease-in forwards; }
.customer.leave-sad { animation: leaveSad .7s ease-in forwards; }
.animal { font-size: 110px; line-height: 1; }
.customer.leave-happy .animal { transform: scaleX(-1); } /* drawn customers face the baker, then turn to go */
.mood { position: absolute; left: calc(50% + 40px); bottom: 70px; font-size: 38px; } /* beside the animal, even under a wide order */
.order { background: #fff; border: 4px solid var(--ink); border-radius: 22px; padding: 8px 16px 12px; display: flex; flex-direction: column; align-items: center; margin-bottom: 6px; box-shadow: var(--shadow); position: relative; min-width: 150px; max-width: 100%; }
.order::after { content: ''; position: absolute; bottom: -14px; left: 50%; margin-left: -10px; border: 10px solid transparent; border-top-color: var(--ink); border-bottom: 0; }
.customer.targeted .order { background: #fff8d6; box-shadow: 0 0 0 4px var(--sun), var(--shadow); }
.order-emoji { font-size: 48px; line-height: 1.1; }
.order-word { font-size: 40px; font-weight: 800; letter-spacing: 3px; }
/* longer orders get smaller letters and wrap at a space (--len is the number of characters) */
.customers .order-word { font-size: clamp(24px, calc(64px - var(--len, 6) * 2.2px), 40px); text-align: center; line-height: 1.2; }
.order-word span.done { color: var(--good); }
.order-word span.now { color: var(--coral-dark); text-decoration: underline 4px var(--coral); text-underline-offset: 6px; }
.patience { width: 100%; height: 10px; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; background: #eee; margin-top: 4px; }
.patience i { display: block; height: 100%; width: 100%; background: var(--mint); }
.flyer { position: absolute; font-size: 54px; z-index: 4; transition: transform .55s cubic-bezier(.3, .7, .4, 1); pointer-events: none; }
.bk-open { position: absolute; inset: 0; display: grid; place-items: center; font-size: 60px; font-weight: 800; color: #fff; text-shadow: 0 5px 0 var(--coral-dark), 0 9px 0 var(--ink); z-index: 5; animation: comicIn .6s cubic-bezier(.2, 1.6, .4, 1); pointer-events: none; }
/* short screens (a small laptop, and the taller keyboard from level 6): a lower counter, smaller
   customers, and the treat's picture beside its name, so the whole order bubble stays in view */
@media (max-height: 700px) {
  .bk-window { top: 3%; width: 150px; height: 92px; }
  .bk-sun { font-size: 26px; top: 4px; }
  .bk-boat { font-size: 26px; bottom: 12px; }
  .bk-sign { top: 3%; left: 3%; transform: rotate(-2deg); font-size: 20px; padding: 2px 14px; }
  .bk-shelf { top: 24%; font-size: 26px; }
  .bk-baker { width: 18vh; bottom: 30px; }
  .bk-baker .avatar-svg { width: 18vh; height: 28.8vh; }
  .counter { height: 56px; background: linear-gradient(#ffb3c7 0 12px, #c98a4b 12px); }
  .customers { bottom: 40px; }
  .slot { min-height: 0; }
  .customers .animal { font-size: 14vh; }
  .mood { left: calc(50% + 4vh); font-size: 26px; bottom: 44px; }
  .order { display: grid; grid-template-columns: auto auto; justify-content: center; align-items: center; column-gap: 6px; padding: 4px 12px 8px; border-radius: 18px; min-width: 120px; }
  .order-emoji { font-size: 30px; }
  .customers .order-word { font-size: clamp(22px, calc(50px - var(--len, 6) * 1.5px), 28px); }
  .patience { grid-column: 1 / -1; height: 8px; }
}

/* ---------- Wave Racer ---------- */
.racer { background: #2fb7e0; }
.race { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.race-sky { height: 70px; background: linear-gradient(#8fdcff, #c9f0ff); position: relative; overflow: hidden; flex: none; }
.race-sun { position: absolute; right: 6%; top: 6px; font-size: 48px; }
.gull { position: absolute; top: 12px; font-size: 32px; animation: swim 14s linear infinite; }
.lanes { flex: 1; position: relative; display: flex; flex-direction: column; min-height: 0; background: repeating-linear-gradient(90deg, #2fb7e0 0 60px, #38c0e8 60px 120px); animation: water 1.2s linear infinite; }
.lane-row { flex: 1; position: relative; border-bottom: 3px dashed rgba(255, 255, 255, .55); }
.boat > * { pointer-events: none; }
.boat { position: absolute; top: 0; bottom: 0; left: 0; transition: left .25s linear; display: flex; flex-direction: column; align-items: center; justify-content: center; margin-left: 1%; }
.boat-svg { height: 74%; width: auto; animation: rock 1.2s ease-in-out infinite; }
.boat.surge .boat-svg { animation: surge .4s ease-out; }
.rival { font-size: min(52px, 7vh); line-height: 1; animation: rock 1s ease-in-out infinite; }
.tube { width: 60px; height: 16px; border-radius: 50%; background: repeating-linear-gradient(90deg, #ff5a5f 0 14px, #fff 14px 28px); border: 3px solid var(--ink); margin-top: -14px; }
.racer-name { background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 0 10px; font-weight: 800; font-size: 13px; line-height: 1.3; white-space: nowrap; }
.boat.me .racer-name { background: var(--sun); }
.finish { position: absolute; top: 0; bottom: 0; right: 3%; width: 28px; background: repeating-conic-gradient(#fff 0 25%, var(--ink) 0 50%) 0 0 / 14px 14px; border-left: 3px solid var(--ink); border-right: 3px solid var(--ink); }
.race-word { text-align: center; padding: 8px 16px; background: var(--paper); border-top: 4px solid var(--ink); flex: none; }
.rw-now { font-size: 64px; font-weight: 800; letter-spacing: 6px; line-height: 1.1; }
/* long phrases and sentences shrink to fit on one line (--len is the number of characters) */
.race-word .rw-now { font-size: min(64px, calc((100vw - 40px) / (var(--len, 8) * .7))); letter-spacing: .09em; white-space: nowrap; }
.rw-now span.done { color: var(--good); }
.rw-now span.now { color: var(--coral-dark); text-decoration: underline 5px var(--coral); text-underline-offset: 8px; }
.rw-next { color: var(--ink-soft); font-size: 20px; font-weight: 700; min-height: 28px; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 160px; font-weight: 800; color: #fff; text-shadow: 0 8px 0 var(--grape), 0 14px 0 var(--ink); pointer-events: none; opacity: 0; z-index: 6; }
.countdown.show { animation: count .8s ease-out; opacity: 1; }
.countdown.go { color: var(--sun); }
/* short screens (a small laptop, and the taller keyboard from level 6): less sky, a smaller word,
   and boats sized to their lanes so all four racers still fit */
@media (max-height: 700px) {
  .race-sky { height: 22px; }
  .race-sun { font-size: 20px; top: 0; }
  .gull { display: none; }
  .race-word { padding: 2px 16px 4px; }
  .race-word .rw-now { font-size: min(46px, calc((100vw - 40px) / (var(--len, 8) * .7))); }
  .rw-next { font-size: 16px; min-height: 22px; }
  .boat { flex-direction: row; gap: 4px; }
  .boat-svg { height: 92%; }
  .rival { font-size: min(36px, 6vh); }
  .tube { display: none; }
  .racer-name { font-size: 12px; }
}
@media (max-width: 640px) {
  .race-word .rw-now { font-size: min(44px, calc((100vw - 40px) / (var(--len, 8) * .7))); }
}

/* ---------- fx layer ---------- */
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.confetti { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px; animation: fall linear forwards; }
.float-text { position: absolute; transform: translate(-50%, 0); font-size: 30px; font-weight: 800; color: #fff; text-shadow: 0 3px 0 var(--ink); animation: floatUp 1.3s ease-out forwards; white-space: nowrap; }
.float-text.good { color: var(--sun); }
.float-text.warn { color: #ffd0d8; font-size: 24px; }
.toast { position: absolute; left: 50%; top: 84px; transform: translateX(-50%); background: #fff; border: 4px solid var(--ink); border-radius: 20px; padding: 10px 22px; font-size: 22px; font-weight: 800; box-shadow: var(--shadow); animation: toastIn .4s cubic-bezier(.2, 1.5, .4, 1); max-width: calc(100vw - 32px); text-align: center; }
.toast.out { opacity: 0; transition: opacity .4s; }
.toast-emoji { font-size: 34px; vertical-align: middle; }
.shake { animation: shake .35s; }

/* ---------- keyframes ---------- */
@keyframes halo { 0%, 100% { transform: scale(1); opacity: .95; } 50% { transform: scale(1.14); opacity: .55; } }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(6px); } }
@keyframes slideInR { from { transform: translateX(8%); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes slideInL { from { transform: translateX(-8%); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes spinball { to { transform: rotate(720deg); } }
@keyframes netshake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px) scaleY(1.03); } 75% { transform: translateX(6px) scaleY(.98); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes walkbob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes hop { 0%, 70%, 100% { transform: translateY(0); } 80% { transform: translateY(-14px); } 90% { transform: translateY(0); } }
@keyframes jumpy { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-40px); } }
@keyframes badge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }
@keyframes drift { from { transform: translateX(-400px); } to { transform: translateX(1700px); } }
@keyframes sunpulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes wave { from { transform: translateX(0); } to { transform: translateX(-100px); } }
@keyframes foam { 0%, 100% { opacity: .5; } 50% { opacity: .8; } }
@keyframes palm { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes twinkle { 0%, 100% { opacity: .2; transform: scale(.6); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes comic { 0% { transform: scale(.2) rotate(-12deg); opacity: 0; } 20% { transform: scale(1.2) rotate(-6deg); opacity: 1; } 70% { transform: scale(1) rotate(-6deg); opacity: 1; } 100% { transform: scale(1.1) translateY(-40px) rotate(-6deg); opacity: 0; } }
@keyframes comicIn { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes poof { 0% { transform: scale(.1); opacity: 1; } 60% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }
@keyframes splat { 0% { transform: scale(0); opacity: 1; } 40% { transform: scale(1.3); } 100% { transform: scale(1); opacity: 0; } }
@keyframes dust { 0% { transform: scale(.2) translateX(0); opacity: .9; } 100% { transform: scale(1.6) translateX(60px); opacity: 0; } }
@keyframes spark { 0% { opacity: 0; transform: scale(.2); } 30% { opacity: 1; transform: scale(1.2); } 100% { opacity: 0; transform: scale(.8) translateY(-30px); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes starpop { from { transform: scale(0) rotate(-90deg); } to { transform: scale(1) rotate(0); } }
@keyframes spin { 0%, 100% { transform: rotate(-12deg) scale(1); } 50% { transform: rotate(12deg) scale(1.15); } }
@keyframes snip { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-14deg) scale(1.1); } 75% { transform: rotate(14deg) scale(1.1); } }
@keyframes keyhit { 50% { transform: scale(.9); background: #b8f5c8; } }
@keyframes keymiss { 25% { transform: translateX(-4px); background: #ffc2c8; } 75% { transform: translateX(4px); background: #ffc2c8; } }
@keyframes bubble { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-110vh); opacity: .2; } }
@keyframes swim { from { transform: translateX(-120px) scaleX(-1); } to { transform: translateX(110vw) scaleX(-1); } }
@keyframes dolphin { 0% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-40px) rotate(-20deg); } 100% { transform: translateY(0) rotate(0); } }
@keyframes notehit { to { transform: scale(1.6); opacity: 0; } }
@keyframes judge { 0% { opacity: 0; transform: translateX(-50%) scale(.5); } 25% { opacity: 1; transform: translateX(-50%) scale(1.15); } 100% { opacity: 0; transform: translateX(-50%) translateY(-24px) scale(1); } }
@keyframes sail { from { transform: translateX(-60px); } to { transform: translateX(260px); } }
@keyframes arrive { from { transform: translateY(120px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes leaveHappy { 0% { transform: none; } 30% { transform: translateY(-30px); } 100% { transform: translateX(60vw) translateY(-10px); opacity: 0; } }
@keyframes leaveSad { to { transform: translateY(160px); opacity: 0; } }
@keyframes water { from { background-position: 0 0; } to { background-position: -120px 0; } }
@keyframes rock { 0%, 100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(3deg) translateY(-4px); } }
@keyframes surge { 0% { transform: translateX(0); } 40% { transform: translateX(18px) rotate(-6deg); } 100% { transform: none; } }
@keyframes count { 0% { transform: scale(2.2); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 100% { transform: scale(.8); opacity: 0; } }
@keyframes fall { to { transform: translate(var(--drift), 110vh) rotate(var(--spin)); } }
@keyframes floatUp { from { transform: translate(-50%, 0); opacity: 1; } to { transform: translate(-50%, -70px); opacity: 0; } }
@keyframes toastIn { from { transform: translateX(-50%) translateY(-30px) scale(.8); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

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

/* ---------- short screens (small laptops): slimmer bars so the island gets the room ---------- */
@media (max-height: 820px) {
  .topbar { padding-top: 4px; padding-bottom: 4px; gap: 12px; }
  .logo { font-size: 22px; }
  .money-chip { font-size: 18px; padding: 0 10px; }
  .icon-btn { width: 38px; height: 38px; font-size: 18px; }
  .progress-pill { top: 8px; padding: 2px 14px; }
  .back-chip { top: 52px; font-size: 14px; }
  .dock { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); gap: 12px; }
  .play-card { padding: 4px 18px; min-width: 0; }
  .pc-emojis { display: none; }
  .pc-name { font-size: 22px; }
  .pc-sub { font-size: 14px; }
  .place-btn { flex-direction: row; gap: 6px; padding: 4px 12px; font-size: 15px; min-width: 0; }
  .place-btn span { font-size: 22px; }
  .map-dock .btn { font-size: 18px; padding: 6px 16px; }
}
@media (max-height: 600px) {
  .start { gap: 6px; }
  .start-hint { display: none; }
  .start-avatar { width: 80px; height: 128px; }
  .pc-sub { display: none; }
  .lvl-name { display: none; }
}

/* ---------- smaller screens ---------- */
@media (max-width: 980px) {
  .play-card { min-width: 0; }
  .pc-emojis { display: none; }
  .area-nav span { display: none; }
  .lvl-name, .gc-sub { display: none; }
  .game-card { min-width: 0; padding: 6px 12px; }
  .logo { font-size: 22px; }
  .closet { grid-template-columns: 1fr; }
  .avatar-svg.big { width: 140px; height: 220px; }
  .kb-key { width: 34px; height: 36px; font-size: 16px; }
  .kb-space { width: 220px; }
  .kb-full .kb-key { width: 30px; height: 34px; font-size: 15px; }
  .kb-full .kb-shift { width: 50px; font-size: 11px; }
  .kb-full .kb-space { width: 200px; }
  .customers { left: 30%; }
  .animal { font-size: 80px; }
  .order-word { font-size: 30px; }
  .customers .order-word { font-size: clamp(20px, calc(50px - var(--len, 6) * 1.6px), 30px); }
}
@media (max-width: 640px) {
  .topbar { gap: 8px; }
  .xp-bar { display: none; }
  .logo span { display: block; }
  .money-chip { font-size: 18px; padding: 2px 8px; }
  .games, .places { flex-wrap: wrap; justify-content: center; }
  .trade-row { grid-template-columns: auto auto auto; }
  .trade-have { grid-column: 1 / -1; text-align: center; }
  .word-show, .rw-now { font-size: 44px; }
  .bk-baker { display: none; }
  .customers { left: 2%; }
}
@media (max-width: 640px) {
  .new-player { flex-direction: column; gap: 8px; }
  .np-avatar { width: 80px; height: 130px; }
  .np-row { flex-wrap: wrap; }
}
@media (max-height: 700px) {
  .start-avatar { width: 100px; height: 160px; }
  .start-title { font-size: clamp(32px, 5vw, 60px); }
  .np-avatar { width: 100px; height: 160px; }
}
@media (max-width: 480px) {
  .logo { display: none; }
  .icon-btn { width: 38px; height: 38px; font-size: 18px; }
  .pill-bar { width: 70px; }
}

/* ---------- the new-player tour (js/tour.js) ---------- */
.coach { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.coach.off { display: none; }
body:has(.coach:not(.off)) .map-hint { display: none; }
.coach-spot { position: absolute; left: 0; top: 0; border-radius: 50%; box-shadow: 0 0 0 200vmax rgba(40, 28, 70, .32), 0 0 0 6px #fff3a0, 0 0 26px 10px rgba(255, 243, 160, .9);
  transition: transform .35s ease, width .35s ease, height .35s ease; animation: coachpulse 1.6s ease-in-out infinite; }
.coach-arrow { position: absolute; left: 0; top: 0; width: 60px; height: 50px; overflow: visible; transform-origin: 30px 25px; }
.coach-arrow path:first-child { animation: coacharrow .8s ease-in-out infinite alternate; }
.coach-bubble { position: absolute; left: 0; top: 0; max-width: min(420px, calc(100vw - 24px)); background: var(--paper); border: 4px solid var(--ink); border-radius: 22px;
  padding: 10px 18px; box-shadow: 0 6px 0 rgba(58, 42, 74, .3); text-align: center; animation: comicIn .35s cubic-bezier(.2, 1.4, .4, 1); }
.coach-bubble p { margin: 0; font-size: 21px; font-weight: 800; line-height: 1.25; text-wrap: balance; }
.coach-skip { pointer-events: auto; margin-top: 6px; border: 0; background: none; font: inherit; font-size: 14px; font-weight: 700; color: var(--ink-soft); text-decoration: underline; cursor: pointer; }
@keyframes coachpulse { 0%, 100% { box-shadow: 0 0 0 200vmax rgba(40, 28, 70, .32), 0 0 0 6px #fff3a0, 0 0 26px 10px rgba(255, 243, 160, .9); } 50% { box-shadow: 0 0 0 200vmax rgba(40, 28, 70, .32), 0 0 0 9px #ffe14d, 0 0 34px 14px rgba(255, 225, 77, .9); } }
@keyframes coacharrow { from { transform: translateY(-8px); } to { transform: translateY(2px); } }
@media (prefers-reduced-motion: reduce) { .coach-spot, .coach-arrow path:first-child { animation: none; } }

/* phones: keys sized to fit the screen's width (10 a row for letters, 12 for the whole keyboard) */
@media (max-width: 520px) {
  .kb, .kb-full { padding: 6px 4px 8px; gap: 4px; }
  .kb-row, .kb-full .kb-row { gap: 3px; transform: translateX(calc(var(--indent) * 8px)); }
  .kb-key { width: calc((100vw - 8px - 27px) / 10); height: 42px; font-size: 18px; border-width: 2px; border-radius: 8px; }
  .kb-full .kb-key { width: calc((100vw - 8px - 33px) / 12); height: 38px; font-size: 16px; }
  .kb-full .kb-shift { font-size: 9px; }
  .kb-space, .kb-full .kb-space { width: 46vw; }
  .kb-touch, .kb-full .kb-touch { width: 17vw; }
}

/* The top bar on an iPad held upright and on phones: everything has to fit in one row (if the gear
   button sticks out past the edge, an iPad zooms the whole page out to show it). */
@media (max-width: 880px) {
  .topbar { gap: 10px; }
  .logo { font-size: 18px; line-height: 1.05; }
  .logo span { display: block; }
  .money { gap: 6px; }
  .money-chip { font-size: 18px; padding: 2px 9px; gap: 4px; }
  .xp-bar { width: 64px; }
}
@media (max-width: 480px) {
  .topbar { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .money { gap: 4px; }
  .money-chip { font-size: 16px; padding: 1px 6px; gap: 3px; border-width: 2px; }
  .lvl { padding: 2px; }
}
