/* Shared look for the daily puzzle games.
   Default theme "warm morning" (light, cream + apricot). Alternate theme "night jelly": html[data-theme="night"] (?theme=night).
   Master copy lives in AddicGame/shared; each game's www/ holds a copy (run shared/sync.sh after edits). */
@font-face { font-family: Fredoka; src: url(fonts/Fredoka.ttf) format("truetype"); font-weight: 300 700; font-display: block; }

:root {
  --font: Fredoka, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --spring: linear(0, .24 7%, .65 15%, 1.02 25%, 1.13 32%, 1.12 38%, 1.03 49%, .98 58%, 1 75%, 1);

  /* ---- warm morning (default) */
  --ink: #3b2a21; --muted: #7a6355; --faint: #b19e90; --line: rgba(110, 70, 40, .14);
  --panel: #fffdf9; --panel-shadow: 0 2px 0 rgba(150, 100, 60, .12), 0 8px 18px rgba(150, 100, 60, .1);
  --gold: #f9ad2a; --gold-2: #f07a1c; --accent-text: #d6620a; --cta-ink: #3a1d00;
  --tile-ink: #2b1d16; --gloss: .55; --tile-shadow: rgba(150, 90, 40, .28);
  --tray-bg: linear-gradient(180deg, #f7e7d5, #f0dcc5);
  --tray-shadow: inset 0 2px 8px rgba(130, 85, 45, .18), inset 0 -2px 0 rgba(255, 255, 255, .6), 0 14px 34px rgba(160, 105, 60, .2), 0 0 0 6px rgba(255, 255, 255, .55);
  --tray-border: rgba(255, 255, 255, .8); --slot: rgba(140, 95, 60, .1);
  --orb-used: rgba(130, 85, 50, .14); --orb-glow: rgba(249, 173, 42, .35);
  --on-bg: #fff1dc; --on-line: rgba(240, 122, 28, .5); --on-ink: #c25a08;
  --halo-1: rgba(255, 250, 243, .94); --halo-2: rgba(255, 246, 236, .7);
  --combo-top: var(--ca); --combo-stroke: 4px #fff; --combo-drop: drop-shadow(0 4px 0 rgba(120, 70, 30, .28)); --combo-label: var(--ink);
  --scrim: rgba(80, 45, 20, .32);
  --sheet-bg: #fffaf4; --sheet-win-bg: linear-gradient(180deg, #fff0db, #fffaf4 62%); --sheet-line: rgba(150, 100, 60, .14);
  --stat-bg: #fbeedf; --ghost-bg: #fff; --lose-badge: linear-gradient(160deg, #b7a597, #8d7a6c);
  --hero-stroke: 4px #fff; --toast-bg: #3b2a21; --toast-ink: #fff;
  --wall-a: #cbb8a4; --wall-b: #a89280; --wall-hatch: rgba(255, 255, 255, .22);
  --finger-ring: #3b2a21; --finger-fill: rgba(59, 42, 33, .16);
  --j1a: #6fd6ff; --j1b: #2a8fe6; --j2a: #8ce9a6; --j2b: #2bb064; --j3a: #ffe170; --j3b: #f2a812;
  --j4a: #ffb169; --j4b: #ee6a24; --j5a: #ff8db2; --j5b: #e03c74; --j6a: #cba4ff; --j6b: #8452ea;
  --j7a: #ffffff; --j7b: #d9cfc6;
}
html[data-theme="night"] {
  --ink: #f3f1ff; --muted: rgba(243, 241, 255, .66); --faint: rgba(243, 241, 255, .38); --line: rgba(255, 255, 255, .08);
  --panel: rgba(255, 255, 255, .055); --panel-shadow: none;
  --gold: #ffcf4a; --gold-2: #ffaa1f; --accent-text: #ffcf4a; --cta-ink: #3a2300;
  --tile-ink: #24183f; --gloss: .85; --tile-shadow: rgba(0, 0, 0, .35);
  --tray-bg: linear-gradient(180deg, rgba(10, 10, 32, .72), rgba(18, 16, 48, .72));
  --tray-shadow: inset 0 2px 14px rgba(0, 0, 0, .55), 0 18px 50px rgba(0, 0, 0, .45), 0 0 0 6px rgba(255, 255, 255, .025);
  --tray-border: rgba(255, 255, 255, .07); --slot: rgba(255, 255, 255, .045);
  --orb-used: rgba(255, 255, 255, .1); --orb-glow: rgba(255, 207, 74, .55);
  --on-bg: rgba(255, 207, 74, .14); --on-line: rgba(255, 207, 74, .45); --on-ink: #ffcf4a;
  --halo-1: rgba(6, 5, 22, .82); --halo-2: rgba(6, 5, 22, .55);
  --combo-top: #fff; --combo-stroke: 2px rgba(20, 12, 50, .55); --combo-drop: drop-shadow(0 4px 0 rgba(0, 0, 0, .5)) drop-shadow(0 0 22px var(--cb, var(--gold-2))); --combo-label: #fff;
  --scrim: rgba(5, 5, 18, .62);
  --sheet-bg: linear-gradient(180deg, #24205a, #17153d); --sheet-win-bg: linear-gradient(180deg, #2c2468, #17153d 70%); --sheet-line: rgba(255, 255, 255, .1);
  --stat-bg: rgba(255, 255, 255, .06); --ghost-bg: rgba(255, 255, 255, .08); --lose-badge: linear-gradient(160deg, #8c86c8, #5a5496);
  --hero-stroke: 3px rgba(20, 12, 50, .5); --toast-bg: #fff; --toast-ink: #1b1640;
  --wall-a: #5b6075; --wall-b: #3a3e52; --wall-hatch: rgba(255, 255, 255, .07);
  --finger-ring: #fff; --finger-fill: rgba(255, 255, 255, .3);
  --j1a: #6fe0ff; --j1b: #2a93ee; --j2a: #86f5a8; --j2b: #26b866; --j3a: #ffe46e; --j3b: #f3ad12;
  --j4a: #ffb16a; --j4b: #f06a26; --j5a: #ff86b0; --j5b: #e23a74; --j6a: #cfa6ff; --j6b: #8650ee;
  --j7a: #ffffff; --j7b: #c6bfe6;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden; position: relative; z-index: 0; isolation: isolate; color: var(--ink); font-family: var(--font); user-select: none; -webkit-user-select: none;
  background: linear-gradient(180deg, #ffe6cf 0%, #fff4e8 38%, #fff8f0 62%, #fdeedd 100%);
}
body::before, body::after { content: ""; position: fixed; inset: 0; pointer-events: none; }
/* morning: low sun in the top corner + soft warm haze at the bottom */
body::before {
  background:
    radial-gradient(42% 26% at 88% 2%, rgba(255, 196, 120, .55), transparent 70%),
    radial-gradient(70% 30% at 10% 0%, rgba(255, 170, 150, .25), transparent 70%);
}
body::after {
  background:
    radial-gradient(90% 22% at 20% 104%, rgba(255, 180, 130, .35), transparent 70%),
    radial-gradient(80% 20% at 90% 106%, rgba(255, 214, 150, .4), transparent 70%);
}
html[data-theme="night"] body {
  background:
    radial-gradient(120% 60% at 50% -5%, #2c2470 0%, transparent 60%),
    radial-gradient(80% 50% at 0% 105%, #123a63 0%, transparent 60%),
    radial-gradient(70% 40% at 100% 90%, #3b1856 0%, transparent 60%), #0c0d22;
}
html[data-theme="night"] body::before {
  background-image:
    radial-gradient(1.3px 1.3px at 12% 18%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 78% 12%, #fff 50%, transparent 51%),
    radial-gradient(1.6px 1.6px at 64% 34%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 30% 72%, #fff 50%, transparent 51%),
    radial-gradient(1.3px 1.3px at 88% 64%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 46% 88%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 52%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 94% 36%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 8%, #cfd8ff 50%, transparent 51%), radial-gradient(1.2px 1.2px at 55% 6%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 38% 26%, #ffe9c7 50%, transparent 51%), radial-gradient(1.4px 1.4px at 8% 84%, #fff 50%, transparent 51%);
  opacity: .75; animation: twinkle 5s ease-in-out infinite alternate;
}
html[data-theme="night"] body::after {
  background:
    radial-gradient(60% 22% at 50% 52%, rgba(120, 90, 255, .16), transparent 70%),
    radial-gradient(45% 20% at 72% 44%, rgba(80, 180, 255, .1), transparent 70%);
  filter: blur(6px);
}
@keyframes twinkle { from { opacity: .45; } to { opacity: .85; } }

#scene { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: center bottom / cover no-repeat; opacity: 0; transition: opacity .25s; }
#scene.on { opacity: 1; }
html[data-theme="night"] #scene { display: none; }

/* ---- abstract backdrops (set per puzzle by UI.scene): neutral, modern, the jelly blocks stay the hero */
html[data-bg] {
  --ink: #2c2433; --muted: #6c6276; --faint: #a79fb0; --line: rgba(60, 40, 90, .1);
  --panel: rgba(255, 255, 255, .82); --panel-shadow: 0 2px 0 rgba(60, 40, 90, .06), 0 8px 20px rgba(60, 40, 90, .08);
  --tray-bg: rgba(255, 255, 255, .58);
  --tray-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 14px 34px rgba(60, 40, 90, .12), 0 0 0 1px rgba(255, 255, 255, .7);
  --tray-border: rgba(255, 255, 255, .9); --slot: rgba(60, 40, 90, .07);
  --orb-used: rgba(60, 40, 90, .12); --tile-shadow: rgba(60, 40, 90, .22);
  --halo-1: rgba(255, 255, 255, .9); --halo-2: rgba(255, 255, 255, .6);
  --sheet-bg: #fff; --sheet-win-bg: linear-gradient(180deg, #fff4e3, #fff 62%); --stat-bg: #f6f2fa;
  --wall-a: #c9c3d2; --wall-b: #a29bb0; --scrim: rgba(40, 25, 60, .3); --toast-bg: #2c2433;
}
html[data-bg] body { background: #faf7fb; }
html[data-bg] body::before, html[data-bg] body::after { display: none; }
html[data-bg] .tray { -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2); }
html[data-bg] #scene { background-image: none; transition: background-color .5s, opacity .25s; }
html[data-bg] #scene::after { content: ""; position: absolute; inset: 0; pointer-events: none; }

/* mesh: big soft color blobs + faint grain */
html[data-bg="mesh"] #scene {
  background:
    radial-gradient(55% 38% at 12% 8%, var(--p1), transparent 72%),
    radial-gradient(50% 36% at 92% 28%, var(--p2), transparent 72%),
    radial-gradient(65% 42% at 8% 78%, var(--p3), transparent 72%),
    radial-gradient(60% 40% at 96% 102%, var(--p4), transparent 72%),
    var(--p0);
}
html[data-bg="mesh"] #scene::after {
  opacity: .22; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .45 0 0 0 0 .55 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* pop: one stronger pastel + tilted rows of soft dots and rings (sticker-sheet feel) */
html[data-bg="pop"] #scene {
  background:
    radial-gradient(80% 50% at 50% 0%, rgba(255, 255, 255, .55), transparent 70%),
    linear-gradient(180deg, var(--p1), var(--p3));
}
html[data-bg="pop"] #scene::after {
  inset: -30%; transform: rotate(-14deg); opacity: .4;
  background:
    radial-gradient(circle, rgba(255, 255, 255, .75) 0 7px, transparent 7.5px) 0 0 / 64px 64px,
    radial-gradient(circle, transparent 0 9px, rgba(255, 255, 255, .55) 9.5px 12px, transparent 12.5px) 32px 32px / 64px 64px;
}

/* clean: near-white, dot grid, one quiet tint at the top */
html[data-bg="clean"] #scene {
  background:
    radial-gradient(90% 34% at 50% -4%, var(--p1), transparent 75%),
    var(--p0);
}
html[data-bg="clean"] #scene::after {
  opacity: .9;
  background: radial-gradient(circle, rgba(60, 40, 90, .09) 1.2px, transparent 1.6px) 0 0 / 22px 22px;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 30%, #000 75%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 30%, #000 75%, transparent);
}
#app {
  position: relative; height: 100%; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; align-items: center;
  padding: calc(env(safe-area-inset-top) + 14px) 18px calc(env(safe-area-inset-bottom) + 12px + var(--ad-h, 0px));
}

/* ---- top bar */
.top { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.chip.help { gap: 6px; padding: 0 12px 0 9px; color: var(--ink); cursor: pointer; font: 600 15px var(--font); }
.chip.help::after { content: attr(aria-label); }
.chip.help svg { width: 20px; height: 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 22px; letter-spacing: .2px; }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; position: relative; overflow: hidden;
  background: linear-gradient(160deg, var(--j5a), var(--j5b)); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18), 0 4px 12px rgba(226, 58, 116, .3); }
.brand .mark::after { content: ""; position: absolute; left: 5px; top: 4px; width: 12px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .6); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 17px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--panel-shadow); font-weight: 600; font-size: 16px; }
.chip svg { width: 18px; height: 18px; }
.top .right { display: flex; gap: 8px; }
.chip.snd { width: 34px; padding: 0; justify-content: center; color: var(--ink); cursor: pointer; font: inherit; }
.chip.snd.zero { color: var(--faint); }
.chip.snd:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
.streak svg { color: #f2701d; }
.streak { cursor: pointer; }
.stats.one { grid-template-columns: 1fr; }
.stat small { overflow-wrap: anywhere; }
.streak.frozen { color: #3f8fd6; } .streak.frozen svg { color: #7cc4f5; }
.streak.zero { color: var(--muted); } .streak.zero svg { color: var(--faint); }

/* ---- mode line + move meter */
.status { width: 100%; display: flex; align-items: flex-end; justify-content: space-between; margin: 22px 0 14px; }
.mode { display: flex; flex-direction: column; gap: 2px; }
.mode small, .meter small { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .6px; text-transform: uppercase; }
.mode b { font-size: 24px; font-weight: 600; }
.meter { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.orbs { display: flex; gap: 7px; }
.orb { width: 20px; height: 20px; border-radius: 50%; transition: transform .25s, background .25s, box-shadow .25s;
  background: radial-gradient(circle at 35% 30%, #fff8d6 0 18%, var(--gold) 45%, var(--gold-2) 100%);
  box-shadow: 0 0 10px var(--orb-glow), inset 0 -2px 0 rgba(0, 0, 0, .14); }
.orb.used { background: var(--orb-used); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .18); transform: scale(.82); }
.orb.spend { animation: spend .35s ease-out; }
.orbs.last .orb:not(.used) { animation: pulse 1.1s ease-in-out infinite; }
@keyframes spend { 0% { transform: scale(1.35); filter: brightness(1.5); } 100% { transform: scale(.82); } }
@keyframes pulse { 50% { transform: scale(1.12); box-shadow: 0 0 16px rgba(240, 90, 60, .7); } }

/* ---- board tray */
.stage { flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 0; }
.tray { position: relative; padding: var(--pad, 8px); border-radius: 26px; background: var(--tray-bg);
  border: 1px solid var(--tray-border); box-shadow: var(--tray-shadow); }
.board { position: relative; touch-action: none; }
.tray.shake { animation: shake calc(.07s + var(--k, 1) * .02s) 3; }
@keyframes shake {
  25% { transform: translate(calc(var(--k, 1) * -1.4px), calc(var(--k, 1) * .9px)); }
  75% { transform: translate(calc(var(--k, 1) * 1.4px), calc(var(--k, 1) * -.9px)); } }
.hint { margin: 0; max-width: 40ch; text-wrap: balance; font-size: 15px; line-height: 1.45; color: var(--muted); text-align: center; min-height: 44px; transition: opacity .3s; }
.hint b { display: block; color: var(--ink); font-size: 18px; font-weight: 600; margin-bottom: 2px; }
.hint b em { font-style: normal; color: var(--accent-text); }
body.sheet-open .hint { opacity: 0; }
html:not([data-theme="night"]) .hint, html:not([data-theme="night"]) .status { text-shadow: 0 0 4px #fff7ee, 0 0 10px #fff7ee, 0 0 18px rgba(255, 247, 238, .9); }

/* ---- block tile: .jelly sets --a/--b from data-c */
.jelly { position: absolute; width: var(--s); height: var(--s); padding: calc(var(--s) * .05); }
.jelly i { position: relative; display: flex; width: 100%; height: 100%; align-items: center; justify-content: center;
  border-radius: 30%; font-style: normal; font-weight: 700; font-size: calc(var(--s) * .46); color: var(--tile-ink);
  background: linear-gradient(170deg, var(--a) 8%, var(--b) 96%);
  box-shadow: inset 0 calc(var(--s) * -.07) 0 rgba(0, 0, 0, .16), inset 0 calc(var(--s) * .035) 0 rgba(255, 255, 255, .5),
    0 calc(var(--s) * .06) calc(var(--s) * .12) var(--tile-shadow);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .4); }
.jelly i::before { content: ""; position: absolute; left: 14%; top: 9%; width: 38%; height: 22%; border-radius: 50%; opacity: var(--gloss);
  background: linear-gradient(180deg, rgba(255, 255, 255, .85), rgba(255, 255, 255, 0)); transform: rotate(-12deg); }
:is(.jelly, .mini)[data-c="1"] { --a: var(--j1a); --b: var(--j1b); } :is(.jelly, .mini)[data-c="2"] { --a: var(--j2a); --b: var(--j2b); }
:is(.jelly, .mini)[data-c="3"] { --a: var(--j3a); --b: var(--j3b); } :is(.jelly, .mini)[data-c="4"] { --a: var(--j4a); --b: var(--j4b); }
:is(.jelly, .mini)[data-c="5"] { --a: var(--j5a); --b: var(--j5b); } :is(.jelly, .mini)[data-c="6"] { --a: var(--j6a); --b: var(--j6b); }
:is(.jelly, .mini)[data-c="7"], :is(.jelly, .mini)[data-c="8"], :is(.jelly, .mini)[data-c="9"] { --a: var(--j7a); --b: var(--j7b); }
.mini[data-c="0"] { --a: var(--wall-a); --b: var(--wall-b); background: repeating-linear-gradient(135deg, var(--wall-hatch) 0 3px, transparent 3px 7px), linear-gradient(180deg, var(--a), var(--b)); }
.jelly.enter i { animation: enter .55s var(--spring) both; animation-delay: var(--d, 0s); }
.jelly.bump i { animation: squish .26s var(--spring); }
.jelly.pop i { animation: popout .22s ease-in forwards; }
@keyframes enter { from { transform: translateY(-40%) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes squish { 0% { transform: scale(1); } 35% { transform: scale(1.18, .86); } 100% { transform: scale(1); } }
@keyframes popout { 40% { transform: scale(1.25); filter: brightness(1.3); } 100% { transform: scale(.2); opacity: 0; filter: brightness(1.6); } }

/* ---- bottom dock */
.dock { width: 100%; display: flex; justify-content: center; gap: 10px; margin-top: 16px; }
.btn { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px 9px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--panel-shadow); color: var(--ink); cursor: pointer;
  font: 600 13px/1.1 var(--font); letter-spacing: .3px; transition: transform .08s, background .2s, opacity .2s; }
.btn svg { width: 24px; height: 24px; }
.btn:active { transform: scale(.95); }
.btn.on { background: var(--on-bg); border-color: var(--on-line); color: var(--on-ink); }
.btn:disabled { opacity: .38; cursor: default; transform: none; box-shadow: none; }
.btn:focus-visible, .cta:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }

/* ---- center combo callout */
#combo { position: fixed; z-index: 20; left: 50%; top: 50%; pointer-events: none; text-align: center; transform: translate(-50%, -50%); }
#combo .c { position: relative; display: block; opacity: 0; }
#combo .c::before { content: ""; position: absolute; z-index: -1; left: 50%; top: 55%; width: 300px; height: 220px; margin: -110px 0 0 -150px;
  background: radial-gradient(closest-side, var(--halo-1), var(--halo-2) 55%, transparent); }
#combo.go .c { animation: combo 1s var(--spring) both; }
#combo small { display: block; font-size: 18px; font-weight: 700; letter-spacing: 5px; color: var(--combo-label); }
#combo b { display: block; font-size: calc(54px + var(--k, 2) * 9px); font-weight: 700; line-height: 1;
  background: linear-gradient(180deg, var(--combo-top) 10%, var(--ca, var(--gold)) 55%, var(--cb, var(--gold-2)));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: var(--combo-stroke); paint-order: stroke fill; filter: var(--combo-drop); }
#combo .ring { position: absolute; left: 50%; top: 50%; --r: calc(120px + var(--k, 2) * 28px); width: var(--r); height: var(--r); margin: calc(var(--r) / -2); border-radius: 50%;
  border: 4px solid var(--ca, var(--gold)); opacity: 0; }
#combo.go .ring { animation: ring .6s ease-out; border-width: calc(3px + var(--k, 2) * .8px); }
/* warm theme: saturated fill + brown outline so the number reads on a light screen */
html:not([data-theme="night"]) #combo b { background: linear-gradient(180deg, var(--ca, var(--gold)) 0%, var(--cb, var(--gold-2)) 55%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-stroke: 5px #fff;
  filter: drop-shadow(0 0 1.5px rgba(90, 45, 15, .9)) drop-shadow(0 4px 0 rgba(90, 45, 15, .35)); }
