:root {
  --bg: #0a0704;
  --bg2: #140c07;
  --panel: #120b06;
  --fg: #fff3c2;
  --muted: #c9a56a;
  --gold: #e8b63a;
  --gold2: #ffdd7a;
  --line: #6b4a16;
  --bad: #ffb4a6;
  --blood: #7a1c12;
  --font: "Press Start 2P", ui-monospace, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--fg); }
body { font-family: var(--font); }
button:not(:disabled) { cursor: pointer; }
.hidden { display: none !important; }

.pix { font-family: var(--font); letter-spacing: 0.04em; line-height: 1.55; font-size: 9px; }
.md { font-size: 11px; }
.gold { color: var(--gold2); }
.muted { color: var(--muted); }
.bad { color: var(--bad); }

#boot {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; background: var(--bg); overflow: hidden;
}
#boot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; }
#boot p { position: relative; z-index: 1; color: var(--gold); }
#boot::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent, var(--bg));
}

#app {
  max-width: 430px; height: 100%; height: 100dvh; margin: 0 auto;
  display: flex; flex-direction: column; background: var(--bg);
  position: relative; overflow: hidden;
}
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-bottom: 2px solid var(--line); flex-shrink: 0;
}
.tab {
  display: none; flex: 1; min-height: 0; flex-direction: column; overflow: auto;
}
.tab.on { display: flex; }

.hero-wrap {
  padding: 10px;
}
.portrait {
  position: relative; border: 3px solid var(--gold); background: var(--bg);
  box-shadow: 4px 4px 0 #000; overflow: hidden; line-height: 0;
}
.portrait img { width: 100%; height: auto; object-fit: contain; display: block; }
.hot {
  position: absolute; border: 0; padding: 0; margin: 0;
  background: transparent; appearance: none;
}
.hot:active { background: rgb(232 182 58 / 0.2); }
.skin-pick {
  position: absolute; left: 8px; right: 8px; top: 42%;
  transform: translateY(-50%);
  display: flex; justify-content: center; gap: 12px;
  z-index: 5;
}
.skin-pick.hidden { display: none; }
.skin-ico {
  width: 30%; max-width: 110px; padding: 6px;
  border: 3px solid var(--gold); background: rgb(10 7 4 / 0.92);
  box-shadow: 4px 4px 0 #000; color: var(--gold2);
}
.skin-ico img { width: 100%; height: 88px; object-fit: cover; object-position: top center; display: block; margin-bottom: 6px; }
.skin-ico.on { outline: 2px solid var(--gold2); }
.gear-tip {
  position: absolute; left: 8px; right: 8px; bottom: 8px;
  padding: 8px 10px; text-align: center;
  border: 2px solid var(--gold); background: rgb(10 7 4 / 0.9);
  box-shadow: 4px 4px 0 #000;
}
.panel {
  margin: 0 10px 10px; padding: 10px;
  border: 2px solid var(--line); background: var(--panel);
}
.panel.jail { border-color: var(--blood); }
.bar { height: 8px; border: 1px solid var(--line); margin: 8px 0; background: var(--bg); }
.bar i { display: block; height: 100%; width: 0; background: var(--gold); }
.row { display: flex; gap: 8px; margin: 0 10px 10px; }
.row .btn { flex: 1; }
.log { margin: 0 10px 12px; }
.daylog { margin-top: 8px; max-height: 140px; overflow: auto; }
.daylog p { margin-top: 6px; }

.map {
  position: relative; flex: 1; min-height: 0; margin: 8px;
  border: 3px solid var(--gold); box-shadow: 4px 4px 0 #000; overflow: hidden;
  isolation: isolate; z-index: 0;
}
.map > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.pin {
  position: absolute; transform: translate(-50%, -50%);
  width: 112px; background: transparent; border: 0; color: var(--gold2);
}
.pin:active { transform: translate(-50%, -50%) scale(0.88); }
.pin.pop .pin-art { animation: punch 0.4s ease-out; }
.pin-art {
  display: block; width: 96px; height: 96px; margin: 0 auto;
  overflow: hidden; border: 3px solid var(--gold); background: var(--bg);
  box-shadow: 4px 4px 0 #000;
}
.pin-art img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; }
.pin .pix { display: block; margin-top: 6px; text-align: center; }

