/* Curvaway — glass UI. Light by default, dark follows the system. */
:root {
  --bg: #F3F3F6; --ink: #141414; --muted: #6B6B76; --red: #E5322D; --red-ink: #FFFFFF;
  --gold: #F2A516; --good: #1F9D61; --track: #E2E2E8;
  --glass: rgba(255,255,255,.62); --glass-strong: rgba(255,255,255,.82);
  --glass-border: rgba(255,255,255,.95); --hair: rgba(20,20,40,.08);
  --shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 12px 32px rgba(24,24,48,.10), 0 2px 6px rgba(24,24,48,.06);
  --blob-a: rgba(229,50,45,.20); --blob-b: rgba(90,110,200,.18); --blob-c: rgba(242,165,22,.14);
  --radius: 22px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E0E11; --ink: #EDEDF0; --muted: #9A9AA6; --track: #2A2A31;
    --glass: rgba(255,255,255,.06); --glass-strong: rgba(30,30,36,.85);
    --glass-border: rgba(255,255,255,.12); --hair: rgba(255,255,255,.08);
    --shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 16px 40px rgba(0,0,0,.45);
    --blob-a: rgba(229,50,45,.22); --blob-b: rgba(80,100,220,.20); --blob-c: rgba(242,165,22,.10);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 400 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden; touch-action: manipulation; -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* soft colour behind the glass */
.backdrop { position: fixed; inset: 0; overflow: hidden; z-index: 0; }
.blob { position: absolute; border-radius: 50%; filter: blur(60px); }
.blob.a { width: 340px; height: 340px; background: var(--blob-a); top: -90px; right: -110px; }
.blob.b { width: 380px; height: 380px; background: var(--blob-b); bottom: -140px; left: -140px; }
.blob.c { width: 220px; height: 220px; background: var(--blob-c); top: 40%; left: 55%; }

.glass {
  background: var(--glass); border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%);
  box-shadow: var(--shadow);
}
.muted { color: var(--muted); }
.small { font-size: 13px; }

#app { position: relative; z-index: 1; height: 100%; max-width: 560px; margin: 0 auto; }
.view { position: absolute; inset: 0; display: none; flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom)); }
.view.active { display: flex; animation: viewIn .28s ease-out; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } }
.scroll { flex: 1; overflow-y: auto; overflow-x: hidden; margin: 0 -16px; padding: 4px 16px 24px; -webkit-overflow-scrolling: touch; }
.scroll::-webkit-scrollbar { display: none; }

/* ---------- top bars ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; letter-spacing: -.02em; }
.brand img { width: 40px; height: 40px; filter: drop-shadow(0 4px 8px rgba(0,0,0,.15)); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; }
.chip { height: 44px; border-radius: 22px; padding: 0 14px 0 6px; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; max-width: 170px; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; display: grid; place-items: center;
  background: var(--ink); color: var(--bg); font-weight: 700; font-size: 14px; }

/* ---------- cards ---------- */
.card { border-radius: var(--radius); padding: 18px; margin-bottom: 14px; display: block; width: 100%; text-align: left; }
.hero h1 { font-size: 40px; font-weight: 800; letter-spacing: -.03em; margin: 8px 0 4px; }
.hero-top { display: flex; justify-content: space-between; align-items: center; }
.hero p { margin-bottom: 16px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; background: var(--ink); color: var(--bg); }
.pill.red { background: var(--red); color: #fff; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 16px; padding: 12px 18px; font-weight: 700; }
.btn.primary { background: var(--red); color: var(--red-ink); box-shadow: 0 10px 24px rgba(229,50,45,.35); }
.btn.primary:active { transform: translateY(1px); box-shadow: 0 6px 14px rgba(229,50,45,.35); }
.btn.dark { background: var(--ink); color: var(--bg); }
.btn.ghost { border: 1.5px solid var(--hair); background: var(--glass); }
.btn.big { width: 100%; padding: 16px; font-size: 17px; }
.btn.block { width: 100%; }

.daily { display: flex; gap: 14px; align-items: center; }
.daily .badge { width: 56px; height: 56px; border-radius: 16px; background: var(--ink); color: var(--bg); display: grid; place-items: center; flex: none; text-align: center; }
.daily .badge b { font-size: 20px; line-height: 1; display: block; }
.daily .badge small { font-size: 9px; letter-spacing: .1em; font-weight: 700; }
.daily .body { flex: 1; min-width: 0; }
.daily .body h3 { font-size: 16px; }
.daily .go { flex: none; }
.flame { color: var(--red); font-weight: 700; }

.section { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 18px 4px 10px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.track { border-radius: var(--radius); padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 6px; min-height: 132px; position: relative; }
.track.current { outline: 2px solid var(--red); outline-offset: -2px; }
.track h4 { font-size: 17px; font-weight: 800; }
.track .bars { display: flex; gap: 3px; margin-bottom: 2px; }
.track .bars i { width: 14px; height: 5px; border-radius: 3px; background: var(--track); }
.track .bars i.on { background: var(--red); }
.track .lvl { margin-top: auto; font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; }
.track .lvl span { font-size: 12px; color: var(--gold); }

.row-card { display: flex; align-items: center; gap: 14px; }
.row-card .ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--ink); color: var(--bg); flex: none; }
.row-card .body { flex: 1; min-width: 0; }
.row-card h3 { font-size: 16px; }

.stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 6px 0 12px; }
.stat { text-align: center; padding: 12px 6px; border-radius: 16px; }
.stat b { display: block; font-size: 20px; font-weight: 800; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.foot { text-align: center; margin-top: 4px; }

/* ---------- game ---------- */
.gamebar { display: flex; align-items: center; gap: 12px; padding: 4px 0 10px; }
.gamebar .title { flex: 1; min-width: 0; font-weight: 800; font-size: 17px; }
.hearts { display: flex; gap: 4px; }
.hearts svg { width: 22px; height: 22px; }
.hearts .on { fill: var(--red); stroke: var(--red); }
.hearts .off { fill: none; stroke: var(--muted); opacity: .5; }
.hearts.hit { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.progress { height: 5px; border-radius: 3px; background: var(--track); overflow: hidden; margin-bottom: 12px; }
.progress i { display: block; height: 100%; width: 0; background: var(--red); border-radius: 3px; transition: width .25s; }
.board { flex: 1; min-height: 0; border-radius: 26px; position: relative; overflow: hidden; }
.board canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.toolbar { display: flex; gap: 12px; padding-top: 12px; }
.tool { flex: 1; height: 54px; border-radius: 18px; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; }
.tool b { background: var(--red); color: #fff; border-radius: 999px; font-size: 12px; min-width: 22px; height: 22px; display: grid; place-items: center; padding: 0 6px; }
.tool .ad { background: var(--gold); }

/* ---------- leaderboard ---------- */
.tabs { display: flex; border-radius: 16px; padding: 4px; margin-bottom: 12px; }
.tabs button { flex: 1; height: 40px; border-radius: 12px; font-weight: 700; color: var(--muted); }
.tabs button.on { background: var(--ink); color: var(--bg); }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; margin-bottom: 8px; }
.lb-row.me { outline: 2px solid var(--red); outline-offset: -2px; }
.lb-row .rk { width: 30px; text-align: center; font-weight: 800; color: var(--muted); flex: none; }
.lb-row .rk.m1 { color: #D4A017; } .lb-row .rk.m2 { color: #9AA3AE; } .lb-row .rk.m3 { color: #C0773F; }
.lb-row .nm { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .val { font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-row .val small { color: var(--gold); font-weight: 700; margin-left: 6px; }
.lb-empty { text-align: center; padding: 32px 16px; }
.lb-empty .ico { width: 56px; height: 56px; border-radius: 18px; background: var(--ink); color: var(--bg); display: grid; place-items: center; margin: 0 auto 12px; }
.skel { height: 54px; border-radius: 16px; margin-bottom: 8px; background: var(--glass); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .5; } }

/* ---------- modal / sheet ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; padding: 16px;
  background: rgba(10,10,20,.28); }
.modal.show { display: flex; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-width: 400px; border-radius: 28px; padding: 26px 22px 20px; text-align: center; background: var(--glass-strong);
  animation: pop .32s cubic-bezier(.2,1.4,.4,1); max-height: 90vh; overflow-y: auto; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.sheet h2 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.sheet p { color: var(--muted); margin: 6px 0 16px; }
.sheet .actions { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.sheet .row { display: flex; gap: 10px; }
.sheet .row > * { flex: 1; }
.stars { display: flex; justify-content: center; gap: 10px; margin: 14px 0 6px; min-height: 52px; }
.stars svg { width: 52px; height: 52px; transform: scale(0) rotate(-30deg); animation: starIn .5s cubic-bezier(.3,1.7,.5,1) forwards; }
.stars .on { fill: var(--gold); stroke: #C98A1C; stroke-width: 1; }
.stars .off { fill: var(--track); stroke: none; }
@keyframes starIn { to { transform: scale(1) rotate(0); } }
.setting { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px; border-bottom: 1px solid var(--hair); text-align: left; }
.setting:last-of-type { border-bottom: 0; }
.switch { width: 50px; height: 30px; border-radius: 15px; background: var(--track); position: relative; transition: .2s; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: .2s; }
.switch.on { background: var(--good); }
.switch.on::after { left: 23px; }
.gbtn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 14px; border-radius: 16px; font-weight: 700;
  background: #fff; color: #1F1F1F; border: 1px solid #DADCE0; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.gbtn svg { width: 20px; height: 20px; }
.note { font-size: 12px; color: var(--muted); margin-top: 12px; }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }
#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 40;
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-weight: 600; font-size: 14px;
  opacity: 0; transition: .25s; pointer-events: none; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

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