:root {
  --bg: #1d1838; --bg2: #2d2256; --accent: #ff7ab6; --fg: #fff;
  --card: rgba(20, 16, 44, 0.94); --muted: rgba(255, 255, 255, 0.68); --line: rgba(255, 255, 255, 0.12);
  --hud-h: 56px; --goal-h: 30px;
  color-scheme: dark;
}
.light-theme { --card: rgba(255, 245, 250, 0.96); --muted: rgba(90, 18, 54, 0.7); --line: rgba(90, 18, 54, 0.15); color-scheme: light; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); background-image: radial-gradient(120% 70% at 50% 0%, var(--bg2), var(--bg) 70%);
  background-attachment: fixed; color: var(--fg); line-height: 1.55;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* ---------- Game shell ---------- */
.game { position: relative; display: flex; flex-direction: column; align-items: center; min-height: 100vh; min-height: 100svh; padding: 0 12px; user-select: none; -webkit-user-select: none; }
.hud { width: 100%; max-width: 520px; height: var(--hud-h); display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; }
.iconbtn, .petals { height: 40px; min-width: 40px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, 0.1); font-size: 18px; font-weight: 700; padding: 0 12px; }
.light-theme .iconbtn, .light-theme .petals { background: rgba(90, 18, 54, 0.08); }
.iconbtn { padding: 0; }
.scorebox { text-align: center; line-height: 1.05; }
#score { font-size: 30px; font-weight: 900; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.best { font-size: 12px; color: var(--muted); font-weight: 600; }
.goal { width: 100%; max-width: 520px; height: var(--goal-h); display: flex; flex-direction: column; justify-content: center; gap: 4px; font-size: 12.5px; font-weight: 700; color: var(--muted); text-align: center; }
.goal-bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.goal-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 6px; transition: width .35s ease; }
.stage {
  position: relative; touch-action: none;
  width: min(100%, 520px, calc((100vh - var(--hud-h) - var(--goal-h) - 14px) * 0.7049));
  width: min(100%, 520px, calc((100svh - var(--hud-h) - var(--goal-h) - 14px) * 0.7049));
  aspect-ratio: 86 / 122; min-width: 260px;
}
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
#hint { position: absolute; left: 0; right: 0; bottom: 30%; text-align: center; pointer-events: none; font-weight: 800; font-size: 15px; color: var(--fg); text-shadow: 0 2px 8px rgba(0,0,0,.5); animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(6px); } }
.scroll-cue { margin: 4px 0 10px; font-size: 13px; color: var(--muted); text-decoration: none; }