@keyframes combo { 0% { transform: scale(.3); opacity: 0; } 18% { opacity: 1; } 70% { transform: scale(1); opacity: 1; }
  100% { transform: translateY(-26px) scale(1.05); opacity: 0; } }
@keyframes ring { 0% { transform: scale(.3); opacity: .9; } 100% { transform: scale(1.8); opacity: 0; } }
#flash { position: fixed; inset: 0; z-index: 19; pointer-events: none; background: radial-gradient(circle, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 70%); opacity: 0; }
#flash.go { animation: flash .35s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
#fx { position: fixed; inset: 0; z-index: 18; pointer-events: none; }

/* ---- title screen */
#app { transition: opacity .45s .12s, transform .6s var(--spring) .12s; }
body.intro #app { opacity: 0; transform: translateY(28px) scale(.96); pointer-events: none; }
#title { position: fixed; inset: 0; z-index: 25; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: calc(env(safe-area-inset-top) + 24px) 22px calc(env(safe-area-inset-bottom) + 28px); text-align: center; cursor: pointer; }
#title :is(h1, .tag, .tapgo) { text-shadow: 0 0 4px #fff7ee, 0 0 12px #fff7ee, 0 0 22px rgba(255, 247, 238, .9); }
html[data-theme="night"] #title :is(h1, .tag, .tapgo) { text-shadow: none; }
.t-logo { display: flex; gap: 8px; margin-bottom: 14px; }
.mini { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 30%; flex: none;
  font-weight: 700; font-size: 22px; color: var(--tile-ink); background: linear-gradient(170deg, var(--a) 8%, var(--b) 96%);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .16), inset 0 2px 0 rgba(255, 255, 255, .5), 0 3px 8px var(--tile-shadow); }
