:root {
  --screen-x: max(clamp(16px, 2.45vw, 42px), env(safe-area-inset-left));
  --screen-right: max(clamp(16px, 2.45vw, 42px), env(safe-area-inset-right));
  --screen-top: max(clamp(15px, 2.5vh, 30px), env(safe-area-inset-top));
  --screen-bottom: max(clamp(14px, 2.4vh, 28px), env(safe-area-inset-bottom));
  --menu-cream: #ffe5a9;
  --menu-gold: #ffc168;
}

body { display: block; position: relative; height: 100dvh; }
#arena { position: fixed; inset: 0; width: 100%; height: 100%; }
#world { width: 100%; height: 100%; }
body > header, body > footer {
  position: fixed;
  left: var(--screen-x);
  right: var(--screen-right);
  padding: 0;
  min-height: 0;
  border: 0;
  background: none;
  box-shadow: none;
  pointer-events: none;
}
body > header { top: var(--screen-top); align-items: flex-start; z-index: 5; }
body > footer { bottom: var(--screen-bottom); align-items: center; z-index: 4; }
body > header button, body > footer button { pointer-events: auto; }
body > header .brand {
  padding: 2px 0;
  gap: 9px;
  filter: drop-shadow(0 2px 2px #311d24);
}
.brand h1 { font-size: clamp(27px, 2.2vw, 35px); }
.brand p { color: #ffe0b4; letter-spacing: 1.8px; }
.brand-icon { width: 31px; height: 34px; }
.top-actions { margin-left: auto; gap: 8px; }
.top-actions .chrome, .close.chrome {
  height: 37px;
  background: #33292ce8;
  border: 1px solid #bc8969;
  border-bottom: 2px solid #574237;
  border-radius: 4px;
  color: #ffe7c6;
  box-shadow: inset 0 1px #ffffff19, 0 2px 0 #2c2023a8;
}
.top-actions .chrome.square, .close.chrome { width: 39px; }
.top-actions .chrome:hover, .close.chrome:hover { background: #60433b; border-color: #f3b67d; }
#main-menu { display: none; }
body[data-screen='menu'] #main-menu {
  position: fixed;
  inset: 0;
  z-index: 3;
  isolation: isolate;
  display: flex;
  align-items: center;
  pointer-events: none;
}
body[data-screen='menu'] #main-menu::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, #251a26ed 0%, #2e1d28d4 16%, #3b242bc4 26%, #3d252a84 39%, #482d2c29 54%, transparent 70%),
    linear-gradient(0deg, #271b273f 0%, transparent 30%, transparent 85%, #341e261a 100%);
}
body[data-screen='menu'] :is(.brand, #pause, .arena-top, .arena-bottom, .touch-controls, .player-marker, footer) {
  display: none !important;
}
body[data-screen='menu'] header { justify-content: flex-end; }
.menu-content {
  width: min(43vw, 660px);
  margin-left: max(5.8vw, calc(env(safe-area-inset-left) + 22px));
  margin-top: clamp(0px, 1.4vh, 18px);
  color: var(--menu-cream);
}
.menu-kicker {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 clamp(14px, 2.1vh, 26px) 3px;
  color: #ffd89d;
  font: 700 clamp(10px, .74vw, 12px)/1.4 var(--mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  text-shadow: 0 2px #432527;
}
.menu-kicker::before, .menu-kicker::after {
  content: '';
  width: 18px;
  height: 4px;
  background: repeating-linear-gradient(90deg, #f18d58 0 4px, transparent 4px 7px);
  box-shadow: 0 1px 0 #4b2d2b75;
}
.menu-kicker::after { width: 11px; }
h1.menu-title {
  display: block;
  width: max-content;
  max-width: 100%;
  margin: 0 0 0 -1px;
  transform-origin: left center;
  color: var(--menu-cream);
  font: 400 clamp(69px, min(7.8vw, 14vh), 145px)/.71 Jersey, Impact, sans-serif;
  letter-spacing: -.011em;
  text-transform: uppercase;
  text-rendering: optimizeLegibility;
}
.menu-title > span { display: block; width: max-content; white-space: nowrap; }
.menu-title .title-dust {
  margin-bottom: .072em;
  color: #ffedba;
  text-shadow:
    -1px 0 #ffd69b, 1px 1px #dc9c60, 2px 2px #af714b, 3px 3px #975a3d,
    4px 4px #754031, 5px 5px #62342f, 6px 6px #45292b, 7px 7px #332228,
    8px 9px 0 #251b23a8;
}
.menu-title .title-dynamite {
  color: #ff9e51;
  text-shadow:
    -1px 0 #ffc47d, 1px 1px #e97c44, 2px 2px #c76138, 3px 3px #a24a34,
    4px 4px #883b2f, 5px 5px #70342d, 6px 6px #51292a, 7px 7px #372229,
    8px 9px 0 #251b23a8;
}
.menu-intro {
  max-width: min(32ch, 100%);
  margin: clamp(22px, 3.3vh, 38px) 0 0 2px;
  color: #ffe8ce;
  font: 500 clamp(15px, 1.12vw, 19px)/1.52 Inter, Arial, sans-serif;
  text-wrap: pretty;
  text-shadow: 0 1px 3px #46292c;
}
.menu-meta {
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin: clamp(10px, 1.6vh, 17px) 0 0 2px;
  color: #ffcf97;
  font: 700 clamp(10px, .75vw, 12px)/1.32 var(--mono);
  text-transform: uppercase;
  letter-spacing: .095em;
  text-shadow: 0 1px 0 #46302a;
}
.menu-meta > span + span {
  margin-left: 12px;
  border-left: 1px solid #d89a68a6;
  padding-left: 12px;
}
.action-pair {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  gap: clamp(9px, .86vw, 14px);
}
.menu-content .action-pair { margin-top: clamp(20px, 3.55vh, 38px); }
.action-pair :is(.action-primary, .more-games) {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 8px clamp(19px, 1.5vw, 31px) 9px;
  border: 2px solid;
  border-radius: 0;
  background-clip: padding-box;
  font: 400 clamp(24px, 1.69vw, 29px)/.95 Jersey, Impact, sans-serif;
  text-transform: uppercase;
  letter-spacing: .02em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.action-pair .action-primary {
  border-color: #ffe2a3 #eaa757 #ba713e #ffcd83;
  background: #ffbb64;
  color: #35252a;
  box-shadow: inset 0 2px #ffce83, inset 0 -2px #e99d4f, 0 3px #975737, 0 5px #44292b;
}
.action-pair .more-games {
  border-color: #bc8e76 #9a7364 #805e55 #b98b70;
  background: #35292f;
  color: #ffe3b8;
  box-shadow: inset 0 2px #4c3838, inset 0 -2px #302429, 0 3px #62473f, 0 5px #332229;
}
.action-pair .action-primary:hover { background: #ffcc81; color: #2b1d20; }
.action-pair .more-games:hover { background: #4e3838; color: #fff0d2; }
.action-pair :is(.action-primary, .more-games):active { transform: translateY(2px); }
.action-pair svg { width: 16px; height: 16px; flex: none; }
.action-pair a:focus-visible, .menu-help:focus-visible { outline: 2px solid #fff0b6; outline-offset: 5px; }
.menu-help {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 15px 0 0;
  padding: 8px 3px;
  min-height: 34px;
  border: 0;
  background: transparent;
  color: #e8c5ab;
  font: 600 13px/1.2 Inter, Arial, sans-serif;
  text-shadow: 0 1px 2px #35252a;
  pointer-events: auto;
}
.menu-help svg { width: 15px; height: 15px; color: #efba83; }
.menu-help:hover { color: #ffedcf; text-decoration: underline; text-underline-offset: 3px; }

/* Each group has its own footprint so the sand remains visible between controls. */
.arena-top, .arena-bottom { left: var(--screen-x); right: var(--screen-right); }
.arena-top { top: calc(var(--screen-top) + 56px); }
.arena-bottom { bottom: calc(var(--screen-bottom) + 48px); }
.mission h2 { font-size: clamp(30px, 3.1vw, 48px); margin-top: 4px; }
.mission .eyebrow { font-size: 10px; }
.scoreboard, .loadout { padding-top: 8px; padding-bottom: 8px; }
.stat-block { padding: 0 clamp(10px, 1vw, 17px); gap: 8px; }
.stat-block strong, .hostiles strong { font-size: 25px; }
.stat-block img { width: 20px; height: 21px; }
.load-stat { min-width: 58px; padding: 0 clamp(10px, .93vw, 16px); }
.load-stat:first-child { min-width: 89px; }
.value, .hearts { height: 21px; }
.hostiles { padding: 8px 13px; }
.panel { background: #2c2228e6; }
footer .controls, footer #help, footer .touch-hint {
  background: #2d2429d9;
  border: 1px solid #a77d627d;
  border-radius: 3px;
  color: #eddbc6;
  box-shadow: 0 2px 0 #38252a77;
}
footer .controls { gap: clamp(13px, 1.5vw, 24px); padding: 6px 11px; }
footer .control { gap: 7px; font-size: 12px; color: #f4dfc6; }
footer .control-title { color: #dfbaa0; }
footer kbd { height: 20px; line-height: 17px; min-width: 19px; padding: 0 6px; font-size: 10px; border-width: 1px 1px 2px; }
footer #help { padding: 8px 10px; font-size: 12px; }
footer .touch-hint { padding: 8px 10px; }
#dialog { width: min(458px, 100%); max-height: calc(100dvh - 28px); }
#dialog .action-pair { justify-content: center; margin-top: 20px; }
#dialog .action-pair :is(.more-games, .action-primary) { min-height: 43px; font-size: 22px; padding: 7px 15px; }
.dialog-utility {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding-top: 15px;
}
.dialog-utility button {
  padding: 6px 2px;
  border: 0;
  background: none;
  color: #e1b78f;
  box-shadow: none;
  font: 600 13px/1.25 Inter, sans-serif;
}
.dialog-utility button:hover { color: #fff0ce; text-decoration: underline; text-underline-offset: 3px; }
@media (pointer: coarse), (max-width: 600px) {
  .arena-bottom { bottom: calc(var(--screen-bottom) + 89px); }
  .touch-controls { bottom: var(--screen-bottom); left: var(--screen-x); right: var(--screen-right); }
  body > footer { bottom: auto; top: var(--screen-top); left: 50%; right: auto; transform: translateX(-50%); }
  footer .touch-hint, footer .controls { display: none; }
  footer #help { width: 34px; height: 33px; justify-content: center; padding: 0; font-size: 0; gap: 0; }
  .touch-controls button { min-height: 36px; }
  .dpad { grid-template-rows: repeat(2, 36px); }
}
@media (max-width: 760px) {
  .top-actions { gap: 6px; }
  .arena-top { top: calc(var(--screen-top) + 48px); }
  .scoreboard, .loadout, .hostiles { padding-top: 6px; padding-bottom: 6px; }
  .brand h1 { font-size: 27px; }
  .brand-icon { width: 27px; height: 30px; }
  .brand p { font-size: 8px; }
  .menu-content { width: 49vw; margin-left: max(4.5vw, env(safe-area-inset-left)); }
  .action-pair :is(.action-primary, .more-games) { padding-inline: 13px; }
}
@media (max-aspect-ratio: 26/25) {
  body[data-screen='menu'] #main-menu { justify-content: center; align-items: flex-end; }
  body[data-screen='menu'] #main-menu::before {
    background: linear-gradient(0deg, #291d28 0%, #31212beb 17%, #39242ce8 31%, #41282bc4 42%, #41292d5c 51%, transparent 65%);
  }
  .menu-content {
    width: min(91vw, 490px);
    text-align: center;
    margin: 0 0 max(clamp(17px, 4vh, 52px), env(safe-area-inset-bottom));
  }
  .menu-kicker { justify-content: center; margin: 0 0 12px; font-size: 10px; }
  h1.menu-title { margin: 0 auto; transform-origin: center; font-size: clamp(64px, min(17vw, 12vh), 99px); }
  .menu-title > span { margin-inline: auto; }
  .menu-intro { max-width: 34ch; margin: clamp(16px, 2.7vh, 24px) auto 0; font-size: 14px; line-height: 1.42; }
  .menu-meta { margin: 9px auto 0; font-size: 10px; }
  .menu-content .action-pair { margin-top: clamp(17px, 2.4vh, 24px); justify-content: center; }
  .action-pair :is(.action-primary, .more-games) { min-height: 46px; padding-inline: 18px; font-size: 24px; }
  .menu-help { margin: 9px auto 0; min-height: 33px; }
}
@media (max-width: 490px) {
  :root { --screen-x: max(12px, env(safe-area-inset-left)); --screen-right: max(12px, env(safe-area-inset-right)); }
  .top-actions .chrome { height: 33px; }
  .top-actions .chrome.square { width: 33px; }
  .top-actions #pause { width: 33px; padding: 0; }
  .top-actions #pause span { display:none; }
  .brand h1 { font-size: 25px; }
  .brand p { letter-spacing: 1px; }
  .stat-block { padding: 0 8px; }
  .stat-block strong, .hostiles strong { font-size: 21px; }
  .arena-bottom .load-stat { min-width: 42px; padding: 0 7px; }
  .arena-bottom .load-stat:first-child { min-width: 69px; }
  .hostiles { gap: 5px; padding-inline: 8px; }
  .mission h2 { font-size: 31px; }
  .mission .eyebrow { font-size: 9px; }
  .value span { font-size: 22px; }
  .value img { width: 19px; height: 21px; }
  .value, .hearts { height: 19px; }
  .hearts img { width: 16px; height: 16px; }
}
@media (max-height: 570px) and (min-aspect-ratio: 1/1) {
  :root { --screen-top: max(9px, env(safe-area-inset-top)); --screen-bottom: max(10px, env(safe-area-inset-bottom)); }
  .menu-content { margin-top: 0; }
  .menu-kicker { margin-bottom: 8px; font-size: 9px; }
  h1.menu-title { font-size: clamp(47px, min(7.4vw, 14.5vh), 82px); }
  .menu-intro { margin-top: 16px; font-size: 13px; line-height: 1.32; }
  .menu-meta { font-size: 9px; margin-top: 7px; }
  .menu-content .action-pair { margin-top: 16px; }
  .action-pair :is(.action-primary, .more-games) { min-height: 39px; padding: 6px 12px; font-size: 21px; }
  .menu-help { min-height: 28px; margin-top: 7px; padding: 4px; font-size: 12px; }
  .brand-icon { width: 24px; height: 26px; }
  .brand h1 { font-size: 23px; }
  .brand p { display:none; }
  .top-actions .chrome { height: 30px; }
  .top-actions .chrome.square { width: 32px; }
  .arena-top { top: calc(var(--screen-top) + 38px); }
  .arena-bottom { bottom: calc(var(--screen-bottom) + 35px); }
  .mission h2 { font-size: 27px; }
  .mission .eyebrow, .panel small { font-size: 9px; }
  .stat-block strong, .hostiles strong { font-size: 21px; }
  .loadout, .scoreboard, .hostiles { padding-block: 4px; }
  footer .controls { padding: 3px 7px; gap: 13px; }
  footer #help { padding-block: 5px; }
  #dialog { max-height: calc(100dvh - 16px); padding: 12px 22px 16px; }
  .dialog-img { width: 29px; height: 32px; margin-bottom: 4px; }
  #dialog h2 { font-size: 35px; margin-block: 3px 7px; }
  #dialog .action-pair { margin-top: 11px; }
  .dialog-utility { padding-top: 8px; }
}
@media (max-height: 570px) and (pointer: coarse) {
  .arena-bottom { bottom: calc(var(--screen-bottom) + 68px); }
  .touch-controls .dpad { grid-template-rows: repeat(2, 29px); grid-template-columns: repeat(3, 32px); }
  .touch-controls button { min-height: 29px; }
}
@media (max-height: 690px) and (max-aspect-ratio: 26/25) {
  .menu-content { margin-bottom: max(11px, env(safe-area-inset-bottom)); }
  h1.menu-title { font-size: clamp(52px, min(15vw, 10vh), 68px); }
  .menu-kicker { margin-bottom: 8px; }
  .menu-intro { margin-top: 14px; }
  .menu-meta { margin-top: 7px; }
  .menu-content .action-pair { margin-top: 13px; }
  .menu-help { margin-top: 6px; }
}

.menu-links { display: flex; align-items: center; gap: 18px; }
@media (max-aspect-ratio: 26/25) {
  .menu-links { justify-content: center; }
  .menu-links .menu-help { margin-inline: 0; }
}
#fullscreen-note {
  position: fixed; top: calc(var(--screen-top) + 43px); right: var(--screen-right); z-index: 6;
  padding: 9px 12px; border: 1px solid #a57d64; border-radius: 3px;
  background: #30252c; color: #ffe4c5; font: 500 13px/1.4 Inter, sans-serif;
}

#pickup-notice {
  position: absolute;
  left: 0;
  bottom: calc(100% + 7px);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 4px 10px 4px 6px;
  border: 1px solid #d69a61;
  border-left: 3px solid #ffbf68;
  background: #35262cef;
  color: #ffdfaa;
  box-shadow: 2px 2px #482d2b99;
  font: 400 19px/1.1 Jersey, Impact, sans-serif;
  letter-spacing: .02em;
  pointer-events: none;
}
#pickup-icon { width: 22px; height: 22px; flex: none; object-fit: contain; }
.loadout .value img { object-fit: contain; width: 22px; height: 22px; }
@media (max-width: 440px) {
  .arena-bottom { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
  .arena-bottom .loadout { display: grid; grid-template-columns: 1.25fr repeat(3, minmax(0, 1fr)); }
  .arena-bottom .load-stat, .arena-bottom .load-stat:first-child { min-width: 0; padding-inline: 5px; }
  .arena-bottom .load-stat .value { gap: 3px; }
  .arena-bottom .load-stat .value img { width: 16px; height: 16px; }
  .arena-bottom .load-stat .value span { font-size: 19px; }
  .arena-bottom .load-stat .hearts { gap: 0; }
  .arena-bottom .load-stat .hearts img { width: min(3.95vw, 16px); height: auto; }
  .arena-bottom .hostiles { padding-inline: 7px; gap: 4px; }
}
@media (max-width: 355px) {
  .arena-bottom .hostiles > img { display: none; }
  .arena-bottom small { letter-spacing: .8px; }
}
@media (max-height: 570px) and (min-aspect-ratio: 1/1) {
  #pickup-notice { bottom: calc(100% + 4px); gap: 5px; padding-block: 2px; font-size: 17px; }
  #pickup-icon, .loadout .value img { width: 17px; height: 17px; }
}
