:root {
  --bg: #0b0812;
  --ink: #f4ead2;
  --gold: #f2c14e;
  --gold2: #b8862b;
  --red: #c8323a;
  --panel: rgba(14, 10, 24, .92);
  --line: #5b4a2a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden;
  font-family: 'Press Start 2P', monospace; touch-action: none; user-select: none; -webkit-user-select: none; }
#wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
canvas#game { image-rendering: pixelated; image-rendering: crisp-edges; background: #000;
  width: min(100vw, calc(100vh * 320 / 192)); height: auto; max-height: 100vh; }
.hidden { display: none !important; }

#hud { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 10px; right: 54px; display: flex; gap: 12px;
  align-items: center; font-size: 11px; pointer-events: none; text-shadow: 2px 2px 0 #000; flex-wrap: wrap; }
#hearts { color: var(--red); letter-spacing: 2px; font-size: 13px; }
#stageName { color: var(--gold); }
#zen { margin-left: auto; color: #e9e2a0; }
#bossbar { position: absolute; top: 26px; left: 0; right: 0; text-align: center; font-size: 9px; }
#bossbar div { margin: 4px auto 0; width: min(320px, 70vw); height: 8px; border: 2px solid #000; background: #2a1414; }
#bossbar i { display: block; height: 100%; width: 100%; background: linear-gradient(#ff6a4a, #a0181e); }
#pauseBtn { position: absolute; top: max(6px, env(safe-area-inset-top)); right: 8px; width: 36px; height: 30px;
  font: 10px 'Press Start 2P'; background: var(--panel); color: var(--ink); border: 2px solid var(--line); border-radius: 4px; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: radial-gradient(ellipse at center, rgba(20,12,30,.55), rgba(5,3,10,.9)); text-align: center; padding: 16px; }
#title { background: linear-gradient(rgba(5,3,10,.15), rgba(5,3,10,.75)); }
h1 { font-size: clamp(40px, 11vw, 84px); margin: 0; color: var(--gold); letter-spacing: 2px;
  text-shadow: 4px 4px 0 #6b2a10, 8px 8px 0 #000; }
h1 span { color: #ff5a3c; margin-left: .25em; }
h2 { font-size: clamp(16px, 4vw, 24px); color: var(--gold); margin: 0 0 4px; text-shadow: 3px 3px 0 #000; }
.sub, .hint, .screen p { font-size: clamp(8px, 2.2vw, 11px); line-height: 1.8; margin: 0; text-shadow: 2px 2px 0 #000; }
.hint { opacity: .7; }

.btn { font: 12px 'Press Start 2P', monospace; color: #2a1606; background: linear-gradient(#ffe08a, var(--gold) 50%, var(--gold2));
  border: 3px solid #000; box-shadow: 0 4px 0 #000, inset 0 -3px 0 rgba(0,0,0,.25); padding: 12px 18px; border-radius: 4px; cursor: pointer; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #000; }
.btn.big { font-size: clamp(13px, 3.4vw, 18px); padding: 16px 26px; }
.btn.ghost { background: var(--panel); color: var(--ink); border-color: var(--line); }
.btn.small { font-size: 9px; padding: 9px 12px; }

.cards { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.card { width: 116px; padding: 12px 8px; background: var(--panel); border: 3px solid var(--line); border-radius: 6px; color: var(--ink);
  font-family: inherit; display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; }
.card:hover, .card:focus { border-color: var(--gold); outline: none; }
.card canvas { width: 96px; height: 96px; image-rendering: pixelated; }
.card b { font-size: 9px; color: var(--gold); }
.card small { font-size: 7px; opacity: .8; }

#touch { position: absolute; inset: auto 0 0 0; height: 0; }
.pad { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 12px; }
.pad.left { left: 14px; } .pad.right { right: 14px; }
.pad button { width: 64px; height: 64px; border-radius: 50%; border: 3px solid rgba(255,255,255,.35); background: rgba(20,14,34,.45);
  color: rgba(255,255,255,.85); font-size: 20px; touch-action: none; }
.pad button.on { background: rgba(242,193,78,.45); }
.pad .jump { margin-bottom: 34px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 12px; }
.box { position: relative; width: min(440px, 100%); max-height: 94vh; overflow: auto; background: #140e20; border: 3px solid var(--gold2);
  border-radius: 8px; padding: 18px 16px; text-align: center; }
.box .x { position: absolute; right: 8px; top: 6px; background: none; border: 0; color: var(--ink); font-size: 26px; cursor: pointer; }
.note { font-size: 8px; line-height: 1.8; opacity: .8; margin: 6px 0 12px; }
.wing { display: flex; align-items: center; gap: 12px; padding: 10px; margin: 8px 0; border: 2px solid var(--line); border-radius: 6px; background: #1c142b; text-align: left; }
.wing canvas { width: 80px; height: 60px; image-rendering: pixelated; flex: none; background: #0b0812; border-radius: 4px; }
.wing div { flex: 1; font-size: 9px; line-height: 1.8; }
.wing .btn { white-space: nowrap; }
.wing.eq { border-color: var(--gold); }
#pixBox { margin: 10px 0; }
#pixBox img { width: 220px; height: 220px; background: #fff; padding: 8px; border-radius: 6px; image-rendering: pixelated; }
#pixTitle { font-size: 10px; color: var(--gold); }
.codebox { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 6px; }
details { font-size: 8px; }
summary { cursor: pointer; margin-bottom: 8px; }
#restoreIn { font: 11px 'Press Start 2P'; width: 130px; padding: 8px; margin-right: 6px; background: #000; color: var(--ink); border: 2px solid var(--line); text-transform: uppercase; }

#toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); background: var(--panel); border: 2px solid var(--gold);
  padding: 10px 14px; font-size: 9px; border-radius: 6px; z-index: 20; max-width: 90vw; text-align: center; }

@media (pointer: coarse) { .hint { display: none; } }
