:root {
  --bg: #0f2417; --bg2: #0b1c12; --panel: #183524; --raise: #1f4530; --line: #071109;
  --text: #eaf5e4; --dim: #9db8a3; --gold: #f5c542; --leaf: #6bd14a; --red: #ff6b5e; --blue: #5ec8ff; --purple: #b06bd6; --pink: #ff5ecb;
  --trip: linear-gradient(90deg, #ff5ecb, #ffb347, #f9f871, #7df29b, #4de1ff, #9b6bff, #ff5ecb);
  --pix: 'Press Start 2P', ui-monospace, 'Courier New', monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg2); color: var(--text); font: 16px/1.45 var(--sans); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
h1, h2, h3 { font-family: var(--pix); font-weight: 400; margin: 0; line-height: 1.5; text-wrap: balance; }
h1 { font-size: 14px; color: var(--gold); }
h2 { font-size: 12px; color: var(--gold); margin: 24px 0 10px; text-transform: uppercase; }
h3 { font-size: 11px; }
a { color: inherit; text-decoration: none; }
small, .dim { color: var(--dim); }
code { font-size: 13px; background: var(--bg2); padding: 1px 5px; }
.pix { font-family: var(--pix); font-size: 10px; }
.num { font-variant-numeric: tabular-nums; }
canvas.px, img.px { image-rendering: pixelated; image-rendering: crisp-edges; }
.tripline { height: 4px; background: var(--line); }
.triptext { color: var(--gold); }

#app { display: grid; grid-template-rows: auto 1fr; min-height: 100dvh; background: var(--bg); }
#top { position: sticky; top: 0; z-index: 5; background: var(--bg2); padding-top: env(safe-area-inset-top); }
#top .topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
#top .logo { width: 34px; height: 34px; box-shadow: 0 0 0 3px var(--line); }
#top .sub { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#top h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow { flex: 1; min-width: 0; }
.dot { width: 10px; height: 10px; background: var(--leaf); box-shadow: 0 0 0 2px var(--line); flex: none; }
.dot.off { background: var(--red); } .dot.busy { background: var(--gold); }
.me { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.me canvas { width: 20px; height: 28px; }
.switch { display: flex; gap: 10px; padding: 2px 16px 12px; overflow-x: auto; }
.switch button { font-family: var(--pix); font-size: 9px; color: var(--dim); background: var(--panel); border: 0; box-shadow: 0 0 0 3px var(--line); padding: 9px 12px; cursor: pointer; white-space: nowrap; }
.switch button.on { color: #1a1205; background: var(--gold); }

#main { padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 1100px; width: 100%; margin: 0 auto; }
#nav { position: fixed; z-index: 6; bottom: 0; left: 0; right: 0; display: flex; background: var(--bg2); border-top: 4px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 2px 8px; font-family: var(--pix); font-size: 8px; color: var(--dim); }
#nav a span { font-size: 20px; line-height: 1; filter: grayscale(.6); }
#nav a.on { color: var(--gold); background: var(--panel); } #nav a.on span { filter: none; }
@media (min-width: 900px) {
  #app { grid-template-columns: 200px 1fr; }
  #top { grid-column: 1 / -1; }
  #nav { position: sticky; top: 110px; align-self: start; flex-direction: column; border-top: 0; border-right: 4px solid var(--line); min-height: calc(100dvh - 110px); padding: 12px 0; }
  #nav a { flex: none; flex-direction: row; gap: 12px; padding: 14px 18px; font-size: 10px; }
  #main { padding-bottom: 40px; grid-column: 2; }
  #app[data-view="login"] #main, #app[data-view="wizard"] #main { grid-column: 1 / -1; }
}

.card { display: block; background: var(--panel); border: 4px solid var(--line); box-shadow: inset 0 0 0 2px rgba(255,255,255,.05); padding: 14px; margin-bottom: 14px; }
.card.tight { padding: 10px 12px; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid .card { margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-family: var(--pix); font-size: 10px; line-height: 1.4; color: #1a1205; background: var(--gold); border: 0; padding: 12px 14px; cursor: pointer; box-shadow: 0 4px 0 #8a6a12, 0 0 0 3px var(--line); margin: 3px 3px 7px; min-height: 40px; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #8a6a12, 0 0 0 3px var(--line); }
.btn.green { background: var(--leaf); box-shadow: 0 4px 0 #2f7a1f, 0 0 0 3px var(--line); }
.btn.ghost { background: var(--raise); color: var(--text); box-shadow: 0 4px 0 #0e2416, 0 0 0 3px var(--line); }
.btn.red { background: var(--red); box-shadow: 0 4px 0 #8f2d25, 0 0 0 3px var(--line); }
.btn.small { padding: 8px 10px; font-size: 8px; min-height: 32px; }
.btn.block { display: flex; width: calc(100% - 6px); }
.btn:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }

.scene { display: block; width: 100%; height: 160px; border: 4px solid var(--line); background: #1b1440; }
@media (min-width: 600px) { .scene { height: 240px; } }
@media (min-width: 1000px) { .scene { height: 320px; } }
.stages { display: flex; margin: -4px 0 14px; border: 4px solid var(--line); background: var(--bg2); }
.stages div { flex: 1; text-align: center; padding: 7px 2px; font-family: var(--pix); font-size: 7px; color: var(--dim); border-right: 2px solid var(--line); overflow: hidden; white-space: nowrap; }
.stages div:last-child { border: 0; }
.stages div.done { color: var(--leaf); } .stages div.now { background: var(--gold); color: #1a1205; }
.stages div span { display: block; font-size: 16px; margin-bottom: 4px; }
.stages b { font-weight: 400; }
@media (max-width: 520px) { .stages div b { display: none; } .stages div span { margin: 0; } }

.bar { height: 12px; background: var(--bg2); border: 2px solid var(--line); }
.bar i { display: block; height: 100%; background: var(--leaf); }
.bar.gold i, .bar.trip i { background: var(--gold); }
.big { font-family: var(--pix); font-size: 18px; color: var(--text); }
.stat .big { display: block; margin: 4px 0; }
.ok { color: var(--leaf); } .warn { color: var(--gold); } .bad { color: var(--red); }

.quest { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--raise); border: 0; border-left: 6px solid var(--gold); padding: 12px; margin-bottom: 8px; cursor: pointer; }
.quest span { font-size: 22px; } .quest em { font-style: normal; font-family: var(--pix); font-size: 8px; color: var(--gold); white-space: nowrap; }

.chip { display: inline-block; font-size: 12px; padding: 3px 8px; background: var(--bg2); border: 2px solid var(--line); color: var(--dim); white-space: nowrap; }
.chip.on, .chip.keeper { background: var(--gold); color: #1a1205; } .chip.culled { color: var(--red); } .chip.live { color: var(--leaf); }
button.chip { cursor: pointer; font: inherit; font-size: 13px; padding: 7px 11px; color: var(--text); min-height: 34px; }
button.chip.on { color: #1a1205; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.plant { padding: 0; overflow: hidden; }
.plant .thumb { height: 96px; background: var(--bg2) center/cover; display: grid; place-items: center; font-size: 36px; border-bottom: 4px solid var(--line); }
.plant .body { padding: 10px; }
.plant .code { font-family: var(--pix); font-size: 11px; color: var(--gold); }
.plant.culled { opacity: .5; }
.score { font-family: var(--pix); font-size: 12px; color: var(--leaf); }

.list > * { border-bottom: 2px solid var(--line); padding: 10px 0; } .list > *:first-child { padding-top: 0; } .list > *:last-child { border: 0; padding-bottom: 0; }
.entry { display: flex; gap: 10px; align-items: flex-start; }
.entry .ico { font-size: 22px; width: 30px; text-align: center; flex: none; }
.entry p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.who { font-weight: 600; } .who.p1 { color: var(--gold); } .who.p2 { color: var(--red); } .who.p3 { color: var(--blue); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photos.mini { grid-template-columns: repeat(auto-fill, 64px); margin-top: 8px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border: 3px solid var(--line); display: block; cursor: pointer; }
.trait { display: grid; grid-template-columns: minmax(90px, 34%) 1fr 34px; align-items: center; gap: 8px; font-size: 14px; margin: 6px 0; }
.rank { display: grid; grid-template-columns: 34px minmax(80px, auto) 1fr 44px; gap: 10px; align-items: center; }
.rank .pos { font-family: var(--pix); font-size: 12px; text-align: center; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 12px; }

/* forms + sheets */
label { display: block; font-size: 13px; color: var(--dim); margin: 10px 0 4px; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--bg2); border: 3px solid var(--line); padding: 10px; border-radius: 0; }
textarea { min-height: 80px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
#sheet { position: fixed; inset: 0; z-index: 20; background: rgba(4,10,6,.75); display: flex; align-items: flex-end; justify-content: center; }
#sheet-card { background: var(--panel); border: 4px solid var(--line); border-bottom: 0; width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { #sheet { align-items: center; } #sheet-card { border-bottom: 4px solid var(--line); } }
#sheet-card > h2:first-child, #sheet-card > .row:first-child h2 { margin-top: 0; }
.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.types button { font: inherit; font-size: 12px; color: var(--text); background: var(--bg2); border: 3px solid var(--line); padding: 10px 4px; cursor: pointer; }
.types button span { display: block; font-size: 24px; } .types button.on { background: var(--gold); color: #1a1205; }
.ten { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.ten button { font-family: var(--pix); font-size: 9px; padding: 0; height: 36px; color: var(--dim); background: var(--bg2); border: 2px solid var(--line); cursor: pointer; }
.ten button.on { background: var(--leaf); color: #0b1c12; }
.ten button.on.top { background: var(--gold); }
.ten.pos button.on { background: var(--purple); color: #fff; }
.scale { position: relative; height: 12px; background: var(--bg2); border: 2px solid var(--line); margin-bottom: 14px; }
.scale.color { background: linear-gradient(90deg, var(--purple), var(--leaf)); }
.scale i { position: absolute; top: -4px; width: 6px; height: 16px; margin-left: -3px; background: var(--gold); box-shadow: 0 0 0 2px var(--line); }
.scale small { position: absolute; top: 12px; font-size: 10px; } .scale small:last-child { right: 0; }
.filebtn { margin-top: 12px; color: var(--text); }
.filebtn input { position: absolute; opacity: 0; width: 1px; height: 1px; }
#toast { position: fixed; z-index: 30; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--gold); color: #1a1205; font-family: var(--pix); font-size: 10px; line-height: 1.6; padding: 12px 16px; border: 4px solid var(--line); max-width: 90vw; text-align: center; }

.login, .wizard { max-width: 460px; margin: 0 auto; padding: 20px 0; }
.login { text-align: center; }
.brandname { font: 400 20px/1.4 var(--pix); margin: 18px 0 6px; }
.pick { display: flex; justify-content: center; gap: 12px; margin: 10px 0 18px; }
.pick button { background: var(--panel); border: 4px solid var(--line); padding: 12px 6px 8px; cursor: pointer; color: var(--text); font: inherit; font-size: 13px; flex: 1; }
.pick button.on { background: var(--raise); border-color: var(--gold); }
.pick canvas { width: 50px; height: 70px; display: block; margin: 0 auto 6px; }
.lightbox { width: 100%; max-height: 70dvh; object-fit: contain; background: #000; }
@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }
