:root {
  --ink: #292a23;
  --ink-2: #34352c;
  --cream: #f6f5ee;
  --lime: #d8fd71;
  --wood: #6b3519;
  --wood-hi: #8a4a24;
  --wood-lo: #3f1e0d;
  --pit: #2a1409;
  --pit-hi: #4a2512;
  --gold: #f2b84b;
  --red: #d9503a;
  --green: #4fa36b;
  --muted: rgba(246, 245, 238, .62);
  --radius: 18px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #3c3d31 0%, transparent 70%),
    var(--ink);
  color: var(--cream);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  min-height: 100vh;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, .pit:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; }

/* header + start.ng profile card */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0 8px; max-width: 980px; margin: 0 auto; }
.startng-card { display: flex; align-items: center; gap: 12px; padding: 6px 14px 6px 6px; border-radius: 999px; background: #1f2019; border: 1px solid rgba(255,255,255,.08); min-width: 0; }
.startng-card img { width: 44px; height: 44px; border-radius: 50%; background: var(--lime); flex: none; object-fit: cover; }
.startng-card .who { min-width: 0; }
.startng-card b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.startng-card span { font-size: 12px; opacity: .7; }
.startng-card button { margin-left: 4px; border: 0; border-radius: 999px; padding: 6px 12px; background: var(--lime); color: var(--ink); font-weight: 700; font-size: 13px; }
.top-actions { display: flex; gap: 8px; }
.icon { width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,.14); background: transparent; font-weight: 700; font-size: 16px; }
.icon:hover { background: rgba(255,255,255,.08); }

