@font-face {
  font-family: 'Pixelify Sans';
  src: url('../art/fonts/pixelify-sans-latin-600.woff2') format('woff2');
  font-weight: 600; font-display: swap;
}
:root {
  color-scheme: dark;
  --night: #10191f; --slate: #203932; --iron: #63766b; --brass: #efc681; --bone: #fff0d0; --mist: #d8e1cd;
  --pixel: 'Pixelify Sans', ui-monospace, monospace; --ui: system-ui, -apple-system, sans-serif;
  background: var(--night); color: var(--bone); font-family: var(--ui);
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
main { position: relative; width: 100%; height: 100%; height: 100dvh; isolation: isolate; -webkit-user-select: none; user-select: none; }
#board { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; outline: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
#hud {
  position: absolute; inset: 0 0 auto; z-index: 2; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 7px) 10px 7px; background: #10191fe6; box-shadow: 0 2px 0 #0a1014;
  font-family: var(--pixel); font-weight: 600; font-size: 15px; pointer-events: none;
}
#hud button { pointer-events: auto; }
.who { display: flex; align-items: center; gap: 5px; }
.who img { width: 30px; height: 30px; image-rendering: pixelated; border-radius: 6px; background: #203932; box-shadow: 0 0 0 1px #63766b; }
.who.ally img { width: 24px; height: 24px; }
.bar { width: 56px; height: 9px; background: #1d1414; border-radius: 2px; box-shadow: 0 0 0 1px #3c2b28; overflow: hidden; }
.ally .bar { width: 34px; }
.bar i { display: block; height: 100%; width: 100%; background: linear-gradient(#ef7a5c, #c4432f); transition: width .12s; }
.ally .bar i { background: linear-gradient(#a6e07e, #5ea944); }
#keys { display: flex; gap: 2px; min-width: 10px; }
#keys img { width: 22px; height: 12px; image-rendering: pixelated; }
.count { display: flex; align-items: center; gap: 4px; color: var(--brass); }
.ember-dot { width: 9px; height: 9px; border-radius: 50%; background: radial-gradient(#ffe7a3, #f07a2c); box-shadow: 0 0 6px #ff9a3c; }
#kills::before { content: '✦ '; color: #c58ccf; }
#mode, #pause {
  margin-left: auto; font: inherit; color: var(--bone); background: #203932; border: 0; border-radius: 8px;
  padding: 6px 9px; box-shadow: inset 0 0 0 1px #63766b, 0 2px 0 #0a1014;
}
#pause { margin-left: auto; width: 34px; }
#mode.aim { background: #4b2c1d; box-shadow: inset 0 0 0 1px #c9874c, 0 2px 0 #0a1014; }
#hint {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); transform: translateX(-50%); z-index: 2;
  font-size: 14px; padding: 8px 14px; border-radius: 99px; background: #10191fcc; color: var(--mist); pointer-events: none;
  white-space: nowrap; transition: opacity .6s;
}
#hint.gone { opacity: 0; }
#hurt { position: absolute; inset: 0; pointer-events: none; z-index: 1; box-shadow: inset 0 0 80px #c4432f; opacity: 0; transition: opacity .35s; }
#hurt.on { opacity: .75; transition: none; }
#hurt.low { opacity: .35; animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { opacity: .1; } }
#loading { position: absolute; inset: 45% 0 auto; text-align: center; font-family: var(--pixel); color: var(--brass); }
dialog {
  border: 0; border-radius: 14px; padding: 20px 18px 16px; width: min(340px, 92vw); color: var(--bone);
  background: #142520; box-shadow: 0 0 0 2px #63766b, 0 0 0 5px #10191f, 0 14px 40px #000a;
}
dialog::backdrop { background: #0a1014b3; }
dialog h1 { font-family: var(--pixel); color: var(--brass); margin: 0 0 4px; font-size: 26px; text-align: center; }
dialog p { margin: 0 0 12px; text-align: center; color: var(--mist); }
dialog .small { font-size: 12px; margin: 10px 0 0; color: #9fb0a6; }
#menu-stats { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; margin: 0 6px 12px; font-family: var(--pixel); }
#menu-stats:empty { display: none; }
#menu-stats span:nth-child(even) { color: var(--brass); text-align: right; }
fieldset { border: 0; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
legend { font-family: var(--pixel); color: var(--brass); margin-bottom: 6px; }
fieldset label { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; padding: 9px 10px; border-radius: 10px; background: #203932; box-shadow: inset 0 0 0 1px #63766b55; }
fieldset label:has(input:checked) { box-shadow: inset 0 0 0 2px var(--brass); }
fieldset input { grid-row: span 2; accent-color: #efc681; margin-top: 3px; }
fieldset span { font-size: 13px; color: #b8c6bb; }
#primary { width: 100%; font: 600 18px var(--pixel); color: #2a1a08; background: linear-gradient(#ffd98f, #e9a948); border: 0; border-radius: 10px; padding: 12px; box-shadow: 0 3px 0 #8a5a1c; }
#steering-ring {
  --travel: 22px; --rim: calc(var(--travel) + 14px);
  position: fixed; z-index: 1; pointer-events: none; left: calc(0px - var(--rim)); top: calc(0px - var(--rim));
  width: calc(var(--rim) * 2); height: calc(var(--rim) * 2);
  transform: translate3d(var(--stick-x, 50vw), var(--stick-y, 50vh), 0);
  border-radius: 50%; background: radial-gradient(circle, #ffdb97dc 0 1.5px, #182933a6 2px 2.6px, transparent 3px), #12222e27;
  box-shadow: inset 0 0 0 1px #d7e3d6a8, inset 0 0 0 2.5px #0b1c26c0, 0 0 0 1px #0b19236e; opacity: 0;
}
#steering-ring.active { opacity: .92; }
#steering-thumb { position: absolute; left: calc(50% - 11px); top: calc(50% - 11px); width: 22px; height: 22px; border-radius: 50%; background: #839e9866; box-shadow: inset 0 0 0 1px #0f202cc2, inset 0 0 0 2px #f8e2b0ba; }
#steering-ring.active #steering-thumb { transform: translate3d(var(--thumb-x), var(--thumb-y), 0); }
#bombs img { width: 18px; height: 18px; image-rendering: pixelated; }
#bombs.empty { opacity: .45; }
details#experiments { margin: 0 0 14px; }
details#experiments summary { font-family: var(--pixel); color: var(--brass); cursor: pointer; margin-bottom: 8px; }
details#experiments label { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; padding: 7px 10px; margin-bottom: 6px; border-radius: 10px; background: #203932; }
details#experiments input { grid-row: span 2; accent-color: #efc681; margin-top: 3px; }
details#experiments span { font-size: 12px; color: #b8c6bb; }
dialog { max-height: 92dvh; overflow-y: auto; }
#pages img { width: 16px; height: 18px; image-rendering: pixelated; }
#pages #rune-key-icon { width: 20px; height: 11px; margin-left: 4px; }
#pages.ready #page-count { color: #d9c2ff; text-shadow: 0 0 6px #b48cff; }
#pages.open { animation: codex 0.6s infinite alternate; }
@keyframes codex { to { filter: drop-shadow(0 0 5px #c9a6ff); } }
#ink { display: none; width: 22px; height: 4px; margin-left: 3px; border-radius: 2px; background: #1d1414; box-shadow: 0 0 0 1px #3c2b48; overflow: hidden; align-self: center; }
#ink.on { display: block; }
#ink b { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #6b4fd6, #c9a6ff); }
#hud { gap: 7px; }
@media (max-width: 420px) {
  #hud { gap: 5px; padding-left: 7px; padding-right: 7px; font-size: 14px; }
  .bar { width: 44px; }
  .ally .bar { width: 26px; }
  #mode, #pause { padding: 6px 7px; }
}
#mode[hidden] { display: none; }