/* ---------- Overlay / cards ---------- */
#overlay { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade .18s ease; }
#overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.card { position: relative; width: 100%; max-width: 400px; max-height: calc(100svh - 32px); overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 22px 18px 18px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.45); animation: pop .2s ease; }
.card h2 { margin: 2px 0 8px; font-size: 24px; line-height: 1.2; }
.card .sub { margin: 4px 0 14px; color: var(--muted); font-size: 14px; }
.logo { font-size: 38px; font-weight: 900; letter-spacing: -1px; line-height: 1.1; margin-top: 4px; }
.logo span { color: var(--accent); }
.x { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.1); font-size: 16px; }
.big { display: block; width: 100%; margin: 8px 0; padding: 13px 14px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.07); font-size: 17px; font-weight: 800; text-align: center; transition: transform .08s ease; }
.big small { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.big:active, .grid4 button:active, .lvl:active { transform: scale(.97); }
.primary { background: var(--accent) !important; color: #170c22 !important; border-color: transparent !important; box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent); }
.primary small { color: rgba(23, 12, 34, .75) !important; }
button:disabled { opacity: .45; cursor: default; }
button:focus:not(:focus-visible) { outline: none; }
.ghost { display: block; width: 100%; margin: 6px 0 0; padding: 10px; border: 0; background: none; color: var(--muted); font-weight: 700; font-size: 14px; }
.ghost.gold { color: #ffd86b; }
.light-theme .ghost.gold { color: #b06a00; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.grid4 button { padding: 10px 0 8px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.06); font-size: 22px; }
.grid4 span { display: block; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.bigscore { font-size: 56px; font-weight: 900; letter-spacing: -2px; line-height: 1.05; margin: 4px 0; }
.newbest { display: inline-block; padding: 4px 12px; border-radius: 99px; background: #ffd84d; color: #3a2400; font-weight: 900; font-size: 13px; animation: pop .4s ease; }
.earned { margin: 6px 0 2px; font-weight: 800; font-size: 18px; }
.stars { font-size: 46px; letter-spacing: 4px; color: rgba(255,255,255,.2); }
.stars .on { color: #ffd84d; text-shadow: 0 0 18px rgba(255,216,77,.6); }
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.lvl { aspect-ratio: 1; padding: 2px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.07); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.lvl b { font-size: 17px; }
.lvl i { font-style: normal; font-size: 10px; height: 12px; }
.lvl em { font-style: normal; font-size: 10px; color: #ffd84d; letter-spacing: -1px; }
.lvl.cur { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.lvl.locked { opacity: .35; }
.themes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme { border-radius: 16px; padding: 12px 8px; border: 1px solid var(--line); }
.theme b { display: block; margin: 6px 0; }
.theme button { width: 100%; padding: 8px; border-radius: 10px; border: 0; background: rgba(255,255,255,.15); font-weight: 800; }
.sw { display: flex; justify-content: center; gap: 3px; }
.sw i { width: 18px; height: 18px; border-radius: 5px; }
.ach { list-style: none; margin: 0; padding: 0; text-align: left; }
.ach li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); opacity: .55; }
.ach li.done { opacity: 1; }
.ach li > span { font-size: 22px; }
.ach li div { flex: 1; }
.ach small { display: block; color: var(--muted); }
.ach em { font-style: normal; font-weight: 700; font-size: 13px; white-space: nowrap; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats div { padding: 10px; border-radius: 12px; background: rgba(255,255,255,.06); }
.stats small { display: block; color: var(--muted); font-size: 12px; }
.stats b { font-size: 20px; }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 12px 6px; border-bottom: 1px solid var(--line); font-weight: 700; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
.links { margin: 16px 0 4px; }
.cal { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 8px; }
.day { padding: 8px 2px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.05); line-height: 1.2; }
.day small { display: block; font-size: 11px; color: var(--muted); }
.day b { font-size: 22px; }
.day em { display: block; font-style: normal; font-weight: 800; font-size: 13px; }
.day.got { opacity: .45; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.day:last-child { grid-column: span 1; }
#toast { position: fixed; left: 50%; top: 14px; z-index: 40; transform: translate(-50%, -30px); opacity: 0; padding: 10px 18px; border-radius: 99px; background: #fff; color: #222; font-weight: 800; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.35); transition: all .3s ease; pointer-events: none; white-space: nowrap; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- SEO / content section ---------- */
.content { max-width: 760px; margin: 0 auto; padding: 32px 18px 48px; }
.content h1 { font-size: clamp(26px, 5vw, 38px); line-height: 1.15; letter-spacing: -0.5px; margin: 0 0 12px; }
.content h2 { font-size: 24px; margin: 36px 0 10px; line-height: 1.25; }
.content h3 { font-size: 18px; margin: 22px 0 6px; }
.content p, .content li { color: color-mix(in srgb, var(--fg) 86%, transparent); font-size: 16.5px; }
.content .lead { font-size: 18px; }
.content ol, .content ul { padding-left: 22px; }
.content li { margin: 6px 0; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 14px 0; }
.modes article { padding: 16px; border-radius: 16px; background: rgba(255,255,255,.06); border: 1px solid var(--line); }
.modes h3 { margin-top: 0; }
.cta { display: inline-block; margin: 10px 0; padding: 12px 22px; border-radius: 14px; background: var(--accent); color: #170c22; font-weight: 900; text-decoration: none; }
details { border-bottom: 1px solid var(--line); padding: 12px 0; }
summary { cursor: pointer; font-weight: 800; font-size: 17px; }
details p { margin: 8px 0 0; }
.ad-slot { margin: 28px auto; min-height: 100px; text-align: center; }
.ad-slot:empty { display: none; }
footer { max-width: 760px; margin: 0 auto; padding: 24px 18px 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
footer nav a { margin-right: 14px; }
.portal .content, .portal footer, .portal .scroll-cue, .portal .ad-slot { display: none !important; }
.page { max-width: 760px; margin: 0 auto; padding: 24px 18px 48px; }
.page header { display: flex; justify-content: space-between; align-items: center; padding: 8px 0 18px; }
.page header a.brand { font-weight: 900; font-size: 22px; text-decoration: none; color: var(--fg); }
.page header a.brand span { color: var(--accent); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* cross-promo (shared with arcade.css) */
.a-more { margin-top: 14px; text-align: left; }
.a-more-h { font-weight: 800; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.a-more-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.a-mini { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; border-radius: 14px; text-decoration: none; color: var(--fg); background: linear-gradient(160deg, color-mix(in srgb, var(--c) 35%, transparent), rgba(255,255,255,.06)); border: 1px solid var(--line); text-align: center; line-height: 1.2; }
.a-mini span { font-size: 26px; }
.a-mini b { font-size: 12.5px; margin-top: 4px; }
.a-mini small { font-size: 10.5px; color: var(--muted); }