.t-logo .mini { width: 66px; height: 66px; font-size: 34px; animation: logoIn .7s var(--spring) both var(--d), bob 3.2s ease-in-out infinite calc(var(--d) * 3 + .8s); }
@keyframes logoIn { from { transform: translateY(-60px) scale(.5); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bob { 50% { transform: translateY(-5px); } }
#title h1 { margin: 0; font-size: 46px; font-weight: 700; letter-spacing: .3px; line-height: 1.1; animation: rise .6s var(--spring) both .35s; }
#title .tag { margin: 0 0 6px; font-size: 18px; font-weight: 500; color: var(--muted); animation: rise .6s var(--spring) both .45s; }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.howbtn { display: inline-flex; align-items: center; gap: 7px; height: 44px; margin-top: 18px; padding: 0 18px; border-radius: 22px; cursor: pointer;
  font: 600 16px var(--font); color: var(--ink); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--panel-shadow); animation: rise .6s var(--spring) both .55s; }
.howbtn svg { width: 20px; height: 20px; }
.howbtn[hidden] { display: none; }
.tapgo { margin-top: auto; padding-top: 20px; font-size: 17px; font-weight: 600; color: var(--ink); animation: rise .6s both .7s, breathe 1.8s ease-in-out infinite 1.3s; }
#title .tapgo { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 13vh + var(--ad-h, 0px)); left: 0; right: 0; }
@keyframes breathe { 50% { opacity: .45; } }
#title.out { pointer-events: none; animation: titleOut .55s cubic-bezier(.5, 0, .75, 0) forwards; }
@keyframes titleOut { to { opacity: 0; transform: scale(1.12); filter: blur(8px); } }

