@font-face {
  font-family: "Room Reset UI";
  src: url("./assets/fonts/pretendard-ui.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Black Han Sans";
  src: url("./assets/fonts/black-han-sans-title.woff2") format("woff2");
  font-display: swap;
}
:root {
  color-scheme: dark;
  --ink: #141414; --panel: #232323; --line: #656565; --text: #f7f7f5;
  --muted: #b5b5b2; --signal: #ff583e; --caution: #ffad91; --reward: #ffda6a;
  --number: "Room Reset UI","Segoe UI",sans-serif;
  font-family: "Room Reset UI","Malgun Gothic","Apple SD Gothic Neo",sans-serif;
}
*, *::before,*::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--text); background: #141414; }
h1,h2,p { margin: 0; }
button,a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
button:not(:disabled), a[href] { cursor: pointer; }
button:focus-visible,a:focus-visible,canvas:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
a { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.arcade-shell { max-width: 1140px; margin: auto; padding: clamp(4px,2.4vh,22px) clamp(4px,2.5vw,22px) 16px; }
.room-stage {
  position: relative; overflow: hidden; isolation: isolate; outline: none;
  height: clamp(475px,76svh,685px); touch-action: none;
  border: 1px solid var(--line); outline-offset: -3px; background: #303831;
}
.room-stage::after { content: ''; position: absolute; z-index: 2; inset: 0; border: 1px solid transparent; pointer-events: none; }
.room-stage[data-impacted="true"]::after { border-color: var(--signal); }
.room-stage[data-phase="upgrade"] :is(#arenaLayers,#backdropCanvas,#shellCanvas) { filter: brightness(.67); }
#arenaLayers { position: absolute; inset: 0; pointer-events: none; }
#backdropCanvas,#shellCanvas,#arenaLayers { transform: var(--battle-shift, none); }
canvas { width: 100%; height: 100%; position: absolute; display: block; inset: 0; image-rendering: pixelated; }

.combat-hud,.stage-record,.boss-bar,.stage-callout,.combo,.room-error { position: absolute; z-index: 3; pointer-events: none; }
.boss-bar,.combo {
  background: #141414eb;
  clip-path: polygon(0 0,100% 0,100% calc(100% - 7px),calc(100% - 7px) 100%,0 100%);
}
.combat-hud { left: 15px; top: 13px; color: var(--text); white-space: nowrap; }
.hud-readings { display: flex; align-items: start; gap: 16px; }
.hud-stat { display: grid; gap: 2px; font-size: 13px; line-height: 1.1; text-align: left; }
.hud-stat:first-child { min-width: 70px; }
.hud-stat strong {
  font: 850 24px/1 var(--number); font-variant-numeric: tabular-nums;
}
.hud-stat strong,.stage-record strong {
  color: var(--text);
  -webkit-text-stroke: 4px #141414; paint-order: stroke fill;
}
.hud-stat > b,.hud-context,.stage-record small {
  -webkit-text-stroke: 3px #141414; paint-order: stroke fill;
}
.room-stage[data-low-health="true"] #healthText,
.room-stage[data-low-health="true"] .hud-stat:first-child > b { color: var(--caution); }
.hud-context { display: flex; align-items: baseline; gap: 8px; margin-top: 5px; font-size: 11px; font-weight: 700; line-height: 1.15; }
.hud-zone { display: flex; gap: 4px; align-items: baseline; }
.hud-zone span { font-variant-numeric: tabular-nums; }
.hud-zone strong { font: inherit; }
.arcade-tools { position: absolute; z-index: 5; right: 14px; top: 13px; display: flex; gap: 3px; }
.arcade-tools .game-button {
  --face: #141414; --lip: #666666; --shade: #090909;
  border: 1px solid var(--lip); border-radius: 50%; clip-path: none;
}
#pauseButton { appearance: none; background: transparent; border: 0; }
.stage-record { top: 13px; right: 57px; display: flex; align-items: baseline; gap: 6px; padding: 6px 9px 5px; }
.stage-record small { color: #e5e5e3; font-size: 12px; font-weight: 700; }
.stage-record strong { font: 850 27px/1 var(--number); font-variant-numeric: tabular-nums; }
.combo { top: 55px; right: 57px; padding: 4px 10px 4px 7px; background: var(--reward); color: var(--ink); font: 850 14px var(--number); }
.room-stage[data-phase="ready"] :is(.combat-hud,.stage-record,#pauseButton,.touch-controls),
.room-stage:not([data-phase="ready"]):not([data-paused="true"]) :is(#soundButton,#helpButton),
.room-stage[data-paused="true"] :is(#pauseButton,.touch-controls),
.room-stage:is([data-phase="lost"],[data-phase="won"]) :is(.arcade-tools,.touch-controls) { display: none; }
.room-stage[data-paused="true"] .stage-record { top: 55px; right: 14px; }
.room-stage:is([data-phase="lost"],[data-phase="won"]) .stage-record { right: 14px; }
.boss-bar { left: 50%; top: 13px; transform: translateX(-50%); width: min(calc(100% - 450px),400px); padding: 6px 8px; }
.boss-bar > div:first-child { display: flex; justify-content: space-between; align-items: center; gap: 4px; margin-bottom: 5px; }
.boss-bar b,.boss-bar span { font-size: 11px; font-weight: 800; }
.boss-bar span { color: var(--caution); }
.boss-track { height: 8px; background: #40312e; border: 1px solid #8e6f65; overflow: hidden; }
.boss-track i { display: block; height: 100%; background: var(--caution); box-shadow: inset 0 -2px #b95d49; }
.stage-callout {
  left: 50%; bottom: 15px; transform: translateX(-50%); max-width: 65%; width: max-content;
  padding: 5px 9px; background: var(--ink); text-align: center; font-size: 13px; font-weight: 800;
}
.stage-callout[data-danger="true"] { border-left: 3px solid var(--caution); color: var(--caution); }
.stage-callout[data-combo="true"] { background: var(--reward); color: var(--ink); font-size: 16px; }
.room-error { right: 15px; bottom: 119px; font-size: 10px; color: var(--muted); }

.stage-banner {
  position: absolute; inset: 0; z-index: 4; pointer-events: none; display: grid; place-content: end center;
  padding: 12px 14px 30px;
}
.stage-banner[data-menu="ready"] {
  inset: auto 0 0; display: flex; align-items: end; justify-content: space-between; gap: 8px;
  padding: 30px 20px 15px; background: linear-gradient(transparent,#101010e8 75%);
}
.arcade-title { display: none; min-width: 0; text-align: left; }
.stage-banner[data-menu="ready"] .arcade-title { display: block; }
.arcade-title h1 { font: 400 clamp(30px,5vw,62px)/.96 "Black Han Sans",sans-serif; letter-spacing: -.055em; text-shadow: 2px 3px #171717; }
.arcade-title p { margin-top: 5px; color: var(--text); font-size: 13px; font-weight: 650; line-height: 1.25; text-shadow: 0 1px 2px #000; }
.game-button {
  --face: var(--panel); --shade: #090909; --lip: #747474;
  appearance: none; min-height: 37px; border: 2px solid var(--lip); border-radius: 0;
  background: var(--face); box-shadow: inset 0 -3px var(--shade);
  color: var(--text); font-weight: 900;
  clip-path: polygon(0 5px,5px 5px,5px 0,calc(100% - 5px) 0,calc(100% - 5px) 5px,100% 5px,100% calc(100% - 5px),calc(100% - 5px) calc(100% - 5px),calc(100% - 5px) 100%,5px 100%,5px calc(100% - 5px),0 calc(100% - 5px));
}
.game-button:hover:not(:disabled) { filter: brightness(1.18); }
.game-button:active:not(:disabled),.game-button[data-down="true"] { transform: translateY(2px); filter: brightness(1.3); box-shadow: inset 0 -1px var(--shade); }
.game-button:focus-visible { outline: none; border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text), inset 0 -3px var(--shade); }
.game-button:disabled { color: #929292; --face: #292929; --lip: #535353; }
.icon-button { width: 37px; min-height: 36px; padding: 0; display: grid; place-items: center; }
.primary { --face: var(--signal); --shade: #a62f21; --lip: #ff8a76; color: #171717; padding: 9px 16px; font-size: 13px; }
.secondary { display: inline-flex; align-items: center; padding: 8px 13px; font-size: 12px; text-decoration: none; }
.start-button { pointer-events: auto; min-width: 108px; min-height: 44px; padding: 7px 12px 9px; white-space: nowrap; font-size: 17px; }

.touch-controls { position: absolute; inset: auto auto 12px 13px; z-index: 4; pointer-events: none; }
.touch-controls button { pointer-events: auto; -webkit-user-select: none; user-select: none; touch-action: none; padding: 0; }
.dpad { display: grid; grid-template-columns: repeat(3,40px); grid-template-rows: repeat(2,38px); gap: 2px; }
.dpad::before {
  content: ''; position: absolute; inset: 0; background: #141414e8;
  clip-path: polygon(33.6% 3px,66.4% 3px,66.4% 50%,calc(100% - 3px) 50%,calc(100% - 3px) calc(100% - 5px),3px calc(100% - 5px),3px 50%,33.6% 50%);
}
.dpad button { position: relative; min-height: 0; display: grid; place-items: center; border: 0; background: transparent; box-shadow: none; clip-path: none; }
.dpad button:hover { background: #fff2; }
.dpad button:focus-visible { box-shadow: inset 0 0 0 2px var(--text); }
.dpad button[data-down="true"] { background: var(--text); color: var(--ink); filter: none; }
.dpad .north { grid-area: 1/2; } .dpad .west { grid-area: 2/1; } .dpad .south { grid-area: 2/2; } .dpad .east { grid-area: 2/3; }
.pixel-icon { position: relative; display: block; width: 16px; height: 16px; }
.pixel-icon::before,.pixel-icon::after { content: ''; position: absolute; background: currentColor; }
.arrow-icon::before {
  inset: 1px; clip-path: polygon(43% 0,57% 0,57% 14%,71% 14%,71% 28%,86% 28%,86% 43%,64% 43%,64% 100%,36% 100%,36% 43%,14% 43%,14% 28%,29% 28%,29% 14%,43% 14%);
}
.west .arrow-icon { rotate: -90deg; }
.east .arrow-icon { rotate: 90deg; }
.south .arrow-icon { rotate: 180deg; }
.pause-icon::before,.pause-icon::after { width: 4px; height: 14px; top: 1px; outline: 2px solid var(--ink); }
.pause-icon::before { left: 1px; }
.pause-icon::after { right: 1px; }
.sound-icon::before { inset: 2px 6px 2px 0; clip-path: polygon(0 34%,40% 34%,40% 17%,65% 17%,65% 0,100% 0,100% 100%,65% 100%,65% 83%,40% 83%,40% 66%,0 66%); }
.sound-icon::after { inset: 3px 0 3px 12px; clip-path: polygon(0 0,50% 0,50% 20%,100% 20%,100% 80%,50% 80%,50% 100%,0 100%,0 80%,50% 80%,50% 20%,0 20%); }
[aria-pressed="false"] .sound-icon::after { inset: 3px 7px; rotate: 45deg; box-shadow: 0 0 0 1px var(--panel); clip-path: none; }
.help-icon::before { inset: 1px 3px 5px; clip-path: polygon(20% 0,80% 0,80% 20%,100% 20%,100% 60%,80% 60%,80% 80%,60% 80%,60% 100%,40% 100%,40% 60%,60% 60%,60% 40%,80% 40%,80% 20%,20% 20%,20% 40%,0 40%,0 20%,20% 20%); }
.help-icon::after { width: 2px; height: 2px; bottom: 1px; left: 7px; }

.affiliate-panel { margin-top: 11px; }
.affiliate-disclosure { margin: 0 2px 7px; color: #d2cdc3; font-size: 12px; line-height: 1.45; }
.affiliate-banner {
  display: grid; grid-template-columns: 115px minmax(0,1fr) auto; grid-template-areas: "product copy action";
  align-items: center; gap: 18px; padding: 3px 16px 3px 5px; color: var(--text);
  background: #28231d; border: 1px solid #756346; border-left: 3px solid var(--reward); text-decoration: none;
}
.affiliate-banner:hover { background: #31291e; border-color: var(--reward); }
.affiliate-banner img {
  grid-area: product; display: block; width: 115px; height: 101px; object-fit: contain; image-rendering: pixelated;
  filter: drop-shadow(0 3px 0 #15120d);
}
.affiliate-copy { grid-area: copy; min-width: 0; }
.affiliate-copy small { display: block; color: #dacbb8; font-size: 13px; font-weight: 650; margin-bottom: 4px; }
.affiliate-copy strong { display: block; font-size: clamp(19px,2.4vw,26px); font-weight: 850; line-height: 1.18; }
.affiliate-copy strong span { display: inline-block; }
.affiliate-cta {
  grid-area: action; justify-self: start; display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 14px; background: var(--reward); color: #1f1a10;
  box-shadow: inset 0 -3px #bd963e; white-space: nowrap; font-size: 15px; font-weight: 850;
}
.affiliate-banner:hover .affiliate-cta { background: #ffe592; }

.dialog { width: min(530px,calc(100% - 26px)); max-height: calc(100% - 28px); color: var(--text); padding: 0; background: var(--ink); border: 1px solid var(--line); border-top: 3px solid var(--text); box-shadow: 0 0 0 2px #090909, 5px 7px 0 #000c; }
.dialog::backdrop { background: #0b0b0bcc; }
.dialog-content { padding: 17px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; gap: 8px; margin-bottom: 11px; }
.dialog h2 { font-size: 23px; letter-spacing: -.06em; margin-block: 5px; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .07em; }
.close-button { width: 32px; min-height: 32px; font-size: 21px; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.55; }
.dialog-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.upgrade-dialog {
  position: fixed; inset: var(--upgrade-y,50%) auto auto var(--upgrade-x,50%); transform: translate(-50%,-50%);
  width: min(596px,var(--upgrade-width,calc(100% - 18px))); margin: 0; max-width: calc(100% - 12px);
}
.upgrade-dialog::backdrop { background: #0b0b0b38; }
.module-screen { padding: 14px 15px 11px; }
.module-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 1px 12px; }
.module-heading h2 { margin: 0; font-size: clamp(19px,3.7vw,26px); }
.module-heading p { border: 1px solid #6c6c6c; padding: 3px 6px; color: var(--text); font-size: 11px; font-weight: 800; white-space: nowrap; }
.upgrades { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); background: #222; border-block: 1px solid #656565; }
.upgrade-card {
  position: relative; appearance: none; min-width: 0; display: grid;
  justify-items: center; align-content: start; grid-template-rows: auto auto minmax(34px,auto);
  gap: 6px; padding: 12px 5px 15px; text-align: center; border: 0;
  background: transparent; box-shadow: inset 0 -3px #101010;
}
.upgrade-card + .upgrade-card { border-left: 1px solid #555; }
.upgrade-card::before { content: ''; position: absolute; bottom: 0; left: calc(50% - 7px); width: 14px; height: 8px; background: transparent; clip-path: polygon(50% 0,100% 100%,0 100%); }
.upgrade-card:hover:not(:focus) { background: #303030; }
.upgrade-card:focus {
  outline: none; background: #302524; box-shadow: inset 0 -2px var(--signal);
}
.upgrade-card:focus::before { background: var(--signal); }
.upgrade-card:active { transform: translateY(2px); }
.upgrade-card > kbd { position: absolute; top: 8px; left: 8px; min-width: 19px; padding: 0 2px; background: var(--ink); color: var(--text); font: 700 12px/19px var(--number); }
.upgrade-card:focus > kbd { background: var(--signal); color: #171717; }
.upgrade-icon { width: 72px; height: 72px; border-radius: 50%; background: #151515; image-rendering: pixelated; }
.upgrade-card strong { font-size: clamp(14px,2.9vw,18px); line-height: 1.2; }
.upgrade-stats { align-self: center; display: grid; gap: 2px; color: #dededc; font-size: 13px; line-height: 1.35; }
.module-controls { display: flex; justify-content: center; gap: 14px; color: #dededc; font-size: 12px; padding-top: 10px; }
.module-controls kbd { padding: 1px 3px; background: #383838; color: var(--text); font: 700 11px/1.5 var(--number); }
.module-controls .vertical-keys { display: none; }
.upgrade-dialog[open] .module-screen { animation: rack-in 135ms steps(3,end); }
@keyframes rack-in { from { opacity: .45; translate: 0 5px; } }
@media (prefers-reduced-motion:reduce) { .upgrade-dialog[open] .module-screen { animation: none; } }
.result-meters { display: grid; grid-template-columns: repeat(3,1fr); margin-block: 14px; padding-block: 6px; border-block: 1px solid var(--line); }
.result-cell { padding: 3px 4px; text-align: center; }
.result-cell + .result-cell { border-left: 1px solid #565656; }
.result-cell small { display: block; color: #e2e2e0; font-size: 12px; margin-bottom: 4px; }
.result-cell strong { color: var(--text); font: 800 23px var(--number); }
.product-stage { position: relative; overflow: hidden; height: clamp(190px,40vh,335px); border: 1px solid var(--line); background: #313a31; }
.product-stage canvas { touch-action: none; cursor: grab; }
.orbit-controls { position: absolute; bottom: 6px; right: 6px; display: flex; gap: 4px; }
.orbit-controls button { width: 32px; min-height: 32px; font-size: 15px; }
.product-facts { color: var(--muted); font-size: 11px; margin-top: 10px; }
.disclosure { margin-block: 9px; padding: 7px; color: var(--text); background: var(--panel); border-left: 2px solid var(--text); font-size: 11px; line-height: 1.5; }
.help-list { padding-left: 18px; color: var(--text); font-size: 12px; line-height: 1.65; }
.help-list li { margin: 7px 0; }

@media(max-width:630px) {
  .arcade-shell { padding: 5px 4px 11px; }
  .room-stage { height: clamp(405px,77svh,590px); }
  .combat-hud { top: 8px; left: 9px; }
  .hud-stat { font-size: 15px; }
  .hud-stat strong { font-size: 28px; }
  .hud-context { flex-wrap: wrap; width: 145px; gap: 2px 7px; }
  .arcade-tools { top: 7px; right: 7px; gap: 3px; }
  .icon-button { width: 44px; min-height: 44px; }
  .stage-record { top: 7px; right: 55px; gap: 4px; padding: 6px 7px 5px; }
  .stage-record strong { font-size: 24px; }
  .room-stage[data-paused="true"] .stage-record { top: 56px; right: 7px; }
  .room-stage:is([data-phase="lost"],[data-phase="won"]) .stage-record { right: 7px; }
  .combo { top: 50px; right: 7px; font-size: 13px; }
  .boss-bar { top: 88px; left: 6px; transform: none; width: min(calc(100% - 12px),228px); }
  .boss-track { height: 6px; }
  .touch-controls { left: 8px; bottom: 10px; }
  .dpad { grid-template-columns: repeat(3,44px); grid-template-rows: repeat(2,44px); }
  .stage-banner[data-menu="ready"] { padding: 24px 10px 11px; }
  .arcade-title h1 { font-size: clamp(26px,8.6vw,51px); white-space: nowrap; }
  .arcade-title p { margin-top: 4px; font-size: 12px; }
  .start-button { min-width: 80px; font-size: 15px; }
  .stage-callout { bottom: 108px; max-width: 90%; font-size: 11px; }
  .stage-callout[data-combo="true"] { font-size: 14px; }
  .affiliate-panel { margin-top: 10px; }
  .affiliate-banner {
    grid-template-columns: 88px minmax(0,1fr); grid-template-areas: "product copy" "product action";
    gap: 5px 10px; padding: 6px 10px 7px 4px;
  }
  .affiliate-banner img { width: 88px; height: 86px; }
  .affiliate-copy small { font-size: 12px; }
  .affiliate-cta { min-height: 36px; padding-inline: 11px; font-size: 13px; }
}

@media(max-width:470px) {
  .module-screen { padding: 10px 8px; }
  .upgrades { grid-template-columns: minmax(0,1fr); }
  .upgrade-card {
    grid-template-columns: 48px minmax(0,1fr) 19px; grid-template-rows: auto auto;
    justify-items: start; align-items: center; column-gap: 8px; row-gap: 2px;
    padding: 8px 10px 8px 12px; text-align: left; box-shadow: none;
  }
  .upgrade-card + .upgrade-card { border-left: 0; border-top: 1px solid #565656; }
  .upgrade-card::before { top: calc(50% - 7px); left: 0; width: 7px; height: 14px; clip-path: polygon(0 0,100% 50%,0 100%); }
  .upgrade-card:focus { box-shadow: inset 3px 0 var(--signal); }
  .upgrade-card > kbd { position: static; grid-area: 1/3/3/4; text-align: center; }
  .upgrade-icon { grid-area: 1/1/3/2; width: 48px; height: 48px; }
  .upgrade-card strong { grid-area: 1/2; align-self: end; font-size: 16px; }
  .upgrade-stats { grid-area: 2/2; align-self: start; gap: 0; }
  .module-controls .horizontal-keys { display: none; }
  .module-controls .vertical-keys { display: inline; }
}

@media(max-width:310px) {
  .hud-readings { gap: 12px; }
  .stage-record small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .stage-record strong { font-size: 20px; }
  .affiliate-banner { grid-template-columns: 71px minmax(0,1fr); gap: 6px 7px; }
  .affiliate-banner img { width: 71px; height: 86px; }
}
