:root {
  --ink: #f3ece2;
  --dim: #b9ada0;
  --panel: rgba(18, 14, 16, 0.78);
  --crimson: #c4383c;
  --azure: #3d7fd6;
  --gold: #e2b866;
  --stam: #e8d38a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #120d10; color: var(--ink); font: 14px/1.45 Inter, system-ui, sans-serif; }
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }
kbd { display: inline-block; min-width: 1.6em; padding: 0 0.35em; margin: 0 0.1em; border-radius: 4px; background: rgba(255,255,255,0.12); font: 600 12px/1.6 Inter, sans-serif; text-align: center; color: var(--ink); }
button { font: 600 15px Inter, sans-serif; color: var(--ink); background: rgba(255,255,255,0.08); border: 0; border-radius: 8px; padding: 12px 18px; cursor: pointer; transition: background 0.15s, transform 0.1s; }
button:hover { background: rgba(255,255,255,0.16); }
button:active { transform: scale(0.98); }
button.primary { background: var(--crimson); }
button.primary:hover { background: #d84a4e; }
button small { display: block; font-weight: 400; font-size: 12px; color: rgba(255,255,255,0.7); }

.panel { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--panel); backdrop-filter: blur(8px); border-radius: 14px; padding: 28px 32px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; z-index: 20; }
#menu h1 { font: 800 56px/1 Cinzel, serif; letter-spacing: 0.06em; margin: 0 0 8px; color: var(--ink); text-shadow: 0 2px 20px rgba(196,56,60,0.5); }
#menu .tag { margin: 0 0 20px; color: var(--dim); }
#loading .msg { font-size: 13px; color: var(--dim); display: flex; justify-content: space-between; }
#loading .track { height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; margin: 8px 0; }
#load-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--crimson), var(--gold)); transition: width 0.2s; }
#loading.error .msg { color: #ff8a80; }
.note { font-size: 12px; color: var(--dim); margin: 6px 0 0; }
#levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
#levels .choose { grid-column: 1 / -1; font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--dim); }
#levels .note { grid-column: 1 / -1; }
.how { margin-top: 20px; display: grid; gap: 8px; font-size: 13px; color: var(--dim); }
.how b { color: var(--ink); font-weight: 600; }
.controls { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--dim); }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud .side { position: absolute; top: 18px; width: min(38vw, 420px); }
#side0 { left: 22px; }
#side1 { right: 22px; text-align: right; }
.name { font: 600 18px Cinzel, serif; letter-spacing: 0.05em; margin-bottom: 6px; text-shadow: 0 1px 4px #000; }
.pips { display: inline-flex; gap: 5px; vertical-align: middle; margin: 0 8px; }
.pip { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.18); display: inline-block; }
.pip.won { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.bar { position: relative; background: rgba(0,0,0,0.45); border-radius: 4px; overflow: hidden; }
.bar.hp { height: 14px; }
.bar.st { height: 5px; margin-top: 4px; }
.bar .fill, .bar .lag { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: width 0.08s; }
.right .bar .fill, .right .bar .lag { left: auto; right: 0; }
#hp0 { background: linear-gradient(180deg, #e0575b, #a3262a); }
#hp1 { background: linear-gradient(180deg, #5b97e6, #24569e); }
.bar .lag { background: rgba(255,240,200,0.55); }
.bar.st .fill { background: var(--stam); }
.bar.st .fill.low { background: #d07a3c; }
.stance { display: flex; gap: 4px; margin-top: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.right .stance { justify-content: flex-end; }
.stance i { font-style: normal; padding: 2px 8px; border-radius: 4px; background: rgba(0,0,0,0.35); color: rgba(255,255,255,0.45); }
.stance i.on { background: rgba(255,255,255,0.85); color: #1a1214; }
.stance i.atk { background: var(--gold); color: #1a1214; }
#timer { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); font: 800 32px Cinzel, serif; text-shadow: 0 2px 8px #000; }
#keys { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 18px; font-size: 12px; color: rgba(255,255,255,0.65); white-space: nowrap; }

#announce { position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%) scale(0.9); font: 800 72px Cinzel, serif; letter-spacing: 0.1em; opacity: 0; pointer-events: none; z-index: 10; text-shadow: 0 4px 30px rgba(0,0,0,0.8); transition: opacity 0.2s, transform 0.25s; }
#announce.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#announce.fight { color: var(--gold); }
#announce.ko { color: #ff5a5f; font-size: 110px; }
#toasts { position: fixed; inset: 0; pointer-events: none; z-index: 9; }
.toast { position: absolute; transform: translate(-50%, -50%); font: 800 22px Cinzel, serif; letter-spacing: 0.05em; white-space: nowrap; text-shadow: 0 2px 8px #000; }
.toast.good { color: var(--gold); }
.toast.bad { color: #ff6b6b; }
.toast.dim { color: rgba(255,255,255,0.6); font-size: 16px; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
#vignette.hurt { animation: hurt 0.45s ease-out; }
@keyframes hurt { from { box-shadow: inset 0 0 160px 40px rgba(200,20,20,0.65); } to { box-shadow: inset 0 0 160px 40px rgba(200,20,20,0); } }
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 4; background: radial-gradient(circle, rgba(220,235,255,0.35), rgba(220,235,255,0) 60%); opacity: 0; }
#flash.on { animation: flash 0.35s ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
#debug { position: fixed; left: 12px; bottom: 40px; margin: 0; font: 11px/1.4 ui-monospace, monospace; color: #cfe; background: rgba(0,0,0,0.6); padding: 8px; border-radius: 6px; z-index: 30; }
#result h2, #pause h2 { font: 800 44px Cinzel, serif; margin: 0 0 16px; text-align: center; }
#result.won h2 { color: var(--gold); }
#result.lost h2 { color: #ff6b6b; }
#result-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 20px; text-align: center; }
#result-stats b { display: block; font: 800 28px Cinzel, serif; }
#result-stats span { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; }
.row { display: flex; gap: 10px; justify-content: center; }
#pause { text-align: center; width: 260px; }
footer { position: fixed; bottom: 8px; right: 12px; font-size: 11px; color: rgba(255,255,255,0.45); z-index: 6; }
footer a { color: rgba(255,255,255,0.65); }
@media (max-width: 720px) {
  #menu h1 { font-size: 40px; }
  #levels { grid-template-columns: 1fr; }
  #hud .side { width: 44vw; }
  #side0 { left: 12px; } #side1 { right: 12px; }
  #keys { display: none; }
  #announce { font-size: 44px; }
  #result-stats { grid-template-columns: repeat(2, 1fr); }
}

#threat { position: fixed; transform: translate(-50%, -100%); font: 800 15px Inter, sans-serif; letter-spacing: 0.12em; color: var(--gold); text-shadow: 0 1px 6px #000; pointer-events: none; z-index: 8; opacity: 0; transition: opacity 0.08s; }
#threat.show { opacity: 1; }
body.fighting footer { display: none; }
#keys kbd { transition: background 0.06s, color 0.06s; }
#keys kbd.down { background: var(--gold); color: #1a1214; }
#fakecursor { position: fixed; left: 0; top: 0; width: 22px; height: 30px; z-index: 100; pointer-events: none; transform: translate(-100px, -100px);
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='22' height='30' viewBox='0 0 22 30'><path d='M2 2 L2 25 L8 19 L12 28 L16 26 L12 17 L20 17 Z' fill='white' stroke='black' stroke-width='1.6' stroke-linejoin='round'/></svg>") no-repeat; }
#touchnote { display: none; margin-top: 12px; font-size: 13px; color: var(--gold); }
@media (hover: none) and (pointer: coarse) { #touchnote { display: block; } }
