@font-face {
  font-family: "IM Fell English SC";
  src: url('./assets/imfellenglishsc.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
:root {
  color-scheme: dark;
  --background: #101914;
  --gold: #f6d496;
  --muted: #c8cbbb;
  --edge: #637158;
  --frame: #ad8b56;
  --accent: #e3b56d;
  --frame-art: url('./assets/bronzeframe.webp');
  --metal-button: linear-gradient(165deg, #263e30a8, #15251dbc), url('./assets/bronzeplate.webp') center / 156px;
  --bevel: inset 0 1px #e1bf7955, inset 1px 0 #9ab38f44, inset 0 -2px #07141098, 0 2px 1px #07110f80;
  --font: system-ui, sans-serif;
  --display: "IM Fell English SC", Georgia, 'Times New Roman', serif;
  font-family: var(--font);
  font-synthesis-weight: none;
  color: #f5ecda;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; background: var(--background); }
body { -webkit-tap-highlight-color: transparent; }
button { color: inherit; font: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 2px solid #fce2ac; outline-offset: 3px; }
#dialog:focus { outline: none; }
/* High-definition pixel filter for interface graphics only: art, frames, icons
   and the minimap. Text is never filtered. --px is empty below 1.5x. */
:root { --px: ; }
.pixel-ui { --px: url(#hd-pixels); }
button[disabled] { cursor: default; }
[hidden] { display: none !important; }
#game { position: relative; width: 100%; height: 100%; height: 100dvh; isolation: isolate; overflow: hidden; }
#game:fullscreen { width: 100%; height: 100%; background: var(--background); }
#view { display: block; width: 100%; height: 100%; image-rendering: pixelated; touch-action: none; }
@media (hover: hover) and (pointer: fine) {
  #view { cursor: crosshair; }
  /* Desktop turns with the mouse: no Turn Around button; a larger minimap. */
  #turn-around { display: none; }
  .map-panel #minimap { width: clamp(142px, 41.4vmin, 212px); }
  .map-panel .run-stat { font-size: 20px; gap: 10px; }
  .map-panel .run-stat span + span::before { font-size: 11px; margin-right: 10px; }
  #hud #boss { top: max(272px, calc(env(safe-area-inset-top) + 264px)); }
}
#hurt { pointer-events: none; position: absolute; inset: 0; opacity: 0; box-shadow: inset 0 0 15vmin 3vmin #bd183a; }
#title-screen {
  --title-art: url('./assets/hall.webp');
  position: absolute; inset: 0; z-index: 4; overflow: hidden;
  display: grid; grid-template: auto minmax(0, 1fr) / minmax(0, 1fr); gap: 7px;
  padding: max(5px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
           max(9px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
#title-screen::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, #0c181350 0%, #0d181306 36%, #0e1c1658 68%, #08140ee5 100%),
              var(--title-art) var(--title-art-position, 50% 47%) / cover, #211a1a;
  filter: var(--px);
}
.title-frame {
  position: relative; display: grid; place-items: center; container: title-frame / size;
}
.title-frame::before {
  content: ''; position: absolute; inset: 0;
  border: 1px solid #9a7e50; border-image: var(--frame-art) 80 / 38px / 0 round; pointer-events: none; filter: var(--px);
}
.title-tools { display: flex; justify-content: flex-end; align-items: center; gap: 6px; padding-inline: 4px; }
.title-control {
  display: flex; flex-direction: column; align-items: center; gap: 2px; flex: none;
  min-width: 74px; padding: 0 2px 2px; border: 0; background: transparent;
}
.title-control .gothic-face { width: clamp(34px, 6.8vmin, 46px); }
.title-control-label {
  color: var(--gold); font: 400 11px/1.15 var(--display); letter-spacing: .035em;
  text-align: center; text-shadow: 0 1px 3px #000, 0 1px #000;
}
.title-control:active:not(:disabled) .gothic-face { transform: translateY(2px); filter: var(--px) brightness(1.18); }
[data-fullscreen][aria-pressed=true] { color: #ffe8a8; border-color: var(--accent); text-shadow: 0 0 7px #d29455; }
[data-fullscreen]:disabled { opacity: .65; }
.fullscreen-note, #dialog .fullscreen-note { margin: 5px 0 0; color: #f3c5a3; font-size: 11px; }
.title-tools .fullscreen-note {
  order: -1; max-width: min(205px, 40%); margin: 0 auto 0 0; padding: 3px 5px;
  background: #111d16; text-shadow: 0 1px #010403;
}
.title-content {
  display: grid; grid-template-areas: 'hero' 'setup' 'footer'; gap: clamp(7px, 2.3cqh, 18px);
  width: min(100%, 930px); padding: clamp(15px, 3.5cqh, 26px) clamp(15px, 3.5cqw, 30px);
  text-align: center;
}
.title-hero { position: relative; grid-area: hero; display: grid; justify-items: center; gap: clamp(2px, 1.15cqh, 8px); min-width: 0; }
.logo-sparkle { position: absolute; pointer-events: none; filter: var(--px); }
.title-relic { width: clamp(28px, 15cqh, 105px); height: clamp(31px, 17cqh, 116px); object-fit: contain; filter: var(--px) drop-shadow(0 0 20px #bc58fa8a); image-rendering: pixelated; }
h1 { width: 100%; margin: 0; color: var(--gold); font: 800 clamp(23px, 7.5vw, 76px)/1.08 var(--display); text-transform: uppercase; filter: var(--px) drop-shadow(0 5px 1px #261815) drop-shadow(0 8px 18px #130d0b); }
h1 img { display: block; width: min(100%, 790px); height: auto; max-height: clamp(36px, 27cqh, 177px); object-fit: contain; margin-inline: auto; }
.run-setup { grid-area: setup; width: min(100%, 355px); justify-self: center; min-width: 0; padding-inline: 2px; }
.title-footer { grid-area: footer; }
fieldset { padding: 0; margin: 0; border: 0; min-width: 0; }
legend { padding: 0 0 6px; font: 400 13px/1.15 var(--display); text-transform: uppercase; letter-spacing: .13em; color: #dfc48d; text-shadow: 0 2px #080c09; }
.difficulty-options {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px;
  container: difficulty-options / inline-size;
}
.primary, .difficulty {
  --bezel-art: url('./assets/bronzeaction.webp');
  --bezel-slices: 49 65 47 65;
  --bezel-source: var(--bezel-art);
  border: solid transparent; border-width: var(--button-rim-block) var(--button-rim-inline);
  filter: drop-shadow(0 2px 2px #08110cb8);
  isolation: isolate;
}
.primary:not(#descend) { position: relative; }
/* The bezel art sits on its own layer behind the label, so the pixel filter
   reaches the bronze and enamel but never the lettering. */
.primary::after, .difficulty::after {
  content: ''; position: absolute; z-index: -1; pointer-events: none;
  inset: calc(-1 * var(--button-rim-block)) calc(-1 * var(--button-rim-inline));
  border: solid transparent; border-width: var(--button-rim-block) var(--button-rim-inline);
  border-image: var(--bezel-source) var(--bezel-slices) fill / 1;
  filter: var(--px);
}
.difficulty {
  --button-rim-block: 10px;
  --button-rim-inline: clamp(7px, 3.7cqw, 13px);
  position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
  padding: 1px 3px; cursor: pointer; font: 400 16px/1.15 var(--display);
  /* Neutral bezel: same art with the enamel repainted green (art/neutral_bezel.py),
     so the 9-slice rims carry the fill and no dark strips appear inside the frame. */
  --bezel-source: url('./assets/bronzeneutral.webp');
  background: transparent;
  color: #dac39b; text-shadow: 0 2px 3px black;
}
.primary, .difficulty:has(input:checked) {
  --bezel-source: var(--bezel-art);
  background: transparent; color: #fff1c8; text-shadow: 0 2px #390d0f;
}
.difficulty input {
  appearance: none; flex: none; width: 17px; height: 17px; margin: 0; border-radius: 50%;
  border: 2px solid #ba8b53; background: #121a12; box-shadow: inset 0 0 0 1px #030906, 0 1px 2px #080705;
  cursor: inherit;
}
.difficulty input:checked {
  border-color: #dfb778;
  background: radial-gradient(circle at 41% 37%, #f4b07f, #c75149 24%, #79282c 50%, #201712 56%);
}
.difficulty input:focus-visible { outline: 2px solid #fce2ac; outline-offset: 2px; }
#difficulty-detail { min-height: 2em; margin: 6px 0 9px; color: #e1d5c0; font-size: 11px; line-height: 1.3; text-shadow: 0 1px 4px black, 0 1px black; }
#start { width: min(100%, 305px); }
.primary {
  --button-rim-block: 12px;
  --button-rim-inline: 18px;
  min-height: 49px; width: 100%; padding: 1px 4px;
  font: 400 21px/1.1 var(--display); letter-spacing: .04em;
}
.primary:hover { filter: brightness(1.09) drop-shadow(0 2px 2px #08110cb8); }
.primary span { margin-left: 5px; }
.instructions { color: #d0c7c0; margin: 0; font-size: clamp(10px, 2.8vw, 12px); font-weight: 550; text-shadow: 0 2px 4px #100b0a; }
.instructions i { display: inline-block; height: 3px; width: 3px; vertical-align: middle; margin: 0 5px; background: #bc4439; transform: rotate(45deg); }
.finger-icon { color: #f1c684; font-size: 15px; }
.best { margin: 9px 0 0; color: #c5a375; font-size: 11px; }
#hud { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
#hud button { pointer-events: auto; }
.topline { position: absolute; inset: max(13px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) auto max(14px, env(safe-area-inset-left)); display: flex; align-items: flex-start; justify-content: flex-end; gap: 8px; }
#score { position: absolute; top: max(14px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); font: 400 clamp(19px, 5vw, 26px) var(--display); color: #ffe2a6; letter-spacing: .04em; font-variant-numeric: tabular-nums; text-shadow: 0 1px 0 #6b4a1f, 0 2px 3px #090c0a, 0 0 10px #000000c0; }
.map-panel { position: absolute; top: max(9px, calc(env(safe-area-inset-top) - 4px)); left: 50%; transform: translateX(-50%); display: grid; justify-items: center; gap: 3px; }
.run-stat { display: flex; align-items: center; gap: 6px; white-space: nowrap; font: 700 10px var(--display); color: #e0ccab; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px #090c0a, 0 0 6px black; opacity: .9; }
#stage { color: #f2dfb8; }
.run-stat span + span::before { content: '◆'; display: inline-block; margin-right: 6px; color: #ac5537; font-size: 6px; vertical-align: 1px; }
.hud-buttons { display: flex; gap: max(1px, 0.4vw); }
.hud-button { position: relative; display: grid; place-items: center; border: 0; background: transparent; padding: 0; width: 43px; height: 44px; }
.hud-button img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; filter: var(--px) drop-shadow(0 3px 2px #030505b8); pointer-events: none; }
.hud-button:hover img { filter: var(--px) brightness(1.18) drop-shadow(0 3px 2px #030505b8); }
.hotkey {
  position: absolute; top: calc(100% + 2px); left: 50%; transform: translateX(-50%);
  padding: 1px 5px 0; border: 1px solid #a9824e; background: #14221ae0; box-shadow: 0 1px 2px #000a;
  color: #f2dfb8; font: 400 11px/1.25 var(--display); letter-spacing: .04em; white-space: nowrap;
  opacity: 0; transition: opacity .8s ease; pointer-events: none;
}
#hud.show-hotkeys .hotkey { opacity: 1; transition-duration: .3s; }
#point-count { position: absolute; top: 0; right: 0; min-width: 16px; text-align: center; background: #6f2523; border: 1px solid #c69b5d; padding: 1px 3px; color: #ffebc1; font: 800 10px var(--font); }
#minimap { display: block; width: clamp(71px, 20.7vmin, 106px); aspect-ratio: 1; opacity: .88; filter: var(--px); }
#boss { position: absolute; inset: max(138px, calc(env(safe-area-inset-top) + 130px)) auto auto 50%; transform: translateX(-50%); width: min(68vw, 370px); color: #ffe1b1; font: bold 12px var(--display); text-align: center; letter-spacing: .12em; text-transform: uppercase; text-shadow: 0 2px 3px black; }
#boss div { height: 9px; border: 1px solid #a9824e; background: #1b1513; box-shadow: 0 1px 0 #0d1812; margin-top: 5px; }
#boss i { display: block; height: 100%; background: linear-gradient(#d54845, #8a2226 58%, #641b23 60%); }
#reticle { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(45deg); width: 9px; height: 9px; border: 1px solid #f7ddb1d6; filter: drop-shadow(0 1px 2px #0d121b); }
#reticle i { position: absolute; width: 2px; height: 2px; top: 2.5px; left: 2.5px; background: white; }
#reticle.locked { border-color: #faa981; }
#reticle.locked i { background: #f65c54; }
#cross-message { position: absolute; inset: 60% 12% auto; color: #ffdda4; font: bold 14px var(--display); letter-spacing: .035em; text-align: center; text-shadow: 0 2px 4px black, 0 0 10px #160b0c; }
.maneuver {
  position: absolute; z-index: 1; top: 62%; transform: translateY(-50%);
  width: clamp(56px, 10vmin, 72px); aspect-ratio: 6 / 7; padding: 0; border: 0; background: transparent;
}
.gothic-face {
  --plate-outline: polygon(
    50% 0, 60% 11%, 78% 21%, 89% 31%, 95% 43%, 95% 72%, 100% 83%, 100% 89%,
    84% 92%, 65% 92%, 50% 100%, 35% 92%, 16% 92%, 0 89%, 0 83%,
    5% 72%, 5% 43%, 11% 31%, 22% 21%, 40% 11%
  );
  --patina: url('./assets/bronzeplate.webp') center / 114px;
  --icon-brass: linear-gradient(148deg, #f9dd9d, #d7af6b 39%, #ae793f 66%, #d4ac68 94%);
  position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 6 / 7;
  image-rendering: pixelated; filter: var(--px) drop-shadow(0 3px 2px #060704de); pointer-events: none;
}
.gothic-plate, .gothic-plate::before, .gothic-plate::after {
  position: absolute; clip-path: var(--plate-outline); pointer-events: none;
}
.gothic-plate {
  inset: 0;
  background: linear-gradient(150deg, #9d6c31b5, #efc782dc 26%, #9c7037e8 47%, #48311be0 81%, #ba8e52d4), var(--patina);
}
.gothic-plate::before {
  content: ''; inset: 2px;
  background: linear-gradient(135deg, #25231bd1, #48604b18 38%, #4157453b 60%, #311e16c9 92%), var(--patina);
}
.gothic-plate::after {
  content: ''; inset: 7px 7px 9px;
  background: linear-gradient(140deg, #151910d9, #131711ae 65%, #090c09f0), var(--patina);
  box-shadow: inset 1px 0 #a27a44, inset -1px 0 #4e3920, inset 0 -3px #6d512d;
}
.gothic-face::before, .gothic-face::after {
  content: ''; position: absolute; z-index: 1; left: 50%; transform: translateX(-50%);
  pointer-events: none;
}
.gothic-face::before {
  top: 3%; width: 29%; aspect-ratio: 1;
  background: url('./assets/bronzegarnet.webp') center / contain no-repeat;
  filter: drop-shadow(0 1px 1px #1d1107);
}
.gothic-face::after {
  bottom: 11%; width: 43%; height: 10%;
  background: linear-gradient(#f1cc88, #9d703e 51%, #cf9d5f 65%, #60401f);
  clip-path: polygon(0 44%, 34% 37%, 50% 0, 66% 37%, 100% 44%, 66% 61%, 50% 100%, 34% 61%);
}
.maneuver[aria-disabled=true] { cursor: default; }
.maneuver[aria-disabled=true] .gothic-face, .title-control[aria-pressed=false] .gothic-face {
  --icon-brass: linear-gradient(148deg, #bca179, #8b6b47 50%, #6a4c33 74%, #8f7048);
}
.maneuver:active:not([aria-disabled=true]) .gothic-face { transform: translateY(2px); filter: var(--px) brightness(1.18) drop-shadow(0 1px 1px #060704d9); }
#turn-around { left: max(10px, calc(env(safe-area-inset-left) + 5px)); }
#dash { right: max(10px, calc(env(safe-area-inset-right) + 5px)); }
.gothic-icon {
  position: relative; z-index: 1; width: 47%; aspect-ratio: 1; pointer-events: none;
  filter: drop-shadow(0 1px #4c2a16) drop-shadow(0 2px 1px #070805);
}
.gothic-icon::before, .dash-icon::after {
  content: ''; position: absolute; background: var(--icon-brass);
}
.turn-icon::before {
  inset: 10% 0;
  clip-path: polygon(
    100% 100%, 82% 100%, 82% 60%, 78% 46%, 70% 35%, 60% 28%, 49% 26%, 38% 29%,
    30% 37%, 25% 49%, 39% 49%, 20% 80%, 0 49%, 9% 49%, 14% 31%, 24% 16%,
    37% 5%, 50% 0, 66% 4%, 80% 15%, 92% 32%, 98% 47%, 100% 60%
  );
}
.dash-icon::before, .dash-icon::after {
  inset: 13% 51% 13% 0;
  clip-path: polygon(0 0, 32% 12%, 100% 50%, 32% 88%, 0 100%, 12% 77%, 57% 50%, 12% 23%);
}
.dash-icon::after { inset-inline: 51% 0; }
.fullscreen-icon::before {
  --ink: linear-gradient(#000, #000);
  inset: 8%;
  mask: var(--ink) left top / 36% 17%, var(--ink) left top / 17% 36%,
        var(--ink) right top / 36% 17%, var(--ink) right top / 17% 36%,
        var(--ink) left bottom / 36% 17%, var(--ink) left bottom / 17% 36%,
        var(--ink) right bottom / 36% 17%, var(--ink) right bottom / 17% 36%;
  mask-repeat: no-repeat;
}
.sound-icon::before {
  inset: 5% 36% 5% 3%;
  clip-path: polygon(0 34%, 35% 34%, 100% 0, 100% 100%, 35% 66%, 0 66%);
}
.sound-icon::after {
  content: ''; position: absolute; inset: 13% 3% 13% 54%;
  border: solid #d4af70; border-width: 0 2px 0 0; border-radius: 0 100% 100% 0;
}
#sound[aria-pressed=false] .sound-icon::after { content: none; }
#dash-timer {
  position: absolute; z-index: 2; bottom: -9px; left: 50%; transform: translateX(-50%);
  min-width: 38px; min-height: 21px; padding: 5px 8px; pointer-events: none;
  color: #ffe3ae; isolation: isolate;
  text-shadow: 0 1px 2px #160908;
  font: 400 11px/1 var(--display); font-variant-numeric: tabular-nums;
}
#dash-timer::after {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: url('./assets/bronzeaction.webp') center / 100% 100% no-repeat; filter: var(--px);
}
#descend {
  --button-rim-block: 10px;
  position: absolute; bottom: clamp(135px, 30vh, 240px); left: 50%; transform: translateX(-50%);
  width: auto; min-width: 198px; min-height: 43px; white-space: nowrap;
  font-size: 17px; filter: drop-shadow(0 3px 4px #070908);
}
#descend:hover { filter: brightness(1.12) drop-shadow(0 3px 4px #070908); }
#descend span { color: #e8b666; margin-left: 3px; }
.bottom-hud { position: absolute; inset: auto 0 0; height: min(38vh, 240px); }
.hand { position: relative; aspect-ratio: 345 / 490; }
.hud-hand { position: absolute; bottom: -3px; width: min(42vw, 41vh, 270px); aspect-ratio: 560 / 270; }
.hud-hand.left { left: max(5%, env(safe-area-inset-left)); }
.hud-hand.right { right: max(5%, env(safe-area-inset-right)); }
.hand img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; pointer-events: none; filter: drop-shadow(0 5px 1px #1b1411) drop-shadow(0 5px 12px #100c0bb0); transform: translateY(var(--bob, 0px)); }
.hand.right img { transform: scaleX(-1) translateY(var(--bob, 0px)); }
.slots { position: absolute; inset: 0; transform: translateY(var(--bob, 0px)); }
.slot { position: absolute; transform: translate(-50%, -50%); display: grid; place-items: center; width: 24%; max-width: 49px; aspect-ratio: 1; border: 0; background: transparent; padding: 0; }
.empty-finger { width: 5px; height: 5px; border: 1px solid #ffe4b6a6; border-radius: 50%; background: #3c2a24ab; box-shadow: 0 1px 2px #170e11; }
#hud .empty-finger { opacity: .35; }
.hud-hand.show-band-masks .empty-finger { visibility: hidden; }
.worn-ring {
  position: relative; display: inline-block; width: 28px; aspect-ratio: 1; flex: none; pointer-events: none; filter: var(--px);
}
.ring-layer {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  background-repeat: no-repeat; image-rendering: pixelated; pointer-events: none;
}
.slot .worn-ring { width: calc(var(--band) * 1.27); transform: rotate(var(--angle)); filter: var(--px) drop-shadow(0 1px 1px #0f1510bd); }
.hud-hand .slot { max-width: none; }
.equipment-hand .hand img { filter: var(--px) drop-shadow(0 5px 1px #1b1411) drop-shadow(0 5px 12px #100c0bb0); }
.combat-rings { position: absolute; inset: -8%; width: 116%; height: 116%; pointer-events: none; }
.vitals {
  position: absolute; bottom: max(9px, calc(env(safe-area-inset-bottom) + 4px)); left: 50%; transform: translateX(-50%);
  width: clamp(92px, 16vw, 157px); display: grid; justify-items: center; filter: drop-shadow(0 3px 3px #080707c2);
}
.vital-life { position: relative; display: grid; place-items: center; width: clamp(54px, 8vw, 76px); aspect-ratio: 1; }
.vital-life img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; filter: var(--px); }
.vital-life img:first-child { filter: var(--px) sepia(.55) saturate(.5) brightness(.49); }
#health-fill { clip-path: inset(calc(100% - var(--fill, 100%)) 0 0); }
#health-text { z-index: 1; color: #fff2ce; font: 800 clamp(9px, 2vw, 12px) var(--display); text-shadow: 0 1px 2px #160507, 0 2px #180003; }
.vital-xp { position: relative; width: 100%; display: grid; grid-template-columns: 15px auto 1fr; align-items: center; gap: 2px; margin-top: -2px; }
.vital-xp b { font: 800 11px var(--display); color: var(--gold); text-shadow: 0 2px 2px #0b0905; }
.vital-xp img { width: 15px; height: 18px; object-fit: contain; image-rendering: pixelated; filter: var(--px); }
.track { height: 6px; border: 1px solid #a38651; background: #16241b; box-shadow: 0 1px #433621; }
.track i { display: block; height: 100%; background: linear-gradient(#f5d476, #b4802c); }
#overlay { position: absolute; z-index: 5; inset: 0; display: grid; place-items: center; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); background: #07110cbe; overscroll-behavior: contain; }
#dialog {
  width: min(100%, 520px); max-height: 100%; overflow: auto; padding: clamp(5px, 1.5vw, 9px);
  border: clamp(12px, 3.5vmin, 22px) solid transparent;
  position: relative; z-index: 1;
  text-align: center; scrollbar-width: thin;
}
/* The dialog's frame and backdrop live on a separate layer that game.js keeps
   matched to the dialog box, so the pixel filter never touches its text. */
#dialog-frame {
  position: absolute; z-index: 0; pointer-events: none;
  border: clamp(12px, 3.5vmin, 22px) solid transparent; border-image: var(--frame-art) 80 / 1 / 0 round;
  box-shadow: 0 14px 70px #000b;
  background: radial-gradient(ellipse at 50% 0, #35403490, #0c1714e8 70%), url('./assets/reliquary.webp') center / cover, #12221b;
  filter: var(--px);
}
#dialog-frame:has(+ #dialog[data-layout=equipment]) {
  border: 0; box-shadow: none;
  background: linear-gradient(180deg, #08140ead, #10231b2e 52%, #08140ec4), url('./assets/reliquary.webp') center / cover, #14281e;
}
#dialog h2 { margin: 0 0 8px; color: #f9d697; font: bold clamp(24px, 5vw, 33px) var(--display); text-shadow: 0 2px 0 #08150d; }
#dialog > h2::after {
  content: ''; display: block; height: 14px; margin: 4px auto 1px; width: min(42%, 146px);
  background: url('./assets/bronzedivider.webp') center / contain no-repeat; image-rendering: pixelated; filter: var(--px);
}
#dialog p { margin: 7px 0 13px; color: #d2c7be; font-size: 13px; line-height: 1.43; }
.panel-actions { display: flex; flex-direction: column; gap: 7px; margin-top: 14px; }
.secondary { min-height: 42px; border: 1px solid var(--edge); background: var(--metal-button); background-clip: padding-box; box-shadow: var(--bevel); padding: 7px 10px; color: #f2e4c8; font-weight: 650; font-size: 13px; }
.secondary:hover { border-color: var(--accent); }
.panel-actions > .secondary, .equipment-header button, .inventory-stow {
  font-family: var(--display); font-weight: 700;
}
.loot-symbol {
  display: inline-grid; place-items: center; width: clamp(76px, 14vh, 112px); aspect-ratio: 1; margin: -5px 0 1px;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--loot-glow) 29%, transparent), transparent 69%);
}
.loot-symbol .worn-ring { width: 100%; filter: var(--px) drop-shadow(0 5px 4px #070c07) drop-shadow(0 0 7px var(--loot-glow)); animation: relic-bob 3.2s ease-in-out infinite; }
@keyframes relic-bob { 50% { transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .loot-symbol .worn-ring { animation: none; } }
#dialog[data-layout=pause], #dialog[data-layout=confirm], #dialog[data-layout=over] { width: min(100%, 390px); }
.menu-crest {
  display: block; width: 38px; height: 38px; margin: -3px auto 4px; object-fit: contain;
  image-rendering: pixelated; filter: var(--px) drop-shadow(0 3px 3px #030807);
}
.panel-actions > .secondary {
  position: relative; min-height: 36px; background: linear-gradient(90deg, transparent, #25372a80 22% 78%, transparent);
  box-shadow: none; border: 0; border-bottom: 1px solid #a0844d6b; color: #f0dab0;
}
.panel-actions > .secondary::before {
  content: ''; display: inline-block; width: 5px; height: 5px; margin-right: .65em;
  vertical-align: .16em; transform: rotate(45deg); background: #aa7750;
}
.panel-actions > .secondary:has(.command-icon)::before { content: none; }
.panel-actions > .secondary:hover {
  color: #ffe6b0; border-color: #bb9258; background: linear-gradient(90deg, transparent, #4b402d80 22% 78%, transparent);
}
.panel-actions > .danger-action { color: #f4b3a0; background: linear-gradient(90deg, transparent, #4d252875 22% 78%, transparent); }
.panel-actions > .danger-action::before { background: #cf5849; }
.command-icon { width: 23px; height: 23px; margin: -2px 5px -2px -6px; vertical-align: middle; object-fit: contain; image-rendering: pixelated; filter: var(--px); }
#dialog .run-medal { color: #e4c790; font: 700 12px var(--display); }
.run-tally {
  display: flex; justify-content: center; margin: 6px 0 13px; padding: 6px 0;
  border-block: 1px solid #97784265;
}
.global-board { margin: 12px 0 4px; text-align: center; }
.global-board h3 { margin: 0 0 6px; color: #f2d7a5; font: 400 15px var(--display); letter-spacing: .04em; }
#dialog .carve-note { margin: 2px 0 6px; font-size: 12px; color: #d2c7be; }
.carve { display: flex; gap: 8px; align-items: stretch; margin: 0 auto 8px; max-width: 360px; }
.carve input { flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid #a9824e; background: #0d1a14e6; color: #ffe8bf;
  font: 400 17px var(--display); box-shadow: inset 0 2px 4px #000a; }
.carve input:focus { outline: 2px solid #fce2ac; outline-offset: 1px; }
.carve .primary { width: auto; min-height: 40px; font-size: 16px; padding-inline: 10px; }
.board-body { color: #cdbf9f; font-size: 12px; }
.board-list { list-style: none; margin: 0 auto; padding: 0; max-width: 380px; text-align: left; }
.board-list li { display: grid; grid-template-columns: 22px 1fr auto 64px; gap: 8px; align-items: baseline; padding: 3px 6px;
  border-bottom: 1px solid #97784240; color: #e7d8b8; font: 400 14px var(--display); }
.board-list .board-rank { color: #c08a4f; text-align: right; }
.board-list .board-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .board-time { color: #a99a7c; font-size: 12px; font-variant-numeric: tabular-nums; }
.board-list .board-score { text-align: right; color: #ffdfa0; font-variant-numeric: tabular-nums; }
.board-list .board-you { background: linear-gradient(90deg, transparent, #6f252355 20% 80%, transparent); }
.board-list .board-you .board-name { color: #ffe9bd; }
.board-list .board-empty { display: block; text-align: center; color: #b8a98a; }
.run-tally div { flex: 1; display: grid; text-align: center; padding: 1px 4px; }
.run-tally div + div { border-left: 1px solid #97784265; }
.run-tally dt { grid-row: 2; color: #ccb687; font: 700 9px var(--display); }
.run-tally dd { grid-row: 1; color: #ffdfa0; font: 800 21px var(--display); margin: 0; }
@media (max-height: 460px) { .menu-crest { width: 26px; height: 26px; margin-bottom: 2px; } }
/* Short landscape screens: the pause menu spreads its options into three
   columns under a full-width Resume, so nothing hides below the fold. */
@media (orientation: landscape) and (max-height: 560px) {
  #dialog[data-layout=pause] { width: min(100%, 620px); }
  #dialog[data-layout=pause] h2 { margin-bottom: 4px; }
  #dialog[data-layout=pause] p { margin: 4px 0 8px; font-size: 12px; line-height: 1.35; }
  #dialog[data-layout=pause] .panel-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px 8px; margin-top: 8px; }
  #dialog[data-layout=pause] .panel-actions > .primary { grid-column: 1 / -1; }
}
.quality { display: block; margin: 1px 0 8px; font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.ring-properties { display: grid; gap: 6px; margin: 9px auto; max-width: 440px; text-align: left; }
.ring-property {
  position: relative; display: grid; grid-template-columns: minmax(66px, .68fr) minmax(0, 2.32fr); align-items: start; gap: 8px;
  padding: 6px 0 6px 10px; background: transparent; border-bottom: 1px solid #bc9f6150;
}
.ring-property::before { content: ''; position: absolute; left: 0; top: 9px; width: 4px; height: 4px; transform: rotate(45deg); background: var(--property-edge); }
.ring-property dt { padding-top: 1px; font: 800 9px var(--display); letter-spacing: .055em; color: var(--property-text); }
.ring-property[data-kind=action] { --property-edge: #b64b40; --property-text: #f0b4a2; }
.ring-property[data-kind=adjacent] { --property-edge: #b99453; --property-text: #f1d794; }
.ring-property[data-kind=wearer] { --property-edge: #54806b; --property-text: #b5d8c2; }
.ring-property dd { margin: 0; font-size: 13px; line-height: 1.32; color: #f3e9de; }
.ring-property small { display: block; margin-top: 3px; color: #cbbeb2; font-size: 11px; line-height: 1.25; }
#dialog .ring-link-note { font-size: 11px; color: #cbbab0; margin-bottom: 8px; }
.finger-chooser { margin-top: 8px; border-top: 1px solid #9e805867; }
#dialog .placement-preview { color: #e9cb9a; min-height: 1.4em; margin: 4px 0 1px; font-size: 11px; }
.slot-picker .equipment-hand .hand { height: clamp(112px, 22vh, 169px); }
.slot-picker .slot { min-width: 25px; }
.slot-picker .slot:hover { border-radius: 50%; outline: 1px solid #f5d59f; background: #e5bc5836; }

.tree { position: relative; display: grid; gap: 6px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 13px 0 17px; }
.tree::before { content: ''; position: absolute; top: 23px; left: 16.66%; right: 16.66%; border-top: 1px solid #b2985c7d; }
.branch { position: relative; isolation: isolate; min-width: 0; display: grid; grid-template-rows: auto 1fr 1fr 1fr; gap: 4px; }
.branch::before { content: ''; position: absolute; z-index: -1; top: 22px; left: 50%; bottom: 32px; border-left: 1px solid #998659; }
.branch h3 { margin: 1px 0 9px; font: 800 clamp(10px, 3vw, 14px) var(--display); color: #efca8f; }
.perk { min-height: 65px; display: grid; justify-items: center; align-content: start; gap: 2px; padding: 0 2px; border: 0; background: transparent; box-shadow: none; text-shadow: 0 1px 2px #07120d; }
.perk::before { content: ''; display: block; width: 32px; height: 32px; background: url('./assets/bronzegarnet.webp') center / contain no-repeat; image-rendering: pixelated; filter: var(--px); }
.perk-name { display: block; padding: 0 3px; font: 800 11px var(--display); color: #f2d7a5; background: #14221ae6; }
.perk-effect { color: #e0ceae; font-size: 10px; line-height: 1.1; padding: 0 2px; background: #14221ae6; }
.perk[disabled]:not(.acquired)::before { filter: var(--px) saturate(.3) brightness(.67); }
.perk[disabled]:not(.acquired) .perk-name, .perk[disabled]:not(.acquired) .perk-effect { color: #afac95; }
.perk:not([disabled])::before, .perk.acquired::before { filter: var(--px) brightness(1.22) drop-shadow(0 0 5px #af4438); }
.perk.acquired .perk-name { color: #ffe5a8; }

#overlay:has(> #dialog[data-layout=equipment]) { padding: 0; background: #0b1612; }
#dialog[data-layout=equipment] {
  width: 100%; height: 100%; padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  border: 0; box-shadow: none; text-align: left;
}
.equipment-header { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 1px 0 9px; border-bottom: 1px solid #b3915a8a; }
.equipment-header, .loadout-summary, .equipment-boards { width: min(100%, 980px); margin-inline: auto; }
#dialog .equipment-header h2 { margin: 0; font-size: clamp(17px, 4.7vw, 34px); }
.equipment-header button {
  flex: none; min-height: 35px; padding: 3px 6px;
}
.equipment-header button, .equipment-detail-heading button, .pack-pages button {
  border: 6px solid transparent; border-image: var(--frame-art) 80 / 1 / 0 round;
  box-shadow: none; filter: drop-shadow(0 1px 1px #060b07aa);
}
.equipment-header button::before { content: ''; display: inline-block; width: 5px; height: 5px; margin-right: 5px; vertical-align: .14em; border-left: 1px solid #dca96b; border-bottom: 1px solid #dca96b; transform: rotate(45deg); }
.loadout-summary { margin-block: 4px 0; text-align: center; }
.loadout-stats { display: flex; justify-content: center; margin: 0 auto; }
.loadout-stat { position: relative; min-width: 0; display: grid; grid-template-rows: auto auto; justify-items: center; text-align: center; padding: 2px clamp(6px, 3vw, 24px) 3px; }
.loadout-stat + .loadout-stat { border-left: 1px solid #b2996157; }
.loadout-stat dt { grid-row: 2; color: #dfc699; font: 700 clamp(8px, 2.25vw, 10px) var(--display); white-space: nowrap; }
.loadout-stat dd { grid-row: 1; color: #ffe5a5; font: 800 clamp(16px, 4.6vw, 24px) var(--display); margin: 0 0 1px; white-space: nowrap; font-variant-numeric: tabular-nums; text-shadow: 0 2px #0b120d; }
.loadout-stat dd small { display: inline-block; margin-left: 3px; font: 750 9px var(--font); }
.stat-gain { color: #8cf1b6; }
.stat-loss { color: #ff8795; }
#dialog .loadout-message { color: #d4c5a8; margin: 4px 0; min-height: 1.35em; font-size: 11px; }
.equipment-boards { display: grid; grid-template-areas: 'hands' 'inventory' 'effects'; gap: 9px; }
.equipment-fingers { grid-area: hands; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; }
.equipment-hand {
  isolation: isolate; position: relative; min-width: 0; display: grid; grid-template-rows: 1fr auto; justify-items: center;
  background: radial-gradient(ellipse at 50% 46%, #65846042, #132a2110 68%, transparent 76%);
}
.equipment-hand::before {
  content: ''; position: absolute; z-index: -1; inset: 6% 0 11%; width: min(88%, 215px); margin: auto; aspect-ratio: 1;
  border-radius: 50%; border: 1px solid #bb9c5b79;
  background: radial-gradient(circle, transparent 56%, #a8915573 57% 57.4%, transparent 58% 63%, #725a3f9d 64% 64.6%, transparent 65% 72%, #2b4a3e88 73%);
  box-shadow: 0 0 28px #162b1e, inset 0 0 22px #0f221a;
}
.equipment-label { margin: 0; color: #ead2a5; font: 800 12px var(--display); }
.equipment-hand > .equipment-label { grid-row: 2; padding: 5px 0 1px; text-align: center; }
.equipment-hand .hand { grid-row: 1; height: clamp(129px, 29dvh, 252px); width: auto; }
.equipment-hand .slot { min-width: 25px; max-width: 45px; cursor: grab; }
.equipment-hand .slot:active, .inventory-ring:active { cursor: grabbing; }
.equipment-boards [data-place], .equipment-boards [data-stow] { touch-action: none; user-select: none; -webkit-user-select: none; }
.equipment-hand .empty-finger { opacity: .75; }
.equipment-hand .slot.ring-selected, .equipment-hand .slot.ring-linked, .equipment-hand .slot.drop-preview { border-radius: 50%; }
.equipment-boards .ring-selected { outline: 1px solid #efc983; outline-offset: -1px; }
.equipment-boards .ring-linked { box-shadow: inset 0 0 0 1px #79b29c; }
.equipment-boards .drop-preview { outline: 2px solid #a6dfb3; outline-offset: -2px; }
.equipment-boards .drop-preview:not(.inventory-socket) { background-color: #51ab8050; }
.equipment-pack { grid-area: inventory; padding: 0 0 4px; border-top: 1px solid #ad91556c; border-bottom: 1px solid #ad91556c; }
.pack-header { display: flex; gap: 7px; align-items: center; min-height: 28px; }
.pack-pages { display: flex; gap: 2px; margin-left: auto; }
.pack-pages button {
  min-height: 32px; min-width: 25px; padding: 0 3px; font: 400 14px/1.25 var(--display);
}
.pack-pages button:disabled { opacity: .4; }
.inventory-grid { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 3px; align-items: start; }
.inventory-socket {
  position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 1; min-height: 0; border: 0;
  background: url('./assets/ringsocket.webp') center / 100% 100% no-repeat; image-rendering: pixelated; filter: var(--px);
}
.inventory-ring { cursor: grab; filter: drop-shadow(0 2px 2px #07100c); padding: 2px; }
.inventory-ring::after { content: ''; position: absolute; bottom: 8%; width: 23%; height: 2px; background: var(--socket-gem); box-shadow: 0 0 3px var(--socket-gem); }
.inventory-ring .worn-ring { width: min(76%, 47px); filter: var(--px) drop-shadow(0 2px 1px #070d0a); }
.stow-active .inventory-socket[data-stow] { outline: 1px dashed #9eca9b; outline-offset: -2px; }
.inventory-stow { margin-left: auto; min-height: 24px; color: #ebc58f; background: transparent; border: 0; padding: 2px 3px; font-size: 10px; }
.pack-pages + .inventory-stow { margin-left: 0; }
.inventory-stow::before { content: '↓'; color: #d39069; margin-right: 3px; }
.inventory-stow:hover { color: #ffe4b5; }
.equipment-details { grid-area: effects; padding: 1px 0 3px; min-height: 33px; }
.equipment-detail-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.equipment-detail-heading h3 { color: #f5d693; margin: 0; font: 800 clamp(14px, 4vw, 18px) var(--display); }
.equipment-detail-heading .equipment-finger-name { color: #d2c1a3; font-size: 10px; }
.equipment-detail-heading .worn-ring { width: 34px; margin-block: -1px; }
.equipment-detail-heading button {
  margin-left: auto; min-height: 28px; padding: 1px 4px;
  font: 400 11px/1.15 var(--display);
}
.equipment-detail-heading button::before { content: ''; display: inline-block; width: 5px; height: 5px; margin-right: 5px; vertical-align: .08em; border: 1px solid #e8bb77; transform: rotate(45deg); }
.equipment-details .quality { margin-bottom: 2px; }
.equipment-details .ring-properties { margin: 3px 0 0; max-width: none; }
.equipment-details .ring-property { padding-block: 4px; }
.equipment-details .ring-property dd { font-size: 12px; }
#dialog .equipment-hint { font-size: 11px; color: #d1c1a2; margin: 4px 0 2px; }
.ring-drag-ghost { position: fixed; left: 0; top: 0; transform: translate(-50%,-50%); z-index: 20; display: grid; place-items: center; width: 39px; height: 34px; background: var(--metal-button); border: 1px solid var(--accent); box-shadow: 0 5px 16px #000b; pointer-events: none; }
@media (orientation: landscape) and (min-width: 620px) {
  .equipment-boards { grid-template-columns: minmax(278px,1.2fr) minmax(220px,1fr); grid-template-areas: 'hands inventory' 'hands effects'; grid-template-rows: auto 1fr; align-items: start; gap: 9px 18px; }
  .equipment-hand .hand { height: clamp(124px, 47dvh, 297px); }
  .equipment-fingers { align-self: start; }
}
@media (orientation: landscape) and (max-height: 470px) {
  #dialog[data-layout=equipment] { padding-block: 8px; }
  #dialog .equipment-header h2 { font-size: 22px; }
  .equipment-header { padding-bottom: 3px; }
  .loadout-summary { margin-block: 3px 0; }
  .loadout-stat { padding-block: 0 2px; }
  #dialog .loadout-message { margin: 3px 0 1px; }
  .pack-header { min-height: 22px; }
  .equipment-boards { gap: 4px 12px; }
}
@media (orientation: portrait) {
  #dialog-frame:has(+ #dialog[data-layout=equipment]) {
    background-image: linear-gradient(180deg, #08140ea1, #10231b25 50%, #08140e8c), url('./assets/reliquaryportrait.webp');
    background-size: auto, 100% 100%;
  }
  #title-screen { --title-art: url('./assets/hallportrait.webp'); --title-art-position: 50% 50%; }
  .hud-hand { width: min(calc((100% - 48px) / 2), 224px); }
  .vitals { bottom: max(32px, calc(env(safe-area-inset-bottom) + 25px)); width: clamp(68px, 20vw, 90px); }
  .hud-hand.left { left: max(0px, env(safe-area-inset-left)); }
  .hud-hand.right { right: max(0px, env(safe-area-inset-right)); }
}
@container title-frame (max-height: 440px) {
  .title-content { padding-block: 15px; gap: 8px; }
  .title-relic { width: clamp(27px, 11cqh, 52px); height: clamp(30px, 13cqh, 58px); }
  .title-hero { gap: 4px; }
  .run-setup legend { padding-bottom: 2px; }
  .difficulty { --button-rim-block: 8px; min-height: 38px; gap: 5px; font-size: 15px; }
  .difficulty input { width: 16px; height: 16px; }
  #difficulty-detail { min-height: 0; margin-block: 3px 5px; }
  #start { --button-rim-block: 9px; min-height: 43px; font-size: 19px; }
  .best { margin-top: 4px; }
}
@container title-frame (max-height: 345px) and (min-width: 510px) {
  .title-content {
    grid-template: 'hero setup' 'footer footer' / minmax(0, 1.15fr) minmax(0, 1fr);
    align-items: center; column-gap: clamp(14px, 4cqw, 42px);
  }
  h1 img { max-height: 50cqh; }
}
@container title-frame (max-height: 300px) and (max-width: 509px) {
  .title-content { gap: 5px; padding-block: 12px; }
  .title-relic { display: none; }
  h1 img { max-height: 23cqh; }
  #start { --button-rim-block: 8px; min-height: 39px; }
}
@container title-frame (max-height: 244px) and (max-width: 509px) {
  .title-content { gap: 4px; padding-block: 10px; }
  h1 img { max-height: 16cqh; }
  .difficulty { --button-rim-block: 6px; min-height: 31px; gap: 4px; font-size: 14px; }
  .difficulty input { width: 14px; height: 14px; }
  #difficulty-detail { font-size: 10px; margin-block: 2px 4px; }
  #start { --button-rim-block: 7px; min-height: 36px; font-size: 17px; }
  .instructions, .best { font-size: 9px; }
  .finger-icon { font-size: 10px; }
}
@container difficulty-options (max-width: 294px) {
  .difficulty { --button-rim-inline: 6px; gap: 4px; padding-inline: 1px; font-size: 14px; }
  .difficulty input { width: 14px; height: 14px; }
}
@container difficulty-options (max-width: 239px) {
  .difficulty { --button-rim-inline: 5px; gap: 3px; font-size: 12px; }
  .difficulty input { width: 12px; height: 12px; }
}
@media (max-height: 340px) {
  .title-control { flex-direction: row; gap: 5px; min-width: 0; }
  .title-control .gothic-face { width: 30px; }
}

@media (max-width: 375px) {
  .loadout-stat { padding-inline: 7px; }
  .hud-buttons { margin-right: -4px; }
  .hud-button { width: 39px; }
  .equipment-detail-heading .equipment-finger-name { font-size: 9px; }
}


.survey-map {
  display: block; width: min(100%, 56vh, 450px); height: auto; margin-inline: auto;
  background: #23241b; border: 1px solid #9e8557; image-rendering: pixelated;
}
#dialog .survey-caption { margin: 8px 0 4px; color: #debf87; }