/* ---- coach marks (guided tutorial) */
#coach { position: fixed; inset: 0; z-index: 28; pointer-events: none; opacity: 0; transition: opacity .25s; }
#coach.on { opacity: 1; }
#coach.on .shade, #coach.on .skip, #coach.on .bubble .cta { pointer-events: auto; }
#coach .shade { position: absolute; inset: 0; background: rgba(58, 34, 18, .55); }
html[data-theme="night"] #coach .shade { background: rgba(4, 4, 16, .7); }
#coach .ring { position: absolute; border: 3px solid #fff; box-shadow: 0 0 0 4px rgba(249, 173, 42, .55), 0 0 26px rgba(255, 220, 160, .8);
  transition: left .35s var(--spring), top .35s var(--spring), width .35s var(--spring), height .35s var(--spring); animation: ringPulse 1.4s ease-in-out infinite; }
@keyframes ringPulse { 50% { box-shadow: 0 0 0 9px rgba(249, 173, 42, .25), 0 0 34px rgba(255, 220, 160, .9); } }
#coach .hand { position: absolute; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; opacity: 0;
  background: rgba(255, 255, 255, .45); border: 4px solid #fff; box-shadow: 0 4px 14px rgba(60, 30, 10, .35); }
#coach .hand.on { opacity: 1; }
#coach .hand.tap { animation: handTap 1.2s ease-in-out infinite; }
@keyframes handTap { 0%, 100% { transform: scale(1.15); } 40% { transform: scale(.78); background: rgba(249, 173, 42, .7); } 60% { transform: scale(1); } }
#coach .hand:is(.U, .D, .L, .R) { animation: handSwipe 1.5s cubic-bezier(.45, 0, .3, 1) infinite; }
#coach .hand.U { --dx: 0px; --dy: -90px; } #coach .hand.D { --dx: 0px; --dy: 90px; }
#coach .hand.L { --dx: -90px; --dy: 0px; } #coach .hand.R { --dx: 90px; --dy: 0px; }
@keyframes handSwipe { 0% { transform: translate(calc(var(--dx) * -.6), calc(var(--dy) * -.6)) scale(.85); opacity: 0; } 15% { opacity: 1; transform: translate(calc(var(--dx) * -.6), calc(var(--dy) * -.6)) scale(.8); }
  75% { transform: translate(calc(var(--dx) * .6), calc(var(--dy) * .6)) scale(.8); opacity: 1; } 100% { transform: translate(calc(var(--dx) * .6), calc(var(--dy) * .6)) scale(1); opacity: 0; } }
