@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;600;700;800&family=Fraunces:opsz,wght@9..144,800&display=swap');

:root { --ink:#18352b; --paper:#f7f3e6; --cream:#fffaf0; --leaf:#9bc66f; --leaf-dark:#5b894d; --coral:#e56b54; --gold:#f2c84b; --muted:#627068; --line:#cbd3bd; --shadow:0 10px 30px rgba(24,53,43,.14); }
* { box-sizing:border-box; }
html, body { margin:0; min-height:100%; background:var(--paper); color:var(--ink); font-family:'DM Sans',system-ui,sans-serif; }
body { background-image:radial-gradient(circle at 8% 4%,rgba(155,198,111,.22),transparent 27%),radial-gradient(circle at 90% 72%,rgba(229,107,84,.12),transparent 30%); }
button, input, select { font:inherit; }
button { color:inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline:3px solid var(--coral); outline-offset:2px; }
[hidden] { display:none !important; }
.app-shell { min-height:100dvh; padding-bottom:78px; }
.topbar { height:72px; padding:max(10px,env(safe-area-inset-top)) 16px 8px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--line); background:rgba(247,243,230,.92); position:sticky; top:0; z-index:20; backdrop-filter:blur(12px); }
.brand { border:0; background:none; display:flex; gap:10px; align-items:center; padding:0; min-height:48px; cursor:pointer; text-align:left; }
.brand-mark { display:grid; place-items:center; width:42px; height:42px; border-radius:50% 50% 45% 55%; background:var(--coral); color:white; font-family:'Fraunces',serif; font-size:1.6rem; transform:rotate(-9deg); box-shadow:inset 0 0 0 3px var(--ink); }
.brand strong { display:block; font:800 1.14rem/1 'Fraunces',serif; }
.brand small { display:block; margin-top:4px; color:var(--muted); font-size:.68rem; }
.wallet { display:flex; align-items:center; gap:7px; background:var(--ink); color:white; border-radius:999px; padding:8px 13px 8px 9px; min-width:67px; justify-content:center; }
.wallet img { width:24px; height:24px; }
.wallet strong { font-size:1.05rem; }
.main-view { width:min(100%,720px); margin:0 auto; padding:24px 16px 30px; }
.page-heading { display:flex; justify-content:space-between; gap:16px; align-items:end; margin:2px 2px 20px; }
.page-heading h1, .drawer h2, .result-title { font-family:'Fraunces',serif; letter-spacing:-.035em; }
.page-heading h1 { margin:0; font-size:clamp(2rem,9vw,3rem); line-height:.95; }
.page-heading p { margin:7px 0 0; color:var(--muted); font-size:.88rem; }
.text-button { min-height:44px; border:0; background:none; color:var(--leaf-dark); font-weight:800; text-decoration:underline; cursor:pointer; }
.onboarding { border:2px solid var(--ink); border-radius:18px; padding:16px 18px; background:var(--gold); box-shadow:5px 5px 0 var(--ink); margin:0 0 22px; font-weight:800; }
.onboarding small { display:block; text-transform:uppercase; letter-spacing:.12em; margin-bottom:5px; }
.card-list { display:grid; gap:12px; }
.section-label { margin:24px 3px 9px; font-size:.72rem; letter-spacing:.14em; text-transform:uppercase; color:var(--muted); font-weight:800; display:flex; justify-content:space-between; }
.card { width:100%; border:1px solid var(--line); border-radius:20px; background:rgba(255,250,240,.9); min-height:104px; padding:14px; display:flex; align-items:center; gap:14px; box-shadow:0 3px 0 rgba(24,53,43,.08); text-align:left; cursor:pointer; transition:transform .15s,box-shadow .15s,border-color .15s; }
.card:hover { transform:translateY(-2px); border-color:var(--leaf-dark); box-shadow:0 7px 16px rgba(24,53,43,.1); }
.card:disabled, .button:disabled, .choice-card:has(input:disabled) { opacity:.48; cursor:not-allowed; transform:none; }
.card-body { min-width:0; flex:1; }
.card-row { display:flex; gap:8px; align-items:center; justify-content:space-between; }
.card h2, .card h3 { margin:0; font-size:1rem; line-height:1.2; }
.card p { margin:5px 0 0; color:var(--muted); font-size:.79rem; line-height:1.3; }
.card .arrow { font-size:1.4rem; margin-left:auto; }
.snail-thumb { width:68px; height:82px; flex:0 0 68px; overflow:visible; }
.snail-thumb .spiral-line { transform-origin:60px 102px; }
.reverse-spiral .spiral-line { transform:scaleX(-1); transform-origin:60px 102px; }
.badge { display:inline-flex; min-height:25px; align-items:center; border-radius:999px; padding:3px 9px; background:#dceac8; color:#31522f; font-size:.68rem; font-weight:800; white-space:nowrap; }
.badge.tired { background:#f8d6a7; color:#784810; }.badge.injured,.badge.exhausted { background:#f4b6ae; color:#7d2922; }.badge.training { background:#c9dfec; color:#254d69; }
.stat-line { display:flex; gap:10px; margin-top:8px; font-size:.72rem; font-weight:700; color:var(--muted); }
.stat-line b { color:var(--ink); }
.race-card { align-items:flex-start; min-height:128px; }
.race-medal { width:50px; height:50px; display:grid; place-items:center; border-radius:14px; color:white; font:800 1.4rem 'Fraunces',serif; background:var(--leaf-dark); flex:0 0 50px; }
.race-medal.garden { background:#b85f8a; }.race-medal.grand { background:#30353e; color:var(--gold); }
.price { font-weight:800; white-space:nowrap; }.price.free { color:var(--leaf-dark); }
.locked-note { display:block; margin-top:6px; color:#a64237; font-weight:700; }
.npc-dots { display:flex; align-items:center; gap:5px; margin-top:9px; }
.npc-dot { width:16px; height:16px; border:2px solid var(--ink); border-radius:50%; background:var(--shell); }.npc-dot.defeated { box-shadow:0 0 0 2px var(--gold); }
.tier { text-transform:uppercase; letter-spacing:.12em; font-size:.65rem; font-weight:800; color:var(--muted); }
.bottom-nav { position:fixed; z-index:25; bottom:0; left:0; right:0; height:70px; padding:5px max(10px,env(safe-area-inset-left)) max(5px,env(safe-area-inset-bottom)); display:grid; grid-template-columns:repeat(4,1fr); border-top:1px solid var(--line); background:rgba(255,250,240,.96); backdrop-filter:blur(16px); }
.bottom-nav button { min-height:54px; border:0; background:transparent; font-size:.69rem; font-weight:800; color:var(--muted); border-radius:14px; cursor:pointer; }
.bottom-nav span { display:block; font-size:1.35rem; line-height:1; margin-bottom:3px; }
.bottom-nav button.active { color:var(--ink); background:#e6edd5; }
.drawer-backdrop { position:fixed; inset:0; z-index:39; background:rgba(15,35,28,.5); backdrop-filter:blur(2px); }
.drawer { position:fixed; z-index:40; background:var(--cream); inset:auto 0 0; height:min(88dvh,820px); border-radius:26px 26px 0 0; transform:translateY(105%); transition:transform .24s ease; box-shadow:0 -16px 50px rgba(24,53,43,.22); display:flex; flex-direction:column; }
.drawer.open { transform:translateY(0); }
.drawer-top { flex:0 0 58px; display:flex; align-items:center; border-bottom:1px solid var(--line); padding:7px 16px; position:relative; }
.drawer-handle { position:absolute; width:44px; height:5px; border-radius:3px; background:var(--line); top:7px; left:calc(50% - 22px); }
.back-button { border:0; background:none; min-height:44px; font-weight:800; cursor:pointer; padding:10px 4px; }
.drawer-content { overflow:auto; overscroll-behavior:contain; padding:20px 18px max(32px,env(safe-area-inset-bottom)); }
.drawer h2 { font-size:2rem; line-height:1; margin:0 0 8px; }
.drawer-lede { color:var(--muted); margin:0 0 18px; line-height:1.45; }
.hero-snail { width:150px; height:190px; display:block; margin:-12px auto 2px; }
.detail-status { display:flex; justify-content:center; margin:-3px 0 18px; }
.stats-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin:16px 0; }
.stat-box { padding:12px 8px; border:1px solid var(--line); border-radius:14px; text-align:center; background:white; }
.stat-box small { display:block; color:var(--muted); font-size:.67rem; font-weight:800; text-transform:uppercase; }.stat-box strong { display:block; font-size:1.3rem; margin-top:3px; }
.meter { height:8px; background:#e0e4d8; border-radius:99px; overflow:hidden; margin:6px 0 3px; }.meter i { display:block; height:100%; background:var(--coral); border-radius:inherit; }
.info-strip { padding:13px 14px; border-radius:14px; background:#edf2df; margin:12px 0; font-size:.82rem; line-height:1.4; }.info-strip strong { display:block; margin-bottom:2px; }
.activity-panel { display:grid; grid-template-columns:1fr auto; gap:4px 12px; align-items:center; padding:14px; border:2px solid var(--ink); border-radius:15px; background:#dce9c9; margin:14px 0 6px; }
.activity-panel small { color:var(--muted); }.activity-panel .activity-timer { font-size:1.15rem; font-weight:800; font-variant-numeric:tabular-nums; white-space:nowrap; }.activity-panel.training-now { background:#d9e9f3; }
.action-grid { display:grid; grid-template-columns:1fr 1fr; gap:9px; margin-top:18px; }.action-grid .wide { grid-column:1/-1; }
.button { min-height:48px; border:2px solid var(--ink); border-radius:13px; background:white; font-weight:800; padding:10px 15px; cursor:pointer; box-shadow:0 3px 0 var(--ink); }.button:active:not(:disabled) { transform:translateY(2px); box-shadow:0 1px 0 var(--ink); }.button.primary { background:var(--coral); color:white; }.button.green { background:var(--leaf); }.button.pale { background:var(--cream); box-shadow:none; color: black; }.button.danger { color:#9d362e; border-color:#9d362e; box-shadow:none; }.button.ghost { border-color:var(--line); box-shadow:none; }
.rename-form,.inline-form { display:flex; gap:8px; margin:14px 0; }.rename-form input,.field input,.field select,.inline-form select { width:100%; min-height:46px; border:1px solid var(--line); border-radius:11px; padding:10px 12px; background:white; color:var(--ink); }.rename-form .button { min-width:82px; }
.choice-stack { display:grid; gap:9px; margin:14px 0 20px; }
.choice-card { display:block; border:1px solid var(--line); border-radius:14px; background:white; padding:13px; cursor:pointer; }
.choice-card:has(input:checked) { border:2px solid var(--ink); padding:12px; background:#edf2df; }
.choice-card input { accent-color:var(--coral); margin-right:8px; }.choice-card strong { font-size:.9rem; }.choice-card small { display:block; margin:5px 0 0 25px; color:var(--muted); }.choice-card .choice-price { float:right; }
.summary-box { border:2px solid var(--ink); border-radius:15px; padding:14px; margin:14px 0; background:var(--gold); }.summary-box div { display:flex; justify-content:space-between; margin:4px 0; }
.subheading { margin:24px 0 9px; font-size:.75rem; letter-spacing:.12em; text-transform:uppercase; color:var(--muted); }
.roster-mini { display:grid; gap:8px; }.roster-row { display:grid; grid-template-columns:36px 1fr auto; gap:9px; align-items:center; padding:9px; border:1px solid var(--line); border-radius:12px; background:white; }.roster-row .snail-art { width:32px; height:42px; }.roster-row p { margin:2px 0 0; font-size:.7rem; color:var(--muted); }
.record { display:flex; justify-content:space-around; text-align:center; border-top:1px solid var(--line); border-bottom:1px solid var(--line); padding:13px 0; margin:16px 0; }.record strong { display:block; font-size:1.15rem; }.record small { color:var(--muted); }
.empty-state { padding:28px 18px; text-align:center; border:1px dashed var(--line); border-radius:18px; color:var(--muted); }
.race-stage { position:fixed; inset:0; z-index:80; background:#18352b; color:white; display:flex; flex-direction:column; padding:max(10px,env(safe-area-inset-top)) 12px max(10px,env(safe-area-inset-bottom)); overflow:hidden; }
.race-top { min-height:58px; display:flex; align-items:center; justify-content:space-between; gap:12px; }.race-top small { display:block; color:#cfe0bd; text-transform:uppercase; font-size:.65rem; letter-spacing:.12em; }.race-top strong { display:block; font-family:'Fraunces',serif; font-size:1.2rem; }.race-top .button { min-height:42px; padding:6px 12px; }
.track-wrap { position:relative; flex:1; min-height:0; width:min(100%,480px); margin:0 auto; overflow:hidden; border:4px solid #e8ddba; border-radius:22px; background:#7ca15e; }
.race-track { position:absolute; inset:34px 0; display:grid; grid-template-columns:repeat(3,1fr); background:repeating-linear-gradient(0deg,transparent 0 42px,rgba(255,255,255,.06) 43px 44px); }
.lane { position:relative; border-right:2px dashed rgba(255,255,255,.36); }.lane:last-child { border:0; }.lane::after { content:attr(data-name); position:absolute; bottom:2px; left:4px; right:4px; text-align:center; font-size:.61rem; font-weight:800; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; color:#fff; text-shadow:0 1px 2px #18352b; }
.racer { position:absolute; width:min(84%,92px); height:100px; left:8%; bottom:1%; transition:none; will-change:transform; filter:drop-shadow(0 5px 2px rgba(24,53,43,.25)); }
.racer .snail-art { width:100%; height:100%; display:block; }
.finish-line,.start-line { position:absolute; z-index:4; left:0; right:0; height:34px; display:grid; place-items:center; font:800 .63rem 'DM Sans',sans-serif; letter-spacing:.18em; color:var(--ink); background:repeating-linear-gradient(90deg,#fff 0 18px,#222 18px 36px); }.finish-line { top:0; }.start-line { bottom:0; }.finish-line span,.start-line span { background:var(--gold); padding:2px 8px; border:2px solid var(--ink); }
.countdown { position:absolute; z-index:8; inset:0; display:grid; place-items:center; pointer-events:none; font:800 clamp(5rem,28vw,9rem) 'Fraunces',serif; color:var(--gold); text-shadow:6px 6px 0 var(--ink); }
.race-results { position:absolute; z-index:12; inset:auto 12px 12px; border-radius:20px; padding:18px; background:var(--cream); color:var(--ink); box-shadow:var(--shadow); max-height:72dvh; overflow:auto; }.race-results h2 { font:800 1.8rem 'Fraunces',serif; margin:0 0 3px; }.race-results ol { margin:14px 0; padding:0; list-style:none; }.race-results li { display:flex; justify-content:space-between; border-bottom:1px solid var(--line); padding:9px 0; }.race-results .action-grid { margin-top:10px; }
.toast { position:fixed; z-index:100; left:50%; bottom:88px; translate:-50% 0; width:min(calc(100% - 32px),420px); padding:12px 16px; border-radius:12px; background:var(--ink); color:white; box-shadow:var(--shadow); text-align:center; font-weight:700; }
.danger-note { color:#9d362e; font-size:.78rem; }.fine-print { color:var(--muted); font-size:.73rem; line-height:1.4; }
noscript { display:block; padding:20px; }

@media (min-width:760px) {
  .app-shell { padding-bottom:0; padding-left:110px; }.topbar { padding-left:26px; }.bottom-nav { top:0; bottom:0; right:auto; width:110px; height:auto; grid-template-columns:1fr; grid-template-rows:repeat(4,82px); align-content:center; border-top:0; border-right:1px solid var(--line); padding:12px; }.bottom-nav button { height:70px; }.main-view { padding-top:38px; }.drawer { inset:0 0 0 auto; width:min(470px,45vw); height:100dvh; border-radius:26px 0 0 26px; transform:translateX(105%); }.drawer.open { transform:translateX(0); }.drawer-top { padding-top:12px; }.drawer-handle { display:none; }.race-stage { padding:16px; }.track-wrap { max-height:calc(100dvh - 96px); }
}
@media (max-width:360px) { .brand small { display:none; }.main-view { padding-inline:10px; }.card { padding:11px; gap:10px; }.snail-thumb { width:58px; flex-basis:58px; }.stats-grid { gap:5px; }.drawer-content { padding-inline:14px; } }
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { scroll-behavior:auto!important; animation-duration:.001ms!important; transition-duration:.001ms!important; } }
