/* Blueberry Brawler — one deliberate dark look (night grove), no light theme.
   Layout: full-screen pixel canvas, thin HUD on top, thumb controls bottom-right, pixel-bordered panels. */
:root {
  --night: #0e1912; --moss: #1b2e20; --moss2: #24402b; --moss3: #2f5236; --leaf: #9fd05e; --bark: #8b5434;
  --berry: #4a7be0; --berry-hi: #8fb8ff; --brass: #d9a83a; --ember: #e8673a; --ink: #ecf2df; --dim: #9db394; --line: #0a110c; --soil: #2c1c15;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--night); color: var(--ink); }
body { font-family: var(--mono); font-size: 15px; line-height: 1.35; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#c { position: fixed; left: 0; top: 0; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
button { font-family: var(--mono); color: var(--ink); cursor: pointer; font-weight: 700; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
button:disabled { cursor: not-allowed; }
.px { background: var(--moss); box-shadow: 0 0 0 2px var(--line), inset 0 0 0 2px var(--moss2), inset 0 -4px 0 2px rgba(0,0,0,.25); }
h1, h2, h3 { margin: 0; text-wrap: balance; line-height: 1.05; letter-spacing: .02em; }
h2 { font-size: 20px; text-transform: uppercase; }
h3 { font-size: 17px; }
p { margin: 0; max-width: 64ch; }
.dim { color: var(--dim); }
.small { font-size: 13px; }
.eyebrow { font-size: 11px; letter-spacing: .12em; color: var(--brass); font-weight: 700; }

/* HUD */
#hud { position: fixed; left: 0; right: 0; top: 0; padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 0; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.hrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hp { position: relative; width: min(46vw, 200px); height: 16px; background: #2a1612; box-shadow: 0 0 0 2px var(--line); }
#hpbar { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#b6e070 0 40%, #6fae3e 40%); width: 100%; }
#hptxt { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: #fff; text-shadow: 1px 1px 0 #000; font-weight: 700; }
.stat { font-size: 12px; letter-spacing: .06em; text-shadow: 1px 1px 0 #000; display: flex; align-items: center; gap: 4px; font-weight: 700; }
.stat b { font-size: 14px; font-variant-numeric: tabular-nums; }
.stat img { width: 12px; height: auto; image-rendering: pixelated; }
.stat.biome { color: var(--dim); font-weight: 400; }
.chip-rooted { font-size: 11px; font-weight: 700; letter-spacing: .1em; padding: 2px 6px; background: var(--bark); color: #fff3d8; box-shadow: 0 0 0 2px var(--line); }
#pauseBtn { pointer-events: auto; margin-left: auto; width: 36px; height: 30px; font-size: 12px; border: 0; }
.bossbar { align-self: center; width: min(80vw, 360px); display: flex; flex-direction: column; gap: 3px; align-items: center; margin-top: 4px; }
.bossbar span { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brass); text-shadow: 1px 1px 0 #000; }
.bossbar div { width: 100%; height: 8px; background: #2a1612; box-shadow: 0 0 0 2px var(--line); }
.bossbar i { display: block; height: 100%; width: 100%; background: linear-gradient(#ffe27a 0 40%, var(--brass) 40%); }
#banner { position: fixed; left: 16px; right: 16px; top: 30%; text-align: center; font-size: clamp(26px, 7vw, 44px); font-weight: 800; color: var(--ink); text-shadow: 3px 3px 0 var(--line), -1px -1px 0 var(--line); opacity: 0; pointer-events: none; letter-spacing: .04em; }
#banner small { display: block; font-weight: 400; font-size: 17px; color: var(--leaf); margin-top: 6px; letter-spacing: 0; }
#banner.show { animation: ban 1.9s steps(12) forwards; }
@keyframes ban { 0% { opacity: 0; transform: translateY(8px); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; } }

/* touch controls */
#ctrl { position: fixed; inset: 0; pointer-events: none; }
#joy { position: fixed; width: 96px; height: 96px; margin: -48px 0 0 -48px; border-radius: 50%; background: rgba(236,242,223,.08); box-shadow: 0 0 0 2px rgba(236,242,223,.25); }
#knob { position: absolute; left: 28px; top: 28px; width: 40px; height: 40px; border-radius: 50%; background: rgba(143,184,255,.55); box-shadow: 0 0 0 2px var(--line); }
#pad { position: fixed; right: 14px; bottom: calc(env(safe-area-inset-bottom, 0px) + 14px); display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none; }
#chips { display: flex; gap: 6px; pointer-events: auto; flex-wrap: wrap; justify-content: flex-end; max-width: 80vw; }
.chip { width: 42px; height: 42px; border: 0; padding: 0; display: grid; place-items: center; position: relative; opacity: .55; }
.chip img { width: 26px; image-rendering: pixelated; }
.chip span { position: absolute; right: 3px; bottom: 1px; font-size: 11px; text-shadow: 1px 1px 0 #000; }
.chip.on { opacity: 1; box-shadow: 0 0 0 2px var(--line), inset 0 0 0 2px var(--leaf); }
.btns { display: flex; gap: 12px; pointer-events: auto; }
.big { width: 78px; height: 78px; border: 0; border-radius: 50%; position: relative; overflow: hidden; font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; box-shadow: 0 0 0 3px var(--line), inset 0 -6px 0 rgba(0,0,0,.3); }
#burstBtn { background: var(--berry); }
#rideBtn { background: #7a5030; }
#offBtn { align-self: flex-end; }
#plantBtn { background: #4c7f34; }
.big .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(10,17,12,.6); }
.big small { font-size: 11px; opacity: .9; font-weight: 400; }
.big.off { filter: grayscale(.7) brightness(.75); }

/* panels */
.ov { position: fixed; inset: 0; display: grid; place-items: center; padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px); background: rgba(8,14,10,.72); overflow-y: auto; touch-action: pan-y; }
.panel { width: 100%; max-width: 460px; padding: 20px 18px; display: flex; flex-direction: column; gap: 14px; box-sizing: border-box; min-width: 0; }
.panel.wide { max-width: 720px; }
.phead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
#logo { width: 100%; max-width: 420px; height: auto; align-self: center; }
.cast { display: flex; align-items: flex-end; justify-content: center; gap: 12px; padding: 8px 0 4px; flex-wrap: wrap; background: linear-gradient(transparent 70%, rgba(0,0,0,.25) 70%); }
.cast figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cast figcaption { font-size: 10px; color: var(--dim); letter-spacing: .05em; text-transform: uppercase; }
.go { border: 0; background: var(--berry); font-size: 14px; padding: 13px 14px; box-shadow: 0 0 0 2px var(--line), inset 0 -5px 0 rgba(0,0,0,.3); text-transform: uppercase; letter-spacing: .04em; }
.go:active:not(:disabled) { transform: translateY(2px); }
.go:disabled { filter: grayscale(.8) brightness(.7); }
.go small { font-size: 11px; color: var(--brass); }
.ghost { background: var(--moss2); }
.mini { border: 0; background: var(--berry); font-size: 12px; padding: 7px 10px; box-shadow: 0 0 0 2px var(--line); }
.mini.ghost { background: var(--moss2); }
.menu3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.menu3 .go { padding: 11px 6px; font-size: 12px; }
@media (max-width: 420px) { .menu3 { grid-template-columns: 1fr; } }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.keys b { font-size: 11px; color: var(--brass); padding-top: 2px; }
.cards { display: flex; flex-direction: column; gap: 10px; }
.card { border: 0; text-align: left; display: grid; grid-template-columns: 44px 1fr; gap: 4px 12px; align-items: center; padding: 12px; background: var(--moss2); box-shadow: 0 0 0 2px var(--line), inset 0 -4px 0 rgba(0,0,0,.25); }
.card:hover:not(:disabled), .card:focus-visible { background: var(--moss3); }
.card img { grid-row: span 2; width: 40px; image-rendering: pixelated; justify-self: center; }
.card .t { font-size: 15px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card .t i { font-style: normal; font-size: 10px; color: var(--brass); letter-spacing: .06em; }
.card .d { font-size: 13px; color: var(--dim); font-weight: 400; }
.card:disabled { opacity: .45; }
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.statgrid div { background: var(--moss2); padding: 8px 10px; box-shadow: 0 0 0 2px var(--line); }
.statgrid b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.statgrid span { font-size: 13px; color: var(--dim); }
.sapgain { font-weight: 700; color: var(--brass); }
.row2 { display: flex; gap: 10px; flex-wrap: wrap; }
.row2 .go { flex: 1 1 140px; }
.credit { font-size: 12px; color: var(--dim); border-top: 2px dashed var(--moss2); padding-top: 10px; }
.note { background: #3a2418; padding: 8px 10px; box-shadow: 0 0 0 2px var(--line); font-size: 13px; }

/* Root System */
.sap { text-align: right; display: flex; flex-direction: column; align-items: flex-end; }
.sap b { font-size: 28px; color: var(--brass); font-variant-numeric: tabular-nums; line-height: 1; }
.sap span { font-size: 11px; letter-spacing: .1em; color: var(--dim); text-transform: uppercase; }
.soil { position: relative; width: 100%; height: min(54vh, 460px); min-height: 280px; box-shadow: 0 0 0 2px var(--line); background: var(--soil); overflow: hidden; }
#rootCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#rootNodes { position: absolute; inset: 0; }
.rnode { position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border: 0; border-radius: 50%; padding: 0; background: #3a2618; box-shadow: 0 0 0 2px var(--line), inset 0 0 0 3px #5a3a24; display: grid; place-items: center; }
.rnode::before { content: ""; width: 10px; height: 12px; border-radius: 50% 50% 45% 45%; background: #6a4a30; }
.rnode.avail { box-shadow: 0 0 0 2px var(--line), inset 0 0 0 3px var(--bc); }
.rnode.avail::before { background: #c9a46a; }
.rnode.owned, .rnode.max { background: #2f5236; box-shadow: 0 0 0 2px var(--line), inset 0 0 0 3px var(--bc); }
.rnode.owned::before, .rnode.max::before { background: var(--leaf); border-radius: 50% 0 50% 0; width: 12px; height: 12px; }
.rnode.max { box-shadow: 0 0 0 2px var(--line), inset 0 0 0 3px var(--bc), 0 0 12px 2px rgba(159,208,94,.45); }
.rnode.locked { opacity: .5; }
.rnode.buyable { animation: pulse 1.4s steps(4) infinite; }
.rnode.sel { outline: 2px solid var(--ink); outline-offset: 3px; }
@keyframes pulse { 50% { transform: translateY(-2px); } }
.pips { position: absolute; bottom: -9px; display: flex; gap: 2px; }
.pips i { width: 5px; height: 5px; background: var(--leaf); box-shadow: 0 0 0 1px var(--line); }
.pips i.e { background: #3a2618; }
#rFlash { position: absolute; left: 0; right: 0; top: 8px; text-align: center; font-weight: 800; color: var(--leaf); text-shadow: 2px 2px 0 var(--line); opacity: 0; pointer-events: none; padding-inline: 12px; }
#rFlash.show { animation: ban 2.4s steps(12) forwards; }
.rdetail { display: grid; gap: 6px; background: var(--moss2); padding: 12px; box-shadow: 0 0 0 2px var(--line); }
.rdetail .go { margin-top: 4px; }

/* Bestiary */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { border: 0; background: var(--moss2); padding: 8px 12px; font-size: 12px; box-shadow: 0 0 0 2px var(--line); text-transform: uppercase; letter-spacing: .05em; }
.tab.on { background: var(--bark); }
.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.bcell { border: 0; background: var(--moss2); padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: 0 0 0 2px var(--line); min-height: 86px; justify-content: flex-end; }
.bcell span { font-size: 11px; font-weight: 400; text-align: center; line-height: 1.15; }
.bcell.on { background: var(--moss3); box-shadow: 0 0 0 2px var(--line), inset 0 0 0 2px var(--brass); }
.bcell.unknown span { color: var(--dim); }
.bdetail { display: grid; grid-template-columns: minmax(0, 140px) minmax(0, 1fr); gap: 16px; background: var(--moss2); padding: 14px; box-shadow: 0 0 0 2px var(--line); align-items: start; }
.bart { display: grid; place-items: center; min-height: 120px; background: radial-gradient(circle at 50% 70%, #2f5236, transparent 70%); }
.binfo { display: grid; gap: 8px; min-width: 0; }
.bstats { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; margin: 4px 0 0; }
.bstats div { background: var(--moss); padding: 6px 8px; }
.bstats dt { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
.bstats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) { .bdetail { grid-template-columns: 1fr; } }

/* Workshop */
.wsgroup { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--brass); margin-top: 6px; }
#wsList { display: flex; flex-direction: column; gap: 8px; }
.wsrow { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px; align-items: center; background: var(--moss2); padding: 8px; box-shadow: 0 0 0 2px var(--line); }
.wspic { width: 56px; height: 48px; display: grid; place-items: center; background: var(--moss); }
.wsinfo { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wsinfo .dim { font-size: 12px; overflow-wrap: anywhere; }
.wsacts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge { align-self: flex-start; font-size: 10px; padding: 1px 6px; letter-spacing: .06em; text-transform: uppercase; background: var(--moss); }
.b-device { background: var(--berry); } .b-server { background: var(--bark); } .b-repo { background: #4c7f34; }
@media (max-width: 480px) { .wsrow { grid-template-columns: 56px minmax(0, 1fr); } .wsacts { grid-column: 1 / -1; justify-content: flex-start; } }
#wsEditor { display: flex; flex-direction: column; gap: 12px; }
.weview { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
#wePreview { width: 240px; max-width: 100%; height: auto; box-shadow: 0 0 0 2px var(--line); }
.weview .small { flex: 1 1 160px; }
.form { display: grid; gap: 10px; }
.form label { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 10px; align-items: center; font-size: 14px; }
.form label.check { grid-template-columns: auto 1fr; }
.form input[type=number] { font-family: var(--mono); font-size: 15px; background: var(--moss); color: var(--ink); border: 0; box-shadow: 0 0 0 2px var(--line); padding: 6px 8px; width: 100%; box-sizing: border-box; }
.form input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--leaf); }
.form input[type=range] { width: 100%; accent-color: var(--leaf); }
.wsfoot { border-top: 2px dashed var(--moss2); padding-top: 12px; }

@media (prefers-reduced-motion: reduce) { #banner.show, #rFlash.show { animation: none; opacity: 1; } .rnode.buyable { animation: none; } }

/* milestone 1: build mode, chip costs, toasts */
.chip em { position: absolute; left: 0; right: 0; top: -14px; font-style: normal; font-size: 10px; font-weight: 700; color: var(--brass); text-shadow: 1px 1px 0 #000; white-space: nowrap; text-align: center; }
.chip.mode { width: auto; padding: 0 8px; font-size: 11px; letter-spacing: .06em; opacity: 1; background: var(--bark); }
#chips { margin-top: 14px; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 92px); max-width: calc(100vw - 32px); box-sizing: border-box; padding: 6px 12px; background: var(--moss); box-shadow: 0 0 0 2px var(--line); font-size: 13px; pointer-events: none; text-align: center; }
#toast.show { animation: toastIn .2s steps(3); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -6px); } }
.rnode.keystone { width: 38px; height: 38px; margin: -19px 0 0 -19px; border-radius: 4px; outline: 2px dashed var(--bc); outline-offset: 2px; }
.rnode.keystone.sel { outline: 2px solid var(--ink); }
.rnode.sealed { opacity: .28; filter: grayscale(1); }
.soil { height: max(80vh, 720px); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; box-shadow: 0 0 0 1px var(--line); }
.rdetail { position: sticky; bottom: 0; z-index: 2; box-shadow: 0 0 0 2px var(--line), 0 -8px 16px rgba(0,0,0,.35); }
