:root {
  color-scheme: dark;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", system-ui, sans-serif;
  background: #090606;
  --red: #b52724;
  --gold: #e0b85b;
  --cream: #f5e6c2;
  --panel: rgba(18, 10, 10, 0.9);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #090606;
}

button, a { -webkit-tap-highlight-color: transparent; }

#game-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #120b0a;
  touch-action: none;
  user-select: none;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #120b0a;
}

.hidden { display: none !important; }
.mission-card {max-height:calc(100dvh - 32px);overflow:auto;overscroll-behavior:contain;touch-action:pan-y;}
#mission-screen {z-index:25;padding:16px;background:rgba(8,12,15,.78);}
#mission-body {font:clamp(15px,2.2vw,20px)/1.55 system-ui,sans-serif;margin:20px 0 26px;}
@media(max-height:450px){.mission-card{padding:18px!important;}.mission-card h2{font-size:24px!important;margin:6px 0!important;}#mission-body{margin:10px 0 14px;}.mission-card .primary-button{padding:12px;}}

.game-tools {display:flex;gap:6px;align-items:center;pointer-events:auto;}
.game-tools button {position:relative;width:44px;height:44px;display:flex;align-items:center;justify-content:center;background:var(--panel);color:#fff6dd;border:1px solid #b58a43;border-radius:7px;cursor:pointer;touch-action:manipulation;}
.notice-button span:not(:empty) {position:absolute;right:-5px;top:-6px;border-radius:10px;background:#b52724;color:white;font:700 11px system-ui;padding:2px 5px;}
.notice-panel {position:absolute;z-index:16;right:max(10px,env(safe-area-inset-right));top:max(10px,env(safe-area-inset-top));bottom:max(10px,env(safe-area-inset-bottom));width:min(390px,calc(100% - 20px));max-height:620px;overflow:auto;overscroll-behavior:contain;touch-action:pan-y;background:#132128;color:#ecf0ee;border:2px solid #78989c;border-radius:8px;padding:14px;font:14px/1.5 system-ui,sans-serif;user-select:text;}
.notice-panel header {display:flex;align-items:center;justify-content:space-between;gap:12px;}
.notice-panel button {min-width:40px;min-height:40px;background:#263b44;color:white;border:1px solid #78989c;font-size:25px;cursor:pointer;}
.notice-warning {font-size:12px;color:#e0b85b;margin:8px 0 16px;}
.notice-current {padding:12px;background:#244048;border-left:3px solid #90d1d0;}
.notice-panel ol {padding-left:22px;}
.notice-panel li {margin:0 0 15px;padding-left:3px;}
.notice-panel small {display:block;color:#90b5bf;font-size:11px;}
@media (max-height:500px) {.notice-panel{font-size:13px;padding:10px;}}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: rgba(5, 3, 3, 0.72);
  backdrop-filter: blur(3px);
}

.overlay--title {
  justify-items: start;
  overflow-y: auto;
  backdrop-filter: none;
  background: linear-gradient(90deg, rgba(9, 5, 5, 0.98) 0%, rgba(9, 5, 5, 0.9) 40%, rgba(9, 5, 5, 0.18) 75%, rgba(9, 5, 5, 0.68) 100%);
}

.title-copy {
  width: min(650px, 94vw);
  padding: clamp(20px, 4vw, 52px);
  border-left: 6px solid var(--red);
  background: linear-gradient(90deg, rgba(8, 5, 5, 0.94), rgba(8, 5, 5, 0.56));
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--gold);
  font: 800 12px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.16em;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 18px;
  color: #fff8df;
  font-size: clamp(45px, 8vw, 92px);
  line-height: 0.82;
  letter-spacing: -0.035em;
  text-shadow: 4px 4px 0 #28110e, 7px 7px 0 rgba(0, 0, 0, 0.5);
}

h1 span { color: #d63a31; }

.lede {
  max-width: 570px;
  margin-bottom: 22px;
  color: #eee3cf;
  font: 700 clamp(15px, 2vw, 20px)/1.35 system-ui, sans-serif;
}

.primary-button {
  min-height: 52px;
  padding: 12px 22px;
  border: 3px solid #140b09;
  outline: 2px solid var(--gold);
  color: #fff7df;
  background: linear-gradient(#cb3930, #841d1a);
  box-shadow: 6px 6px 0 #000;
  font: 900 18px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.primary-button:active { transform: translate(3px, 3px); box-shadow: 3px 3px 0 #000; }

.access-form { width: min(440px, 100%); margin: 0 0 18px; }
.access-form label { display: block; margin-bottom: 7px; color: #d8bc79; font: 800 11px/1 ui-monospace, monospace; letter-spacing: .12em; }
.access-form__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; align-items: stretch; }
.access-form input { min-width: 0; border: 3px solid #2a1713; outline: 2px solid #9a773e; padding: 0 13px; color: #fff4d6; background: rgba(13, 7, 6, .94); font: 800 18px/1 ui-monospace, monospace; }
.access-form .primary-button { min-height: 48px; font-size: 14px; }
.access-error { margin: 10px 0 0; color: #ff796f; font: 800 12px/1.2 system-ui, sans-serif; }

.controls-copy {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 16px;
  margin-top: 22px;
  color: #cdbda8;
  font: 700 12px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.controls-copy b { color: #fff; }
.legal { margin: 18px 0 0; color: #8f8174; font: 11px/1.4 system-ui, sans-serif; }

.hud {
  position: absolute;
  z-index: 8;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  width: min(800px, calc(100% - 20px));
  display: grid;
  grid-template-columns: 92px 76px minmax(0,1fr) 112px 94px;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.hud-chip {
  min-width: 0;
  padding: 7px 10px;
  border: 2px solid #321d17;
  outline: 1px solid #b58a43;
  text-align: center;
  background: var(--panel);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.55);
}

.hud-chip small { display: block; color: #bda47a; font: 700 8px/1 ui-monospace, monospace; letter-spacing: .1em; }
.hud-chip strong { display: block; overflow: hidden; margin-top: 3px; color: #fff6dd; font-size: 22px; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }
.hud-chip--objective strong { color: var(--gold); font: 900 13px/1.1 ui-monospace, monospace; }

.crosshair {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.crosshair::before, .crosshair::after { content: ""; position: absolute; background: #fff4ce; box-shadow: 0 0 3px #000; }
.crosshair::before { left: 9px; top: 1px; width: 2px; height: 18px; }
.crosshair::after { left: 1px; top: 9px; width: 18px; height: 2px; }

.toast {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: clamp(98px, 19vh, 160px);
  max-width: min(500px, 86vw);
  padding: 10px 14px;
  transform: translateX(-50%);
  border: 2px solid var(--gold);
  color: #fff7df;
  text-align: center;
  background: rgba(18, 8, 7, 0.94);
  font: 800 14px/1.25 system-ui, sans-serif;
  pointer-events: none;
}

.damage-flash { position: absolute; z-index: 6; inset: 0; background: #d51010; opacity: 0; pointer-events: none; transition: opacity 120ms; }
.damage-flash.is-active { opacity: 0.28; transition: none; }

.fullscreen-button {
  font-size: 22px;
}

.diploma .message-card {background:linear-gradient(135deg,#651e2d,#32131d);border:3px double #d5ae61;outline:1px solid #8f6938;outline-offset:-12px;box-shadow:0 20px 80px #000a;padding:42px;}
.diploma #message-title {color:#f2d18a;letter-spacing:.06em;}
.diploma #message-body {white-space:pre-line;color:#f3e4c8;line-height:1.6;}
.diploma .eyebrow {color:#d5ae61;}
.overlay--message {overflow-y:auto;place-items:safe center;}
@media(max-height:520px) {.diploma .message-card{padding:24px;}.diploma #message-title{font-size:28px;}.diploma #message-body{font-size:13px;line-height:1.35;}}

.rotate-prompt { display: none; }

.mobile-controls { position: absolute; z-index: 10; inset: 0; pointer-events: none; }
.stick { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom)); width: 126px; height: 126px; border: 2px solid rgba(240, 211, 151, .55); border-radius: 50%; background: rgba(12, 7, 6, .45); pointer-events: auto; touch-action: none; }
.stick__knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; transform: translate(-50%, -50%); border: 2px solid #efcf86; border-radius: 50%; background: rgba(143, 37, 31, .82); box-shadow: 0 5px 12px #0008; }
.look-zone { position: absolute; right: 0; top: 80px; bottom: 0; width: 54%; pointer-events: auto; touch-action: none; }
.action-button { position: absolute; z-index: 2; width: 70px; height: 70px; border: 2px solid #e3c276; border-radius: 50%; color: white; background: rgba(87, 25, 21, .88); box-shadow: 0 5px 0 #1c0b09; font: 900 12px/1 ui-monospace, monospace; pointer-events: auto; touch-action: none; }
.action-button:active { transform: translateY(3px); box-shadow: 0 2px 0 #1c0b09; }
.action-button--fire { right: max(18px, env(safe-area-inset-right)); bottom: max(24px, env(safe-area-inset-bottom)); width: 84px; height: 84px; background: rgba(176, 38, 31, .92); }
.action-button--use { right: max(106px, calc(env(safe-area-inset-right) + 88px)); bottom: max(104px, calc(env(safe-area-inset-bottom) + 80px)); }
.action-button--blast { right: max(112px, calc(env(safe-area-inset-right) + 94px)); bottom: max(14px, env(safe-area-inset-bottom)); width:58px;height:58px;background:#285261; }

.message-card { width: min(560px, 92vw); padding: clamp(24px, 5vw, 46px); border: 3px solid var(--gold); background: #170d0c; box-shadow: 12px 12px 0 #050202; text-align: center; }
.message-card h2 { margin-bottom: 16px; color: #fff5da; font-size: clamp(34px, 7vw, 66px); line-height: .9; }
.message-card p:not(.eyebrow) { color: #dacbb6; font: 600 16px/1.5 system-ui, sans-serif; }
.secondary-link { display: block; margin-top: 22px; color: #cfb774; font: 700 13px/1.2 system-ui, sans-serif; }

.overlay--lift { z-index: 18; background: rgba(4, 3, 4, .72); }
.lift-card { position: relative; width: min(520px, 94vw); padding: clamp(24px, 5vw, 44px); border: 3px solid #bd9150; background: linear-gradient(145deg, #25262a, #0e0f12); box-shadow: 12px 12px 0 #050202; }
.lift-card h2 { margin: 0 0 20px; color: #fff1ce; font-size: clamp(28px, 6vw, 48px); }
.lift-close { position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; border: 1px solid #9f7a43; color: #fff; background: #171214; font: 900 25px/1 monospace; cursor: pointer; }
.lift-floors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.lift-floor { min-height: 64px; border: 2px solid #080808; outline: 1px solid #b68b4b; color: #fff0ca; background: linear-gradient(#4a4b50, #24252a); box-shadow: 3px 3px 0 #080808; font: 900 24px/1 monospace; cursor: pointer; }
.lift-floor small { display: block; margin-top: 5px; color: #c8a86e; font: 700 7px/1.1 system-ui, sans-serif; }
.lift-floor.is-current { color: #180a08; background: #e3bd68; }
.lift-floor:disabled { color: #746b5d; background: linear-gradient(#292a2d, #17181b); cursor: not-allowed; box-shadow: none; opacity: .72; }
.lift-floor:disabled small { color: #746b5d; }
.lift-note { margin: 18px 0 0; color: #bdad92; font: 700 11px/1.45 system-ui, sans-serif; }

@media (pointer: coarse), (max-width: 780px) {
  .mobile-controls:not(.hidden) { display: block; }
  .hud { grid-template-columns: 62px 50px minmax(0,1fr) 74px 94px; gap:5px; }
  .hud-chip { padding-inline: 5px; }
  .hud-chip strong { font-size: 18px; }
  .hud-chip--objective strong { font-size: 10px; }
  .overlay--title { place-items: start stretch; padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); background-position: 62% center; }
  .title-copy { width: 100%; margin: auto 0; align-self: center; padding: 18px 15px; border-left-width: 4px; }
  .eyebrow { margin-bottom: 6px; font-size: 10px; }
  h1 { margin-bottom: 12px; font-size: clamp(34px, 11vw, 58px); line-height: .86; text-shadow: 3px 3px 0 #28110e, 5px 5px 0 rgba(0, 0, 0, 0.5); }
  .lede { margin-bottom: 15px; font-size: 13px; line-height: 1.28; }
  .controls-copy { display: none; }
  .access-form__row { grid-template-columns: 1fr; }
  .access-form input { min-height: 48px; }
  .access-form { margin-bottom: 12px; }
  .legal { margin-top: 12px; font-size: 9px; }
  .lift-floors { grid-template-columns: repeat(3, 1fr); }
}

@media (max-height: 650px) and (pointer: coarse) {
  .overlay--title { align-items: start; }
  .title-copy { margin: 0; }
  h1 { font-size: clamp(30px, 9.5vw, 46px); }
  .lede { font-size: 12px; }
}

@media (max-height: 520px) and (pointer: coarse) {
  .overlay--lift {
    place-items: start center;
    overflow-y: auto;
    padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }
  .lift-card { width: min(760px, 100%); margin: auto 0; padding: 14px 18px 12px; box-shadow: 6px 6px 0 #050202; }
  .lift-card .eyebrow { margin: 0 42px 4px 0; }
  .lift-card h2 { margin-bottom: 9px; font-size: 24px; }
  .lift-close { top: 7px; right: 7px; width: 32px; height: 32px; font-size: 21px; }
  .lift-floors { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
  .lift-floor { min-height: 46px; font-size: 19px; box-shadow: 2px 2px 0 #080808; }
  .lift-floor small { margin-top: 2px; font-size: 6px; }
  .lift-note { margin-top: 8px; font-size: 9px; line-height: 1.25; }
  .stick { width: 104px; height: 104px; }
  .stick__knob { width: 46px; height: 46px; }
  .action-button--fire { width: 70px; height: 70px; font-size:10px; }
  .action-button--use { right: 96px; bottom: 76px; width: 58px; height: 58px; }
  .hud { top: 6px; }
}

@media (min-width: 0px) {
  .game-running.doom-portrait .rotate-prompt {
    position: fixed;
    inset: 0;
    pointer-events: auto;
    z-index: 40;
    display: grid;
    place-content: center;
    gap: 10px;
    padding: 24px;
    color: #fff4d6;
    text-align: center;
    background: #120b0a;
  }
  .rotate-prompt span { color: var(--gold); font-size: 64px; }
  .rotate-prompt strong { font: 900 22px/1.2 ui-monospace, monospace; }
  .rotate-prompt small { color: #cdbda8; font: 700 13px/1.3 system-ui, sans-serif; }
}

/* One static cover: no animated layers or extra game-loop work on the title. */
.overlay--title {
  background: linear-gradient(90deg,rgba(5,8,14,.86),rgba(5,8,14,.45) 43%,rgba(5,8,14,.04) 72%), url('./assets/title-gothic-v1.webp') center / cover no-repeat;
  touch-action:pan-y;
}
.title-copy {
  width:min(640px,52vw);padding:clamp(20px,3vw,42px);
  border-left:2px solid #b99a60;background:linear-gradient(90deg,rgba(8,10,16,.7),rgba(8,10,16,.08));
}
.overlay--title h1 {font-family:Georgia,'Times New Roman',serif;font-size:clamp(38px,4.4vw,70px);line-height:.98;letter-spacing:-.035em;text-shadow:0 3px 20px #000;}
.overlay--title h1 span {display:inline-block;margin-top:12px;color:#d0ac6c;font-size:.64em;letter-spacing:.04em;}
.overlay--title .lede {font-weight:400;font-size:clamp(14px,1.2vw,17px);line-height:1.55;color:#ddd9d3;}
.overlay--title .primary-button {border:1px solid #e3bd79;outline:none;background:linear-gradient(#8f302c,#541a22);box-shadow:0 4px 20px #0008;border-radius:3px;}
.overlay--title .access-form input {border:1px solid #9c8259;outline:none;border-radius:3px;}
@media (max-width:700px) and (orientation:portrait) {
  .overlay--title {background-position:72% center;}
  .overlay--title .title-copy {width:100%;margin-top:18dvh;background:linear-gradient(#080b13cf,#080b13ed);padding:22px 18px;}
  .overlay--title h1 {font-size:clamp(34px,8vw,48px);}
}
@media (max-height:520px) and (orientation:landscape) {
  .overlay--title .title-copy {width:min(590px,67vw);padding:14px 18px;margin:0;}
  .overlay--title h1 {font-size:32px;margin-bottom:12px;}
  .overlay--title h1 span {margin-top:5px;}
  .overlay--title .lede {font-size:12px;line-height:1.35;margin-bottom:14px;}
  .overlay--title .access-form__row {grid-template-columns:minmax(0,1fr) auto;}
  .overlay--title .controls-copy {display:none;}
}

.hud-chip--berserk {border-color:#ffcf5c;box-shadow:inset 0 0 14px #d77a2033;color:#ffe5a1;}