#coach .bubble { position: absolute; left: 50%; width: min(340px, calc(100vw - 32px)); transform: translateX(-50%); padding: 16px 18px; border-radius: 20px;
  background: var(--sheet-bg); color: var(--ink); box-shadow: 0 12px 30px rgba(40, 20, 5, .3); text-align: center; }
#coach .bubble::after { content: ""; position: absolute; left: calc(var(--ax) - 50vw + 50% - 9px); top: -9px; width: 18px; height: 18px; background: inherit; transform: rotate(45deg); border-radius: 3px; }
#coach .bubble.up::after { top: auto; bottom: -9px; }
#coach .bubble.in::after { display: none; }
#coach .bubble.pop { animation: bubIn .4s var(--spring); }
@keyframes bubIn { from { transform: translateX(-50%) translateY(8px) scale(.92); opacity: 0; } }
#coach .bubble p { margin: 0; font-size: 18px; font-weight: 500; line-height: 1.45; word-break: keep-all; text-wrap: balance; }
#coach .bubble p b { color: var(--accent-text); font-weight: 700; }
#coach .bubble .cta { width: 100%; height: 48px; margin-top: 14px; }
#coach .bubble .cta[hidden] { display: none; }
#coach .skip { position: absolute; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 14px); height: 36px; padding: 0 18px; border-radius: 18px; cursor: pointer;
  font: 600 15px var(--font); color: #fff; background: rgba(40, 22, 10, .5); border: 1.5px solid rgba(255, 255, 255, .5); }

