:root {
  --ink: #2b2140;
  --ink-soft: #6b5f86;
  --cream: #fff8e8;
  --cream-edge: #f2d98a;
  --gold: #ffcf4a;
  --gold-d: #e0a722;
  --green: #31c552;
  --green-d: #1f9a3a;
  --red: #c8324a;
  --glass: rgba(26, 22, 52, 0.58);
  --glass-edge: rgba(255, 255, 255, 0.35);
  --tile-empty: #dde5f0;
  --tile-edge: #7d8aa3;
  --board-backdrop: rgba(255, 255, 255, 0.78);
  --tile-found: #21508f;
  --panel: var(--cream);
  --panel-text: var(--ink);
  --font: "Fredoka", ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --panel: #2d2446; --panel-text: #fff3dc; --cream-edge: #8a6fd0; --ink-soft: #b9acd8; }
}
:root[data-theme="dark"] { --panel: #2d2446; --panel-text: #fff3dc; --cream-edge: #8a6fd0; --ink-soft: #b9acd8; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #1b1430; overflow: hidden; }
body { font-family: var(--font); color: #fff; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
button { font-family: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }

#app { position: fixed; inset: 0; max-width: 520px; margin: 0 auto; overflow: hidden; background: #1b1430; }
#scene, #ambient, #fx { position: absolute; inset: 0; width: 100%; height: 100%; }
#scene { z-index: 0; }
/* soft light veil over the scenery so the board is always the clearest thing on screen (admin: Backgrounds → softness) */
#scene::after, .bg-thumb::after { content: ""; position: absolute; inset: 0; background: rgba(250, 248, 243, var(--wash, 0.4)); pointer-events: none; }
#ambient { z-index: 1; pointer-events: none; }
#fx { z-index: 60; pointer-events: none; }
.scene-layer { position: absolute; inset: 0; opacity: 0; transition: opacity 1.1s ease; }
.scene-layer.in { opacity: 1; }
.scene-layer svg { display: block; }
.star { animation: twinkle 3.5s ease-in-out infinite; }
.cloud { animation: drift linear infinite alternate; }
.shimmer { animation: twinkle 2.6s ease-in-out infinite; }
.aurora { animation: aurora 9s ease-in-out infinite alternate; transform-origin: center; }
@keyframes twinkle { 50% { opacity: 0.1; } }
.firework { animation: firework 3.5s ease-out infinite; opacity: 0; }
@keyframes firework { 0% { transform: scale(0.2); opacity: 0; } 12% { opacity: 1; } 60% { transform: scale(1); opacity: 0.9; } 100% { transform: scale(1.15); opacity: 0; } }
.glowpulse { animation: glowpulse 2.4s ease-in-out infinite; }
@keyframes glowpulse { 50% { opacity: 0.55; } }
@keyframes drift { to { transform: translateX(60px); } }
@keyframes aurora { to { transform: translateX(-30px) scaleY(1.15); } }

.ic { display: inline-flex; width: 1.25em; height: 1.25em; vertical-align: -0.25em; position: relative; }
.ic svg { width: 100%; height: 100%; }
.ic.big { width: 72px; height: 72px; }

/* ---------- top bar ---------- */
.topbar { position: absolute; z-index: 20; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 10px); display: flex; align-items: center; gap: 8px; padding: 0 14px; }
.pill { display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 6px 0 8px; border-radius: 20px; background: var(--glass); border: 1.5px solid var(--glass-edge); backdrop-filter: blur(6px); font-size: 18px; }
.pill .ic { width: 26px; height: 26px; }
.pill b { font-weight: 700; min-width: 40px; text-align: left; }
.pill .plus { font-style: normal; width: 24px; height: 24px; border-radius: 50%; background: var(--green); display: grid; place-items: center; font-weight: 700; line-height: 1; }
.pill.bump { animation: bump 0.25s ease; }
@keyframes bump { 50% { transform: scale(1.12); } }
.level-tag { flex: 1; text-align: center; font-weight: 700; font-size: 18px; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45); opacity: 0; transition: opacity 0.3s; display: flex; align-items: center; justify-content: center; gap: 6px; }
body[data-screen="play"] .level-tag { opacity: 1; }
body[data-screen="home"] .level-tag { pointer-events: none; }
.icon-btn { margin-left: auto; width: 42px; height: 42px; border-radius: 50%; background: var(--glass); border: 1.5px solid var(--glass-edge); display: grid; place-items: center; }
.icon-btn .ic { width: 24px; height: 24px; }
.home-btn { margin-left: 0; display: none; flex: 0 0 auto; }
body[data-screen="play"] .home-btn { display: grid; }
body[data-screen="play"] .level-tag { font-size: 16px; }
/* dark pill so the level name reads on light skies too */
.level-tag { flex: 0 1 auto; margin: 0 auto; padding: 6px 14px; border-radius: 18px; background: var(--glass); border: 1.5px solid var(--glass-edge); backdrop-filter: blur(6px); }
body[data-screen="home"] .level-tag { visibility: hidden; }
.hard-badge { background: linear-gradient(#ff5d73, #c8324a); color: #fff; font-size: 0.65em; font-weight: 700; padding: 3px 8px; border-radius: 8px; letter-spacing: 0.06em; box-shadow: 0 2px 0 #8e1f33; }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; z-index: 10; opacity: 0; pointer-events: none; transition: opacity 0.35s ease, transform 0.35s ease; transform: scale(0.98); }
.screen.active { opacity: 1; pointer-events: auto; transform: none; }

/* ---------- home ---------- */
#home { display: flex; flex-direction: column; align-items: center; padding: calc(env(safe-area-inset-top) + 70px) 16px calc(env(safe-area-inset-bottom) + 24px); }
.logo { margin-top: 4vh; display: flex; flex-direction: column; align-items: center; line-height: 0.9; filter: drop-shadow(0 4px 0 rgba(60, 30, 90, 0.35)) drop-shadow(0 8px 18px rgba(0, 0, 0, 0.25)); }
.logo span { font-weight: 700; letter-spacing: 0.02em; -webkit-text-stroke: 2px rgba(60, 30, 90, 0.55); paint-order: stroke fill; }
.logo .l1 { font-size: clamp(40px, 13vw, 60px); color: #fff; }
.logo .l2 { font-size: clamp(52px, 17vw, 78px); background: linear-gradient(#ffe27a, #ff9f4a); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 0; filter: drop-shadow(0 2px 0 rgba(120, 50, 20, 0.55)); }
.logo { animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
.chapter { margin-top: 18px; padding: 10px 16px; border-radius: 16px; background: var(--glass); border: 1.5px solid var(--glass-edge); backdrop-filter: blur(6px); text-align: center; font-weight: 600; }
.dots { display: flex; gap: 6px; justify-content: center; margin-top: 8px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: rgba(255, 255, 255, 0.3); }
.dots i.hard { border-radius: 3px; transform: rotate(45deg) scale(0.9); }
.dots i.done { background: var(--gold); }
.dots i.now { background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.1); } }
.home-side { position: absolute; top: 34%; display: flex; flex-direction: column; gap: 18px; }
.home-side.left { left: 14px; }
.home-side.right { right: 14px; }
.side-btn { width: 64px; height: 64px; border-radius: 50%; background: var(--glass); border: 2px solid var(--glass-edge); backdrop-filter: blur(6px); display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.side-btn .ic { width: 32px; height: 32px; }
.side-btn span { margin-top: 1px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
.side-btn.badge::after { content: "!"; position: absolute; top: -4px; right: -4px; width: 22px; height: 22px; border-radius: 50%; background: #e8344e; display: grid; place-items: center; font-size: 14px; border: 2px solid #fff; animation: bump 1.4s ease-in-out infinite; }
.side-btn.dim { opacity: 0.6; }
.home-bottom { margin-top: auto; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 22px; border-radius: 26px; font-size: 18px; font-weight: 700; color: #fff; position: relative; transition: transform 0.08s; }
.btn:active:not(:disabled) { transform: translateY(2px) scale(0.98); }
.btn.green { background: linear-gradient(#48d968, var(--green)); box-shadow: 0 4px 0 var(--green-d), 0 8px 18px rgba(0, 0, 0, 0.18); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25); }
.btn.gold { background: linear-gradient(#ffe07a, var(--gold)); box-shadow: 0 4px 0 var(--gold-d); color: #5a3a00; }
.btn.red { background: linear-gradient(#e2475e, var(--red)); box-shadow: 0 4px 0 #8e1f33; font-size: 13px; line-height: 1.2; }
.btn.soft { background: rgba(120, 100, 170, 0.14); color: var(--panel-text); box-shadow: none; font-size: 16px; }
.btn.soft.danger { color: #d0384f; }
.btn.ghost { background: transparent; color: var(--ink-soft); box-shadow: none; }
.btn.big { min-height: 58px; font-size: 21px; width: 100%; }
.btn.wide { width: 100%; }
.btn.huge { width: min(82%, 340px); min-height: 72px; font-size: 30px; border-radius: 38px; gap: 10px; animation: breathe 2.4s ease-in-out infinite; }
.btn.huge.hard { background: linear-gradient(#ff7088, #d63a55); box-shadow: 0 5px 0 #8e1f33, 0 10px 24px rgba(0, 0, 0, 0.25); }
@keyframes breathe { 50% { transform: scale(1.03); } }
.btn.daily { width: min(82%, 340px); min-height: 56px; background: rgba(30, 22, 60, 0.6); border: 2px solid var(--glass-edge); backdrop-filter: blur(6px); justify-content: flex-start; padding: 0 12px; gap: 10px; }
.btn.daily .ic { width: 32px; height: 32px; }
.btn.daily span { flex: 1; text-align: left; white-space: nowrap; }
.btn.daily em { font-style: normal; display: flex; flex-direction: column; align-items: center; background: #fff; color: #c8324a; border-radius: 8px; padding: 2px 8px; font-size: 10px; line-height: 1.1; }
.btn.daily em b { font-size: 18px; color: var(--ink); }
.btn.daily em.done { background: var(--green); color: #fff; padding: 6px; }
.btn.daily.done { opacity: 0.75; }
.link { display: block; margin: 14px auto 2px; color: var(--ink-soft); text-decoration: underline; font-size: 14px; }

/* ---------- play ---------- */
#play { display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 62px) 10px calc(env(safe-area-inset-bottom) + 8px); }
#board { flex: 1 1 56%; min-height: 0; position: relative; display: grid; place-items: center; }
/* a soft dark panel behind the board keeps tiles readable on every scene (bright skies included) */
.board-inner { position: relative; }
.board-inner::before { content: ""; position: absolute; inset: -10px; border-radius: 20px; background: var(--board-backdrop); border: 1px solid rgba(255, 255, 255, 0.9); box-shadow: 0 6px 24px rgba(30, 40, 70, 0.18); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.tile { position: absolute; border-radius: 16%; background: var(--tile-empty); border: 2px solid var(--tile-edge); box-shadow: inset 0 -3px 0 rgba(30, 40, 70, 0.12), 0 1px 2px rgba(30, 40, 70, 0.2); display: grid; place-items: center; font-weight: 700; color: #141a2e; transition: background 0.25s; }
.tile span { opacity: 0; transform: scale(0.4); transition: opacity 0.2s, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1); }
.tile.shown span { opacity: 1; transform: none; }
.tile.solved { background: var(--tile-found); color: #fff; border-color: var(--tile-found); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.18), 0 3px 8px rgba(0, 0, 0, 0.2); }
.tile.pop { animation: tilepop 0.42s cubic-bezier(0.3, 1.6, 0.5, 1); }
.tile.pulse { animation: tilepulse 0.5s ease; }
.tile.wave { animation: tilewave 0.6s ease; }
@keyframes tilepop { 0% { transform: scale(0.6); } 100% { transform: none; } }
@keyframes tilepulse { 30% { transform: scale(1.15); filter: brightness(1.4); } }
@keyframes tilewave { 40% { transform: translateY(-10px) scale(1.08); filter: brightness(1.3); } }
#play.picking .tile:not(.shown) { background: #fff6c8; box-shadow: 0 0 0 3px #ffd84a, 0 0 18px #ffd84a; animation: tilepulse 1s ease-in-out infinite; cursor: pointer; }

.preview { height: 46px; margin: 6px auto; display: flex; gap: 3px; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.15s; }
.preview.show { opacity: 1; }
.preview b { min-width: 34px; height: 40px; padding: 0 6px; border-radius: 10px; background: var(--tile-found); color: #fff; display: grid; place-items: center; font-size: 24px; font-weight: 700; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25); animation: chipin 0.15s ease; }
@keyframes chipin { from { transform: scale(0.5); } }
.preview.bad { animation: shake 0.4s ease; }
.preview.bad b { background: #c8324a; }
.preview.good b { background: var(--green); }
.preview.dup b { background: #8a7fb3; }
.preview.good, .preview.dup { animation: fadeup 0.5s ease forwards; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes fadeup { to { opacity: 0; transform: translateY(-14px); } }
.fly { position: fixed; z-index: 55; border-radius: 10px; background: var(--tile-found); color: #fff; display: grid; place-items: center; font: 700 24px var(--font); transform-origin: 0 0; pointer-events: none; }

#wheelArea { flex: 0 0 auto; height: min(39vh, 310px); display: flex; align-items: center; justify-content: center; position: relative; }
#wheel { position: relative; border-radius: 50%; background: radial-gradient(circle at 50% 40%, #ffffff, #f1f4f9); border: 2px solid rgba(30, 40, 70, 0.14); box-shadow: 0 8px 24px rgba(30, 40, 70, 0.22), inset 0 -6px 0 rgba(30, 40, 70, 0.05); touch-action: none; flex: 0 0 auto; }
#wheel.spin { animation: wheelspin 0.32s ease; }
@keyframes wheelspin { 50% { transform: rotate(12deg) scale(0.95); } }
#wheelLines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
#wheelLines polyline { fill: none; stroke: var(--tile-found); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.letter { position: absolute; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #141a2e; transition: background 0.12s, color 0.12s, transform 0.12s; pointer-events: none; }
.letter.on { background: var(--tile-found); color: #fff; transform: scale(1.1); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25); }
#btnShuffle { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; color: #9b93b5; display: grid; place-items: center; z-index: 2; }
#btnShuffle .ic { width: 30px; height: 30px; }
.side-col { position: absolute; top: 0; bottom: 0; display: flex; flex-direction: column; justify-content: space-around; align-items: center; }
.side-col.left { left: 2px; }
.side-col.right { right: 2px; }
.boost { width: 56px; height: 56px; border-radius: 50%; background: var(--glass); border: 2px solid var(--glass-edge); backdrop-filter: blur(6px); display: grid; place-items: center; position: relative; }
.boost .ic { width: 30px; height: 30px; margin-top: -8px; }
.boost .cost { position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; white-space: nowrap; display: flex; align-items: center; gap: 1px; }
.boost .cost .ic { width: 12px; height: 12px; margin: 0; }
.boost .cost .count { background: var(--green); border-radius: 9px; padding: 0 6px; font-size: 12px; }
.boost .cost.free { color: #9fe8ff; }
.boost.active { background: #ffd84a; border-color: #fff; box-shadow: 0 0 16px #ffd84a; }
.boost.pop { animation: bump 0.3s ease; }
.boost.jar { background: conic-gradient(var(--gold) var(--p, 0%), rgba(26, 18, 48, 0.42) 0); }
.boost.jar::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: rgba(26, 18, 48, 0.65); }
.boost.jar > * { position: relative; }
.boost.jar .cost { position: absolute; }
#play.hard #levelTag { color: #ffd0d8; }

.hard-intro { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(60, 10, 30, 0.35); animation: fadein 0.25s ease; }
.hard-intro.out { opacity: 0; transition: opacity 0.45s; }
.hi-card { text-align: center; animation: slam 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
.hi-top { font-size: 48px; font-weight: 700; color: #fff; background: linear-gradient(#ff7088, #c8324a); padding: 8px 28px; border-radius: 18px; box-shadow: 0 6px 0 #8e1f33, 0 0 40px rgba(255, 80, 110, 0.6); }
.hi-sub { margin-top: 12px; font-size: 18px; font-weight: 600; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); }
@keyframes slam { from { transform: scale(2.2); opacity: 0; } }
@keyframes fadein { from { opacity: 0; } }

/* ---------- modals ---------- */
#modal-root { position: absolute; inset: 0; z-index: 50; pointer-events: none; }
.modal-wrap { position: absolute; inset: 0; background: rgba(15, 10, 30, 0); display: grid; place-items: center; padding: 16px; pointer-events: auto; transition: background 0.2s; }
.modal-wrap.open { background: rgba(15, 10, 30, 0.6); }
.modal { position: relative; width: 100%; max-width: 420px; max-height: calc(100% - env(safe-area-inset-top) - 30px); overflow-y: auto; overscroll-behavior: contain; background: var(--panel); color: var(--panel-text); border: 3px solid var(--cream-edge); border-radius: 26px; padding: 22px 18px 20px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4); transform: scale(0.85); opacity: 0; transition: transform 0.25s cubic-bezier(0.3, 1.5, 0.5, 1), opacity 0.2s; }
.modal-wrap.open .modal { transform: none; opacity: 1; }
.modal-wrap.closing .modal { transform: scale(0.9); opacity: 0; }
.modal h1, .modal h2 { margin: 0 0 10px; text-align: center; font-weight: 700; }
.modal h2 { font-size: 28px; letter-spacing: 0.02em; }
.modal h3 { margin: 0 0 4px; font-size: 20px; }
.modal p { margin: 6px 0; }
.modal-x { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; color: var(--ink-soft); display: grid; place-items: center; z-index: 2; }
.modal-x .ic { width: 22px; height: 22px; }
.center { text-align: center; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.row { display: flex; }
.col { display: flex; flex-direction: column; }
.gap { gap: 10px; margin-top: 14px; }
.row.gap > * { flex: 1; }
.modal.small { max-width: 360px; }

.toggles { display: flex; justify-content: center; gap: 14px; margin: 16px 0 10px; flex-wrap: wrap; }
.round-toggle { width: 74px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; text-transform: uppercase; color: var(--ink-soft); position: relative; }
.round-toggle > .ic:first-child { width: 64px; height: 64px; padding: 16px; border-radius: 50%; background: #c9c1b0; color: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15); }
.round-toggle.on > .ic:first-child { background: var(--green); box-shadow: 0 4px 0 var(--green-d); }
.round-toggle.home > .ic:first-child { background: #f2d98a; color: #7a4b1a; box-shadow: 0 4px 0 #d0b060; }
.round-toggle .ic.slash { position: absolute; top: 14px; left: 50%; width: 36px; height: 36px; margin-left: -18px; color: #fff; }
.pill-note { color: var(--green-d); font-weight: 600; }

.how { padding-left: 20px; line-height: 1.5; }
.how li { margin-bottom: 8px; }
.jar-words { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 14px 0; }
.jar-words span { background: var(--tile-found); color: #fff; padding: 4px 10px; border-radius: 10px; font-weight: 600; }

/* win */
.modal.win { text-align: center; padding-top: 34px; overflow: visible; }
.win-ribbon { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); white-space: nowrap; background: linear-gradient(#5aa8ff, #2f6fd6); color: #fff; font-weight: 700; padding: 8px 22px; border-radius: 14px; box-shadow: 0 4px 0 #1f4f9e; }
.win-ribbon.hard { background: linear-gradient(#ff7088, #c8324a); box-shadow: 0 4px 0 #8e1f33; }
.praise { font-size: clamp(28px, 9vw, 40px); text-wrap: balance; margin: 8px 0 4px; background: linear-gradient(#ffb03a, #ff6b3a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.reward-gem { display: flex; flex-direction: column; align-items: center; margin: 4px 0 10px; font-size: 36px; font-weight: 700; }
.reward-gem .ic.big { animation: gemspin 2.4s ease-in-out infinite; filter: drop-shadow(0 6px 10px rgba(30, 160, 90, 0.45)); }
@keyframes gemspin { 50% { transform: translateY(-6px) rotate(-6deg) scale(1.05); } }

/* shop */
.modal.shop { padding-top: 18px; }
.sec-title { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; color: #e0a722; font-weight: 700; font-size: 20px; letter-spacing: 0.04em; text-transform: uppercase; }
.sec-title::before, .sec-title::after { content: ""; flex: 1; height: 1.5px; background: linear-gradient(90deg, transparent, #e0c060, transparent); }
.card { position: relative; background: rgba(255, 255, 255, 0.55); border: 2px solid var(--cream-edge); border-radius: 18px; padding: 12px; margin-bottom: 10px; }
.gem-row { display: flex; align-items: center; gap: 10px; }
.gem-row .amt { flex: 1; font-size: 24px; font-weight: 700; }
.gem-row .btn { min-width: 120px; }
.gem-pile { width: 70px; display: flex; justify-content: center; }
.gem-pile .ic { width: 30px; height: 30px; margin: 0 -6px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.15)); }
.gem-pile.p3 .ic, .gem-pile.p4 .ic { width: 34px; height: 34px; }
.tag { position: absolute; top: -9px; left: 12px; background: #ff6b8a; color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 8px; }
.bundle { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; }
.bundle-title { font-weight: 700; font-size: 18px; grid-column: 1 / -1; }
.bundle-items { display: flex; gap: 8px; font-weight: 700; white-space: nowrap; }
.bundle-items .ic { width: 24px; height: 24px; }
.noads { display: grid; grid-template-columns: 1fr 86px; gap: 8px; align-items: center; }
.noads p { margin: 2px 0; }
.noads .btn { grid-column: 1 / -1; }
.noads-ic { width: 86px; height: 86px; }
.club { background: linear-gradient(#9c2f4a, #7a2140); color: #fff; border-color: #e0a722; }
.club h3 { color: #ffd36b; }
.club .ic { width: 20px; height: 20px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .card:not(.club) { background: rgba(255, 255, 255, 0.06); } }
:root[data-theme="dark"] .card:not(.club) { background: rgba(255, 255, 255, 0.06); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .day:not(.today) { background: rgba(255, 255, 255, 0.06); } }
:root[data-theme="dark"] .day:not(.today) { background: rgba(255, 255, 255, 0.06); }

/* spin */
.modal.spin { background: linear-gradient(#3b2f7a, #241b52); color: #fff; border-color: #ffd36b; }
.modal.spin .modal-x { color: #fff; }
.modal.spin .muted { color: #c9c1ea; }
.spin-wrap { position: relative; width: min(78vw, 320px); aspect-ratio: 1; margin: 6px auto 12px; }
.spin-rot { width: 100%; height: 100%; }
.spin-svg { width: 100%; height: 100%; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.4)); }
.spin-pointer { position: absolute; top: -6px; left: 50%; width: 30px; height: 40px; margin-left: -15px; background: linear-gradient(#ffe27a, #e0a722); clip-path: polygon(50% 100%, 0 0, 100% 0); filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4)); }
.spin-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 8px; min-height: 12px; }
.spin-dots i { width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.spin-dots i.used { background: #4a3f8a; }

/* gift */
.days { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.day { background: rgba(255, 255, 255, 0.55); border: 2px solid var(--cream-edge); border-radius: 14px; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; font-weight: 700; }
.day small { font-size: 11px; color: var(--ink-soft); }
.day .ic { width: 28px; height: 28px; margin: 2px 0; }
.day.got { opacity: 0.45; }
.day.today { background: #fff3c4; border-color: var(--green); box-shadow: 0 0 0 3px rgba(49, 197, 82, 0.35); animation: bump 1.4s ease-in-out infinite; color: var(--ink); }
.day:last-child { grid-column: span 2; }

/* check-in streak */
.streak-chip { margin-top: 10px; display: flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 18px; background: rgba(255, 122, 46, 0.85); font-weight: 700; font-size: 15px; box-shadow: 0 3px 0 rgba(150, 60, 10, 0.5); }
.streak-chip .ic { width: 20px; height: 20px; }
.streak-chip.todo { background: var(--glass); border: 1.5px solid var(--glass-edge); animation: breathe 2s ease-in-out infinite; }
.streak-card { display: flex; align-items: center; gap: 12px; padding: 12px; margin: 10px 0 4px; border-radius: 18px; background: linear-gradient(#ffb36b, #ff7a2e); color: #fff; }
.streak-card .flame-big { width: 52px; height: 52px; filter: drop-shadow(0 2px 4px rgba(120, 40, 0, 0.4)); animation: gemspin 1.8s ease-in-out infinite; }
.streak-card .ic.flame-big path:first-child { fill: #fff3d6; }
.streak-day { font-size: 20px; font-weight: 700; }
.streak-pct { font-size: 16px; font-weight: 600; }
.streak-card .small { opacity: 0.9; }
.streak-note { display: inline-flex; align-items: center; gap: 4px; margin: -4px 0 12px; padding: 4px 12px; border-radius: 12px; background: #ffe3cc; color: #b4501a; font-weight: 700; font-size: 14px; }
.warn { color: #c8324a; font-weight: 600; }

/* profile */
.avatar { width: var(--sz); height: var(--sz); border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff6, transparent 60%), var(--av); color: #fff; display: inline-grid; place-items: center; font-weight: 700; font-size: calc(var(--sz) * 0.48); box-shadow: 0 3px 0 rgba(0,0,0,.2); }
.avatar-btn { background: none; border: 0; backdrop-filter: none; }
.avatar-btn span:last-child { font-size: 10px; text-transform: none; max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal.profile { padding-top: 16px; }
.phead { text-align: center; }
.pav { position: relative; display: inline-block; }
.pedit { position: absolute; right: -4px; bottom: 0; width: 34px; height: 34px; border-radius: 50%; background: #222; color: #fff; display: grid; place-items: center; border: 2px solid #fff; }
.pedit .ic { width: 18px; height: 18px; }
.pname { font-size: 24px; font-weight: 700; margin-top: 6px; }
.pid { color: var(--ink-soft); font-size: 13px; }
.tabs { display: flex; gap: 8px; margin: 14px 0 10px; }
.tabs button { flex: 1; min-height: 42px; border-radius: 22px; background: #2b2140; color: #fff; font-weight: 700; text-transform: uppercase; font-size: 14px; }
.tabs button.on { background: #fff3c4; color: #5a3a00; box-shadow: 0 0 0 2px var(--gold); }
.pcard { background: rgba(255,255,255,.55); border: 2px solid var(--cream-edge); border-radius: 18px; padding: 10px; margin-bottom: 10px; }
.pcard h3 { text-align: center; text-transform: uppercase; font-size: 16px; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); }
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat + .stat { border-left: 1.5px solid var(--cream-edge); }
.stat small { color: var(--ink-soft); font-size: 12px; }
.stat b { font-size: 22px; }
.stat .ic { width: 26px; height: 26px; }
.medal { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 18px; }
.medal.m1 { background: linear-gradient(#ffe27a, #e0a722); } .medal.m2 { background: linear-gradient(#d9dcf0, #8f95c4); } .medal.m3 { background: linear-gradient(#ffb08a, #c4683a); }
.chapter-card { position: relative; display: flex; align-items: center; gap: 10px; min-height: 76px; padding: 10px 12px; margin-bottom: 10px; border-radius: 18px; overflow: hidden; background: #dfe6f7; color: #2b2140; border: 2px solid #b7c4ea; }
.chapter-card.now { border-color: #ff8a9a; min-height: 110px; }
.cc-art { position: absolute; inset: 0; opacity: .55; }
.cc-art svg { width: 100%; height: 100%; }
.cc-body { position: relative; flex: 1; }
.cc-name { font-weight: 700; font-size: 20px; text-transform: uppercase; }
.cc-range { font-size: 13px; font-weight: 600; }
.chapter-card.locked { opacity: .6; }
.cc-count { position: relative; background: #fff; border-radius: 12px; padding: 2px 10px; font-weight: 700; }
.cc-play { position: relative; width: 48px; height: 48px; border-radius: 50%; background: #f07a8a; color: #fff; display: grid; place-items: center; }
.cc-done, .cc-lock { position: relative; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #fff8; color: var(--green-d); }
.cc-lock { color: #8a8fb0; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--ink); }
.field { display: block; font-weight: 700; margin-top: 6px; }
.input { width: 100%; min-height: 48px; border-radius: 14px; border: 2px solid var(--cream-edge); padding: 0 14px; font: 600 18px var(--font); background: #fff; color: #2b2140; margin-top: 4px; }
.err { color: #c8324a; min-height: 1.2em; font-weight: 600; font-size: 14px; }
/* weekly event */
.modal.event { background: linear-gradient(#5b3a6c, #2b2140); color: #fff; border-color: #ffb4a2; }
.modal.event .modal-x { color: #fff; }
.modal.event .muted { color: #e6d6f0; }
.ev-timer { display: inline-flex; align-items: center; gap: 4px; background: #0005; border-radius: 12px; padding: 3px 10px; font-weight: 600; font-size: 14px; }
.ev-art { position: relative; height: 150px; margin: 10px -6px; border-radius: 16px; overflow: hidden; }
.ev-title { position: absolute; top: 10px; left: 0; right: 0; color: #fff; text-shadow: 0 3px 8px rgba(0,0,0,.4); font-size: 32px; }
.ev-track { position: relative; height: 16px; margin: 44px 18px 30px 30px; border-radius: 8px; background: #0006; border: 2px solid #ffd36b; }
.ev-fill { height: 100%; border-radius: 6px; background: linear-gradient(#5ee07a, #2fbf4f); }
.ev-icon { position: absolute; left: -28px; top: -14px; width: 40px; height: 40px; }
.ev-icon .ic { width: 40px; height: 40px; }
.ms { position: absolute; top: -40px; transform: translateX(-50%); text-align: center; }
.ms-gift .ic { width: 28px; height: 28px; }
.ms.got .ms-gift { color: #5ee07a; }
.ms span { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); font-weight: 700; font-size: 13px; }
.ev-msg .ic { width: 18px; height: 18px; }

/* announcement, account, tournaments */
.announce { margin-top: 10px; max-width: min(320px, calc(100% - 128px)); padding: 8px 14px; border-radius: 14px; background: rgba(255, 248, 232, 0.92); color: #2b2140; font-weight: 600; text-align: center; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.account { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; }
.account > div:first-child { flex: 1 1 200px; min-width: 0; }
.gsi { min-height: 44px; }
.modal.tourney h2 .ic { width: 30px; height: 30px; }
.t-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 18px; }
.modal.tourney .ev-timer { background: rgba(120,100,170,.15); color: var(--panel-text); }
.join { text-align: center; margin: 10px 0; padding: 10px; border-radius: 14px; background: #fff3c4; color: #5a3a00; }
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 6px; margin: 16px 0 10px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 4px 8px; border-radius: 14px 14px 6px 6px; background: rgba(120,100,170,.12); min-width: 0; }
.pod.p1 { padding-top: 16px; background: linear-gradient(#fff3c4, rgba(255,207,74,.35)); color: #2b2140; }
.pod b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.pod small { color: var(--ink-soft); font-size: 12px; }
.pod .medal { width: 28px; height: 28px; font-size: 14px; }
.prize { font-style: normal; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 2px; }
.prize .ic { width: 16px; height: 16px; }
.avatar.empty { background: rgba(120,100,170,.25); }
.board { list-style: none; padding: 0; margin: 0; }
.board li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid rgba(120,100,170,.18); }
.board li.me { background: #fff3c4; color: #2b2140; border-radius: 10px; }
.board .rk { width: 28px; text-align: right; font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.board .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.board .pt { font-weight: 700; font-variant-numeric: tabular-nums; }
.mine { margin: 12px 0 4px; padding: 10px; text-align: center; border-radius: 12px; background: var(--tile-found); color: #fff; }
.last { color: var(--ink-soft); }

.save-chip { margin-top: 10px; display: flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 20px; background: #ffffff; color: #1f3a8a; font-weight: 700; font-size: 15px; box-shadow: 0 3px 10px rgba(30, 40, 70, 0.2); }
.save-chip .ic { width: 20px; height: 20px; }

/* easier reading (default sizes) */
.preview { height: 52px; }
.preview b { min-width: 40px; height: 46px; font-size: 28px; }
.boost .cost { font-size: 13px; }
.boost .cost .count { font-size: 14px; }
.level-tag, body[data-screen="play"] .level-tag { font-size: 18px; }

/* Settings → Large text */
.big-text .preview { height: 60px; }
.big-text .preview b { min-width: 48px; height: 54px; font-size: 34px; }
.big-text .modal { font-size: 19px; }
.big-text .modal h2 { font-size: 32px; }
.big-text .modal .small, .big-text .modal small { font-size: 15px; }
.big-text .btn { font-size: 20px; min-height: 54px; }
.big-text .btn.huge { font-size: 34px; }
.big-text .side-btn { font-size: 13px; }
.big-text .boost .cost { font-size: 15px; }
.big-text .chapter, .big-text .streak-chip { font-size: 18px; }
.big-text .level-tag { font-size: 20px; }
.big-text #toast { font-size: 19px; }
.big-text .round-toggle span { font-size: 15px; }

/* background picker */
.bg-btn { justify-content: flex-start; }
.bg-btn b { margin-left: 2px; }
.modal.bgpick { max-width: 460px; }
.bg-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.bg-card { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 0; text-align: center; color: var(--panel-text); min-width: 0; }
.bg-thumb { position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden; border: 3px solid transparent; box-shadow: 0 3px 8px rgba(0,0,0,.2); }
.bg-thumb svg { display: block; width: 100%; height: 100%; }
.bg-card.on .bg-thumb { border-color: var(--green); box-shadow: 0 0 0 3px rgba(49,197,82,.35); }
.bg-check { position: absolute; right: 6px; top: 6px; width: 26px; height: 26px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; }
.bg-check .ic { width: 16px; height: 16px; }
.bg-card b { font-size: 13px; line-height: 1.15; }
.bg-card small { font-size: 11px; color: var(--ink-soft); line-height: 1.15; }

/* demo ad */
.ad-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0.85); display: grid; place-items: center; padding: 20px; font-family: var(--font); }
.ad-card { position: relative; width: 100%; max-width: 380px; background: #fff; color: #333; border-radius: 18px; padding: 16px; text-align: center; }
.ad-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: #999; text-align: left; }
.ad-art { height: 220px; margin: 10px 0; border-radius: 12px; background: linear-gradient(#7fd3ff, #c6f0ff); display: grid; place-items: center; position: relative; overflow: hidden; }
.ad-sun { position: absolute; width: 90px; height: 90px; border-radius: 50%; background: #ffe27a; top: 30px; right: 40px; animation: float 3s ease-in-out infinite; }
.ad-text { position: relative; font-size: 28px; font-weight: 700; color: #2b4a8a; }
.ad-bar { height: 6px; border-radius: 3px; background: #eee; overflow: hidden; }
.ad-bar i { display: block; height: 100%; width: 0; background: var(--green); }
.ad-info { margin-top: 8px; font-weight: 600; }
.ad-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 50%; background: #333; color: #fff; font-size: 16px; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.ad-close.show { opacity: 1; pointer-events: auto; }
.ad-done .ad-info { color: var(--green-d); }

/* toast */
#toast { position: absolute; z-index: 70; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 40%); transform: translate(-50%, 20px); background: rgba(20, 14, 40, 0.88); color: #fff; padding: 10px 18px; border-radius: 16px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: 86%; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast .ic { width: 20px; height: 20px; }

@media (max-height: 640px) {
  .logo { margin-top: 0; }
  .home-side { top: 30%; }
  .side-btn { width: 56px; height: 56px; }
  #wheelArea { height: 38vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