.topart {
  width: calc(100% - 20px); margin: 10px;
  border: 2px solid var(--gold); object-fit: contain; background: var(--bg); display: block;
}
.board-row { display: flex; justify-content: space-between; margin-top: 6px; }
.board-row.me { color: var(--gold2); }

nav {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  border-top: 2px solid var(--gold); background: var(--bg2); flex-shrink: 0;
}
nav button {
  background: var(--bg2); color: var(--muted); border: 0;
  padding: 12px 0 10px; font: 8px var(--font);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
nav button.on { color: var(--gold2); }

.btn {
  width: 100%; margin-top: 10px; padding: 12px;
  border: 2px solid var(--gold); background: var(--bg); color: var(--gold2);
  font: 10px var(--font);
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; }
.btn.ghost { border-color: var(--line); color: var(--muted); }

.scene {
  position: fixed; top: 0; bottom: 0; left: 0; right: 0;
  z-index: 80; max-width: 430px; margin: 0 auto;
  background: var(--bg); display: flex; flex-direction: column;
  padding: 10px 10px 12px; gap: 10px;
}
#app.has-scene .pin { visibility: hidden; pointer-events: none; }
.scene-art-wrap {
  position: relative; flex: 0 1 auto;
  width: 100%; max-height: 58%;
  overflow: hidden; line-height: 0;
  border: 3px solid var(--gold); background: var(--bg); box-shadow: 4px 4px 0 #000;
}
#sceneArt {
  display: block; width: 100%; height: auto;
  max-height: 58dvh; object-fit: contain; object-position: top center;
}
#sceneArt.slam { animation: slam 0.55s cubic-bezier(0.16, 1.24, 0.32, 1); }
#sceneArt.winflash { animation: slam 0.55s cubic-bezier(0.16, 1.24, 0.32, 1), win 0.45s ease; }
#sceneArt.loseflash { animation: slam 0.55s cubic-bezier(0.16, 1.24, 0.32, 1), lose 0.45s ease; }
.scene.shake { animation: shake 0.35s linear; }
.fx-panel {
  flex: 0 0 auto; margin-top: auto; padding: 12px;
  background: var(--panel);
  border: 3px solid var(--gold); box-shadow: 4px 4px 0 #000;
}
.fx-panel.popin { animation: panel-in 0.4s ease-out; }
#sceneText { color: var(--gold2); min-height: 1.6em; }
#sceneText.bad { color: var(--bad); }
#scenePick { max-height: 160px; overflow: auto; }
.pick {
  display: flex; justify-content: space-between; width: 100%;
  margin-top: 6px; padding: 8px; border: 2px solid var(--line);
  background: var(--bg); color: var(--muted); font: 9px var(--font);
}
.pick.on { border-color: var(--gold); color: var(--gold2); }

.scan {
  pointer-events: none; position: absolute; inset: 0; z-index: 50;
  background: repeating-linear-gradient(to bottom, rgb(0 0 0 / 0.14) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
.fx-rays {
  position: absolute; inset: -10%; pointer-events: none;
  background: radial-gradient(circle, rgb(232 182 58 / 0.5), transparent 62%);
  animation: rays 0.7s ease-out;
}

@keyframes blink { 50% { opacity: 0; } }
.blink { animation: blink 1s steps(2) infinite; }
@keyframes punch {
  0% { transform: scale(1); }
  35% { transform: scale(0.84); }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
@keyframes slam {
  0% { transform: scale(1.42) rotate(-4deg); opacity: 0; filter: brightness(2.2); }
  42% { transform: scale(0.94) rotate(1deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); filter: none; }
}
@keyframes win { 0%, 100% { filter: none; } 40% { filter: brightness(1.35); } }
@keyframes lose { 0%, 100% { filter: none; } 40% { filter: grayscale(0.4) brightness(0.7); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
@keyframes rays {
  0% { opacity: 0; transform: scale(0.35); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.35); }
}
@media (prefers-reduced-motion: reduce) {
  .blink, .slam, .winflash, .loseflash, .shake, .fx-rays, .pin.pop .pin-art { animation: none; }
}