/* ---- ads: hint badge, web banner slot (Toss / mock), mock full-screen ad */
.btn { position: relative; }
.btn .adtag { position: absolute; top: -7px; right: -4px; padding: 1px 6px; border-radius: 8px; font: 700 11px/1.4 var(--font); font-style: normal;
  color: #fff; background: var(--accent-text); letter-spacing: .4px; }
.dock:has(.btn:nth-child(5)) { gap: 7px; }
.dock:has(.btn:nth-child(5)) .btn { padding-inline: 2px; font-size: 12px; letter-spacing: 0; white-space: nowrap; }
#adbar { position: fixed; z-index: 24; left: 0; right: 0; bottom: 0; min-height: 50px; padding-bottom: env(safe-area-inset-bottom);
  display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .85); border-top: 1px solid var(--line); }
#adbar > span { font: 600 13px var(--font); color: var(--muted); letter-spacing: 1px; }
#admock { position: fixed; z-index: 60; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: #222; color: #fff; font-family: var(--font); }
#admock b { font-size: 48px; } #admock span { opacity: .7; }

/* ---- result sheet */
.scrim { position: fixed; inset: 0; z-index: 30; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .3s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; z-index: 31; left: 50%; bottom: 0; width: min(520px, 100%);
  padding: 26px 22px calc(env(safe-area-inset-bottom) + 22px + var(--ad-h, 0px)); border-radius: 28px 28px 0 0;
  background: var(--sheet-bg); border: 1px solid var(--sheet-line); border-bottom: 0;
  box-shadow: 0 -20px 60px rgba(60, 30, 10, .22); text-align: center; visibility: hidden;
  transition: transform .38s cubic-bezier(.2, .9, .25, 1.04), visibility 0s .38s; }
