/* NanoNano: chunky pixel UI around a full-bleed map. Colours are the game palette. */
:root {
  --night: #111d35; --ink: #000; --blue: #1d2b53; --cyan: #29adff; --white: #fff1e8;
  --grey: #5f574f; --light: #c2c3c7; --lav: #83769c; --yellow: #ffec27; --orange: #ffa300;
  --red: #ff004d; --green: #00e436; --brown: #742f29;
  --px: 2px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--white); overflow: hidden; }
body {
  font: bold 13px/1.35 ui-monospace, "Cascadia Mono", "DejaVu Sans Mono", Menlo, monospace;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
#app { display: grid; grid-template-rows: auto 1fr auto auto; height: 100dvh; padding-top: env(safe-area-inset-top); }
button {
  font: inherit; color: var(--white); background: var(--blue); border: 0; padding: 8px 10px; cursor: pointer;
  box-shadow: inset calc(-1 * var(--px)) calc(-1 * var(--px)) 0 var(--ink), inset var(--px) var(--px) 0 #3a4a8a;
  text-transform: uppercase; letter-spacing: .03em; min-height: 40px;
}
button:active:not(:disabled) { transform: translateY(1px); box-shadow: inset var(--px) var(--px) 0 var(--ink); }
button:disabled { opacity: .38; cursor: default; }
button.warn { background: #6b1a2c; }
button.big { font-size: 16px; padding: 12px 16px; background: #1f6a3a; }

#bar { display: flex; gap: 8px; align-items: center; padding: 6px 8px; background: var(--ink); border-bottom: var(--px) solid var(--blue); }
#pool { flex: 1; min-width: 0; }
#poolc { width: 100%; max-width: 360px; image-rendering: pixelated; display: block; }
#poolt { font-size: 10px; color: var(--light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
#res { display: flex; flex-direction: column; gap: 1px; font-size: 12px; text-align: right; }
.r i { color: var(--grey); font-style: normal; }
.r.junk { color: var(--light); } .r.alloy { color: var(--orange); } .r.chips { color: var(--cyan); }
.r.full { color: var(--red); }
#menu { min-height: 36px; padding: 4px 10px; font-size: 18px; }
.c { color: var(--cyan); } .d { color: var(--lav); } .g { color: var(--grey); }

#stage { position: relative; overflow: hidden; touch-action: none; background: var(--night); }
#stage canvas { display: block; image-rendering: pixelated; touch-action: none; }

#goal { padding: 6px 10px; background: var(--brown); color: var(--yellow); font-size: 12px; border-top: var(--px) solid var(--ink); }

#sheet {
  height: 36dvh; overflow-y: auto; padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  background: #0b1226; border-top: var(--px) solid var(--blue);
}
.head { display: flex; gap: 10px; align-items: flex-start; }
.head > div { flex: 1; }
.head .x { min-height: 32px; padding: 4px 9px; background: transparent; box-shadow: none; color: var(--grey); }
.ic { width: 48px; height: 48px; image-rendering: pixelated; background: #1a2a1a; flex: none; }
h2 { margin: 0 0 2px; font-size: 15px; color: var(--yellow); text-transform: uppercase; }
h3 { margin: 10px 0 4px; font-size: 11px; color: var(--lav); text-transform: uppercase; }
p { margin: 3px 0; font-weight: normal; }
.stat { color: var(--light); font-size: 12px; }
em { color: var(--orange); font-style: normal; }
.st-ok { color: var(--green); } .st-off { color: var(--grey); } .st-cap { color: var(--yellow); }
.st-full, .st-empty, .st-starved { color: var(--orange); }
.btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.btns button { flex: 1 1 auto; }
.btns.col { flex-direction: column; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 0; font-weight: normal; }
.row button { min-height: 32px; padding: 4px 8px; font-size: 11px; }
.log { margin: 0; padding-left: 16px; color: var(--light); font-weight: normal; font-size: 12px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.card { display: grid; grid-template-columns: 32px 1fr; grid-template-rows: auto auto auto; column-gap: 6px; text-align: left; text-transform: none; padding: 6px; }
.card img { grid-row: 1 / 4; width: 32px; height: 32px; image-rendering: pixelated; }
.card small { font-weight: normal; font-size: 10px; color: var(--light); }
.card .cost { font-size: 10px; color: var(--orange); }
.part { margin-top: 8px; padding: 6px 8px; background: #121b33; }
.part.done b { color: var(--green); }
.part.cur { box-shadow: inset 0 0 0 var(--px) var(--yellow); }
.part small { font-weight: normal; color: var(--light); }
.bar { height: 8px; background: var(--ink); margin-top: 6px; }
.bar i { display: block; height: 100%; width: 0; background: var(--cyan); }

#toast {
  position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--yellow); padding: 8px 12px; box-shadow: 0 0 0 var(--px) var(--yellow); max-width: 90vw;
}
#modal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; }
#modal[hidden], #toast[hidden] { display: none; }
#modal .box { background: var(--night); padding: 14px; max-width: 420px; width: 100%; max-height: 90dvh; overflow-y: auto; box-shadow: 0 0 0 var(--px) var(--cyan); }
#modal p.big { font-size: 15px; color: var(--yellow); font-weight: bold; }
.hero { width: 96px; height: 96px; image-rendering: pixelated; display: block; margin: 8px auto; }

@media (min-width: 800px) {
  #app { grid-template-columns: 1fr 380px; grid-template-rows: auto auto 1fr; }
  #bar { grid-column: 1 / 3; }
  #stage { grid-row: 2 / 4; }
  #goal { grid-column: 2; grid-row: 2; }
  #sheet { grid-column: 2; grid-row: 3; height: auto; border-left: var(--px) solid var(--blue); }
}