main { max-width: 980px; margin: 0 auto; padding-bottom: 32px; }
.screen { animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* menu */
.logo { text-align: center; padding: 28px 0 18px; }
.logo-seeds { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; }
.logo-seeds i { width: 16px; height: 22px; border-radius: 50% 50% 46% 46%; background: var(--cream); box-shadow: inset -3px -4px 0 rgba(0,0,0,.18); animation: bob 2.4s ease-in-out infinite; }
.logo-seeds i:nth-child(2) { background: var(--gold); animation-delay: .15s; }
.logo-seeds i:nth-child(3) { background: var(--red); animation-delay: .3s; }
.logo-seeds i:nth-child(4) { background: var(--green); animation-delay: .45s; }
.logo-seeds i:nth-child(5) { background: var(--lime); animation-delay: .6s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
h1 { font-family: var(--serif); font-size: clamp(44px, 11vw, 76px); line-height: 1; margin: 0; letter-spacing: -.02em; }
h1 em { font-style: italic; color: var(--lime); }
.tag { max-width: 440px; margin: 14px auto 0; color: var(--muted); line-height: 1.5; }
.menu-buttons { display: grid; gap: 12px; max-width: 420px; margin: 10px auto 0; }
.btn { border: 1px solid rgba(255,255,255,.16); background: var(--ink-2); border-radius: var(--radius); padding: 16px 20px; font-size: 18px; font-weight: 700; text-align: left; transition: transform .12s, background .12s; }
.btn small { display: block; font-weight: 400; font-size: 13px; color: var(--muted); margin-top: 3px; }
.btn:hover { transform: translateY(-1px); background: #3d3e33; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--lime); color: var(--ink); border-color: var(--lime); }
.btn.primary small { color: rgba(41,42,35,.72); }
.btn.primary:hover { background: #e4ff93; }
.btn.ghost { background: transparent; text-align: center; }
.btn.small { padding: 9px 16px; font-size: 14px; }
.best { text-align: center; color: var(--muted); font-size: 14px; min-height: 20px; margin-top: 18px; }

/* game */
.opp-row { display: flex; align-items: center; gap: 12px; padding: 8px 0 12px; position: relative; }
.opp-avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--wood-hi); display: grid; place-items: center; font-size: 28px; flex: none; border: 2px solid rgba(255,255,255,.12); }
.opp-info b { display: block; font-family: var(--serif); font-size: 20px; }
.opp-info span { font-size: 13px; color: var(--muted); }
.bubble { margin-left: auto; max-width: 52%; background: var(--cream); color: var(--ink); padding: 9px 13px; border-radius: 14px 14px 14px 4px; font-size: 14px; line-height: 1.3; animation: pop .25s ease both; }
@keyframes pop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }

.table { display: flex; flex-direction: column; gap: 10px; }
.store { background: linear-gradient(180deg, var(--wood-lo), #2e1608); border-radius: var(--radius); border: 2px solid rgba(0,0,0,.35); box-shadow: inset 0 3px 10px rgba(0,0,0,.5); display: flex; align-items: center; gap: 12px; padding: 8px 16px; min-height: 52px; }
.store-label { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); z-index: 1; }
.store-count { font-family: var(--serif); font-size: 30px; z-index: 1; margin-left: auto; text-shadow: 0 2px 6px rgba(0,0,0,.9), 0 0 2px #000; }
.store-seeds { position: absolute; inset: 0; pointer-events: none; opacity: .9; }
.store.flash { animation: storeflash .6s ease; }
@keyframes storeflash { 0% { box-shadow: inset 0 3px 10px rgba(0,0,0,.5), 0 0 0 0 var(--lime); } 40% { box-shadow: inset 0 3px 10px rgba(0,0,0,.5), 0 0 0 6px var(--lime); } 100% { box-shadow: inset 0 3px 10px rgba(0,0,0,.5), 0 0 0 0 transparent; } }

.stage { position: relative; width: 100%; aspect-ratio: 16 / 8; border-radius: 24px; overflow: hidden; touch-action: manipulation;
  background: radial-gradient(70% 90% at 50% 45%, #4a4b3b 0%, #33342a 60%, #2a2b23 100%); border: 1px solid rgba(255,255,255,.07); }
.stage canvas { display: block; width: 100%; height: 100%; outline: none; }
.plabels { position: absolute; inset: 0; pointer-events: none; }
.plabel { position: absolute; transform: translate(-50%, -50%); font-size: 12px; font-weight: 700; line-height: 1; background: rgba(0,0,0,.62); color: #fff; border-radius: 999px; padding: 3px 7px; }
.stage .fail { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--muted); line-height: 1.5; }
@media (max-width: 700px) { .stage { aspect-ratio: 3 / 4; } }

.status { text-align: center; min-height: 26px; margin: 14px 0 6px; color: var(--cream); font-size: 16px; }
.status b { color: var(--lime); }
.game-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.runstats { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: #1f2019; border: 1px solid rgba(255,255,255,.1); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--muted); }
.chip b { color: var(--cream); }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(15,16,12,.72); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .2s ease both; backdrop-filter: blur(3px); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--cream); color: var(--ink); border-radius: 24px; padding: 24px; width: min(460px, 100%); max-height: 88vh; overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.5); animation: pop .25s ease both; }
.modal h2 { font-family: var(--serif); font-size: 30px; margin: 0 0 6px; }
.modal p { line-height: 1.5; margin: 8px 0; }
.modal ul { padding-left: 20px; line-height: 1.5; }
.modal li { margin: 6px 0; }
.modal .row { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal .btn { background: var(--ink); color: var(--cream); border-color: var(--ink); text-align: center; font-size: 16px; padding: 12px 18px; flex: 1; }
.modal .btn:hover { background: #3d3e33; }
.modal .btn.primary { background: var(--ink); }
.modal .btn.light { background: transparent; color: var(--ink); border-color: rgba(41,42,35,.3); }
.modal .big { font-family: var(--serif); font-size: 52px; line-height: 1; margin: 4px 0; }
.modal .nudge { background: #ecebdf; border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.lb { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 15px; }
.lb th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: rgba(41,42,35,.6); padding: 4px 6px; }
.lb td { padding: 8px 6px; border-top: 1px solid rgba(41,42,35,.1); }
.lb td:first-child { width: 34px; font-weight: 700; }
.lb tr.me td { background: var(--lime); }
.lb td.num, .lb th.num { text-align: right; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* error bar */
.errbar { position: sticky; top: 0; z-index: 99; background: #b3261e; color: #fff; padding: 10px 16px; font-size: 14px; line-height: 1.4; }

/* how to play (menu) */
.howto { max-width: 560px; margin: 34px auto 0; background: #1f2019; border: 1px solid rgba(255,255,255,.08); border-radius: 22px; padding: 22px 22px 8px; }
.howto h2 { font-family: var(--serif); font-size: 26px; margin: 0 0 12px; color: var(--lime); }
.steps { list-style: none; counter-reset: s; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 16px 44px; line-height: 1.5; color: var(--cream); font-size: 15px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--lime); color: var(--ink); font-weight: 800; display: grid; place-items: center; }
.steps b { color: var(--lime); font-weight: 700; }

/* quick rules (game screen) */
.quick { margin: 4px 0 14px; background: #1f2019; border: 1px solid rgba(255,255,255,.08); border-radius: 14px; padding: 10px 14px; font-size: 14px; color: var(--muted); }
.quick summary { cursor: pointer; font-weight: 700; color: var(--cream); }
.quick ul { margin: 8px 0 2px; padding-left: 18px; line-height: 1.5; }