/* closed: push past the badge/hero that sticks out above the sheet, and hide it so nothing peeks at the bottom edge */
.sheet:not(.open) { transform: translate(-50%, calc(100% + 140px)); }
.sheet.open { transform: translate(-50%, 0); visibility: visible; transition: transform .38s cubic-bezier(.2, .9, .25, 1.04), visibility 0s; }
.sheet .badge { width: 64px; height: 64px; margin: -58px auto 10px; border-radius: 22px; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--gold), var(--gold-2)); color: var(--cta-ink); box-shadow: 0 10px 26px rgba(240, 122, 28, .4); }
.sheet.lose .badge { background: var(--lose-badge); color: #fff; box-shadow: 0 10px 26px rgba(60, 30, 10, .25); }
.sheet .badge svg { width: 34px; height: 34px; }
.sheet .hero { margin: -96px auto 4px; }
.sheet .hero b { display: block; font-size: 112px; font-weight: 700; line-height: 1;
  background: linear-gradient(180deg, #ffe48a 8%, var(--gold) 50%, var(--gold-2)); -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: var(--hero-stroke); paint-order: stroke fill;
  filter: drop-shadow(0 6px 0 rgba(120, 60, 20, .3)) drop-shadow(0 0 24px rgba(255, 170, 31, .45)); animation: heroIn .7s var(--spring) both .1s; }
.sheet .hero small { display: block; margin-top: 2px; font-size: 13px; font-weight: 700; letter-spacing: 3px; color: var(--accent-text); text-transform: uppercase; }
.sheet.win { padding-top: 22px; background: var(--sheet-win-bg); }
.sheet.lose h2 { font-size: 24px; } .sheet.lose { padding-top: 20px; }
@keyframes heroIn { from { transform: scale(.3) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { margin: 4px 0 6px; font-size: 30px; font-weight: 700; }
.sheet p { margin: 0 0 18px; font-size: 16px; line-height: 1.5; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.stats.two { grid-template-columns: repeat(2, 1fr); }
.stat { padding: 12px 6px; border-radius: 16px; background: var(--stat-bg); }
.stat b { display: block; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat small { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .4px; text-transform: uppercase; }
.actions { display: flex; gap: 10px; }
.cta { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 54px; border-radius: 18px; border: 0;
  font: 700 17px var(--font); cursor: pointer; transition: transform .08s; color: var(--cta-ink);
  background: linear-gradient(180deg, #ffd56e, var(--gold) 45%, var(--gold-2)); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .13), 0 8px 20px rgba(240, 122, 28, .3); }
.cta.ghost { color: var(--ink); background: var(--ghost-bg); box-shadow: var(--panel-shadow); border: 1px solid var(--line); }
.cta:active { transform: scale(.97); }
.cta svg { width: 20px; height: 20px; }
.toast { position: fixed; z-index: 40; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 28px + var(--ad-h, 0px)); transform: translate(-50%, 20px);
  padding: 10px 16px; border-radius: 14px; background: var(--toast-bg); color: var(--toast-ink); font-weight: 600; font-size: 15px; opacity: 0; transition: .25s; pointer-events: none; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .t-logo .mini, .tapgo, #title.out, .tray.shake, .jelly.enter i, .orbs.last .orb:not(.used), #flash.go, #combo .ring, body::before, .sheet .hero b { animation: none !important; }
  #fx { display: none; }
}
@media (max-height: 700px) { .status { margin: 12px 0 8px; } .hint { font-size: 14px; } .dock { margin-top: 10px; } .btn { padding: 8px 6px 7px; } }

/* friend streak cards: flame shows today's state */
.sheet p:empty { display: none; }
.stat.duo svg { display: block; width: 30px; height: 30px; margin: 0 auto 4px; }
.stat.duo.lit svg { color: #ff4d2e; filter: drop-shadow(0 2px 6px rgba(255, 77, 46, .35)); }
.stat.duo.ice svg { color: #5fb6ec; }
.sheet.duo .friends { max-height: 44vh; overflow-y: auto; }
.stat.duo.off svg { color: #d6d0dc; }
.stat.duo.off b { color: var(--muted); }

/* "Me: name [edit]" row in the friend-streak sheet and the hub */
.nick { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; margin: -2px 0 12px; }
.nick small { font-size: 13px; color: var(--muted); font-weight: 600; }
.nick b { font-size: 16px; }
.nick button { min-height: 32px; padding: 0 12px; border: 0; border-radius: 16px; background: var(--stat-bg); color: var(--ink); font: 600 13px var(--font); cursor: pointer; }
.nick input { width: 11em; height: 36px; padding: 0 12px; border: 2px solid var(--gold); border-radius: 12px; background: #fff; color: var(--ink); font: 600 16px var(--font); text-align: center; outline: none; }
#title .hub { position: absolute; top: calc(14px + env(safe-area-inset-top)); left: 16px; text-decoration: none; color: var(--ink); font-weight: 600; }
#title .hub::before { content: "‹"; font-size: 20px; margin-right: 2px; }
