#hud {
  /* PlayerUI uses a 1920-wide reference canvas and Match Width. */
  --hu: calc(100vw / 1920);
  --compass-turn: 1500;
  --left: env(safe-area-inset-left, 0px);
  --right: env(safe-area-inset-right, 0px);
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  padding: 0;
  color: white;
  font-family: ClassicMaru, "Kosugi Maru", "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  text-shadow: 0 1px 2px #111;
  user-select: none;
  -webkit-user-select: none;
}
#hud [hidden] { display: none !important; }
#hud .round-control, #hud .hud-stick, #hud #belt button {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: white;
  background: transparent url("/ui/round.png") center / 100% 100% no-repeat;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
#hud .round-control { width: calc(160 * var(--hu)); aspect-ratio: 1; z-index: 2; }
#hud .round-control img { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: block; width: 72.5%; height: 72.5%; object-fit: contain; pointer-events: none; }
#hud .round-control:active, #hud #belt button:active { filter: brightness(1.4); }
#hud .hud-tools {
  position: absolute; top: max(var(--top), calc(20 * var(--hu))); right: max(var(--right), calc(20 * var(--hu)));
  display: flex; gap: calc(20 * var(--hu)); z-index: 4;
}
#hud .hud-tools .round-control, #hud #pause { position: relative; width: calc(80 * var(--hu)); }
#hud .hud-tools img, #hud #pause img { width: 62.5%; height: 62.5%; }
#hud #pause { position: absolute; top: max(var(--top), calc(20 * var(--hu))); left: max(var(--left), calc(20 * var(--hu))); }
#hud .hud-tools button::after, #hud #pause::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; }
#hud .round-compass { position: absolute; top: var(--top); left: 50%; transform: translateX(-50%); width: calc(480 * var(--hu)); height: calc(151.4 * var(--hu)); text-align: center; }
#hud #azimuth { position: absolute; left: 0; top: calc(13 * var(--hu)); width: 100%; font-size: calc(32 * var(--hu)); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
#hud .round-compass::after { content: ""; position: absolute; left: 50%; top: calc(50 * var(--hu)); transform: translateX(-50%); width: calc(4 * var(--hu)); height: calc(12 * var(--hu)); background: white; }
#hud #bearingScale { position: absolute; left: 0; right: 0; top: calc(70.762 * var(--hu)); height: calc(80.566 * var(--hu)); background: url("/classic/hud/compass.png") repeat-x; background-size: calc(var(--compass-turn) * var(--hu)) 100%; background-position-x: calc(50% + var(--compass-offset, .5) * var(--compass-turn) * var(--hu)); }
#hud #roundGoal { position: absolute; left: 50%; top: max(var(--top), calc(161.4 * var(--hu))); transform: translateX(-50%); white-space: nowrap; font-size: calc(42 * var(--hu)); font-weight: 400; line-height: 1.08; }
#hud #clock:not(:empty)::before { content: " ("; }
#hud #clock:not(:empty)::after { content: ")"; }
#hud #hudRoster { position: absolute; left: max(var(--left), calc(80 * var(--hu))); top: max(var(--top), calc(20 * var(--hu))); z-index: 4; }
#hud .hud-look { position: absolute; inset: 0; display: none; touch-action: none; }
@media (pointer:coarse) { #hud .hud-look { display: block; pointer-events: auto; } }
#hud .hud-stick { z-index: 2; width: calc(300 * var(--hu)); aspect-ratio: 1; left: max(var(--left), calc(120 * var(--hu))); bottom: max(var(--bottom), calc(100 * var(--hu))); }
#hud #moveKnob { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 50%; height: 50%; background: transparent url("/ui/joystick.png") center / contain no-repeat; border: none; box-shadow: none; pointer-events: none; }
#hud #fireLeft { left: max(var(--left), calc(114.5 * var(--hu))); bottom: max(var(--bottom), calc(430 * var(--hu))); }
#hud #fire, #hud #act { right: max(var(--right), calc(300 * var(--hu))); }
#hud #fire { bottom: max(var(--bottom), calc(120 * var(--hu))); }
#hud #act { bottom: max(var(--bottom), calc(320 * var(--hu))); }
#hud #act b { position: absolute; bottom: 92%; font: 900 calc(36 * var(--hu))/1 system-ui; text-shadow: 1px 1px 1px black, -1px -1px 1px black; }
#hud #jump { right: max(var(--right), calc(60 * var(--hu))); bottom: max(var(--bottom), calc(160 * var(--hu))); width: calc(200 * var(--hu)); }
#hud #jump img { width: 100%; height: 100%; }
#hud #hudEmote { width: calc(120 * var(--hu)); bottom: max(var(--bottom), calc(90 * var(--hu))); right: max(var(--right), calc(510 * var(--hu))); }
#hud #hudEmote img { width: 63.333%; height: 63.333%; }
#hud #belt {
  display: grid; grid-auto-columns: calc(100 * var(--hu)); grid-template-rows: repeat(3, calc(100 * var(--hu)));
  direction: rtl; row-gap: calc(20 * var(--hu)); column-gap: calc(10 * var(--hu)); position: absolute; bottom: max(var(--bottom),calc(390 * var(--hu)));
  right: max(var(--right), calc(60 * var(--hu))); z-index: 2;
}
#hud #belt button { position: relative; direction: ltr; width: 100%; height: 100%; text-shadow: inherit; }
/* Extend each touch target halfway into the space between adjacent rings. */
#hud #belt button::after { content:""; position:absolute; inset:calc(-10 * var(--hu)) calc(-5 * var(--hu)); }
#hud #belt button[aria-pressed=true] { background-color: #35bada65; }
#hud #belt button[aria-pressed=true] img { filter: brightness(0) saturate(100%) invert(71%) sepia(85%) saturate(579%) hue-rotate(146deg); }
#hud #belt button:has(.weapon-helper) { z-index: 1; }
#hud #belt[data-pig] button:disabled { opacity:1; }
#hud #belt .weapon-helper {
  position:absolute; top:50%; right:calc(100% + 20 * var(--hu)); transform:translateY(-50%);
  box-sizing:border-box; width:calc(460 * var(--hu)); height:calc(100 * var(--hu)); padding:calc(8 * var(--hu)) calc(20 * var(--hu));
  display:grid; align-content:center; border-radius:calc(27 * var(--hu));
  background:rgb(0 0 0/.65); color:white; white-space:pre; text-align:left;
  font:400 calc(28 * var(--hu))/1.28 ClassicMaru,sans-serif; text-shadow:none; pointer-events:none;
}
#hud #belt .weapon-helper::after {
  content:''; position:absolute; left:100%; top:50%; transform:translateY(-50%);
  border-top:calc(16 * var(--hu)) solid transparent; border-bottom:calc(16 * var(--hu)) solid transparent;
  border-left:calc(42 * var(--hu)) solid rgb(0 0 0/.65);
}
#hud #belt img { display: block; width: 76%; height: 76%; object-fit: contain; }
@property --belt-fill { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes belt-refill { from { --belt-fill: 0deg; } to { --belt-fill: 360deg; } }
#hud #belt button.reloading { background: transparent; }
#hud #belt button.reloading::before { content: ''; position: absolute; inset: 0; border-radius: 50%; background: url('/ui/round.png') center / 100% 100% no-repeat; mask-image: conic-gradient(from 180deg,#000 var(--belt-fill),transparent 0); animation: belt-refill var(--belt-reload-time) linear var(--belt-reload-offset) both; pointer-events: none; }
#hud #belt button.reloading img { position: relative; opacity: .38; }
#hud #belt small { position: absolute; bottom: 0; inset-inline: 0; text-align: center; font: 400 calc(42 * var(--hu))/1 ClassicMaru,sans-serif; color: #c7504f; text-shadow: 0 0 1px white, 0 0 2px white; pointer-events: none; }
#hud #health { position: absolute; bottom: max(var(--bottom), calc(80 * var(--hu))); left: 50%; transform: translateX(-50%); width: calc(554 * var(--hu)); height: calc(44 * var(--hu)); display: flex; align-items: center; border-radius: calc(10 * var(--hu)); background: #64665f99; overflow: hidden; }
#hud #health img { width: calc(38 * var(--hu)); height: calc(38 * var(--hu)); margin-left: calc(8 * var(--hu)); }
#hud #health span { position: absolute; left: calc(51 * var(--hu)); right: calc(3 * var(--hu)); height: calc(40 * var(--hu)); background: #bf1715; border-radius: calc(7 * var(--hu)); overflow: hidden; }
#hud #health i { display: block; background: #75fb4e; height: 100%; transition: width .13s linear; }
#hud .hud-cross { position: absolute; left: 50%; top: 50%; width: calc(22 * var(--hu)); height: calc(22 * var(--hu)); transform: translate(-50%, -50%); border: 1px solid #fff; border-radius: 50%; }
#hud #gameMessage, #hud #rescueProgress { position: absolute; left: 50%; top: 29%; max-width: 67%; transform: translateX(-50%); padding: calc(10 * var(--hu)) calc(27 * var(--hu)); border-radius: calc(8 * var(--hu)); background: #15151688; text-align: center; font-size: calc(42 * var(--hu)); font-weight: 650; }
#hud #gameMessage:empty { display: none; }
#hud #rescueProgress { top: 63%; width: calc(350 * var(--hu)); font-size: calc(35 * var(--hu)); }
#hud #rescueProgress i { display: block; margin-top: 3px; height: calc(12 * var(--hu)); background: linear-gradient(to right, #89f859 var(--recovered), #596457 var(--recovered)); }
#pauseDialog .practice-open { align-self:center; margin: .6em 0; padding:.35em 1em; border:1px solid #aaa; border-radius:.45em; color:#333; background:white; font:inherit; touch-action:manipulation; }
#hud .minimap-toggle { left: max(var(--left), calc(120 * var(--hu))); top: max(var(--top), calc(20 * var(--hu))); right: auto; width: calc(240 * var(--hu)); background: transparent; box-shadow: none; border: 0; border-radius: 50%; }
#hud .minimap-toggle canvas { position: static; display: block; width: 100%; height: 100%; }
#hud #restoreHud { position: absolute; inset: 0; z-index: 5; pointer-events: auto; width: 100%; height: 100%; background: transparent; color: white; border: none; padding-top: 25svh; text-shadow: inherit; font-size: calc(42 * var(--hu)); }
#hud[data-camera=hidden] > :not(#restoreHud) { visibility: hidden; }
#switchChoice {
  --dialog-unit: calc(100vw / 1920);
  position: fixed; inset: max(env(safe-area-inset-top, 0px), calc(80 * var(--dialog-unit))) 0 auto;
  margin: 0 auto; width: calc(1080 * var(--dialog-unit)); height: calc(340 * var(--dialog-unit));
  max-width: none; padding: 0; overflow: hidden; background: white; border: 0;
  border-radius: calc(32 * var(--dialog-unit)); box-shadow: 0 2px 6px #0007; color: white;
  font-family: ClassicMaru, sans-serif;
}
#switchChoice::backdrop { background: transparent; backdrop-filter: none; }
#switchChoice h2 { display: grid; place-items: center; height: calc(120 * var(--dialog-unit)); margin: 0; color: white; background: #4faec7; font-size: calc(60 * var(--dialog-unit)); font-weight: 700; text-align: center; }
#switchChoice > div { position: absolute; inset: auto 0 calc(45 * var(--dialog-unit)); display: flex; justify-content: center; gap: calc(60 * var(--dialog-unit)); }
#switchChoice button { position: relative; width: calc(420 * var(--dialog-unit)); height: calc(120 * var(--dialog-unit)); border: 0; border-radius: calc(32 * var(--dialog-unit)); padding: 0 calc(100 * var(--dialog-unit)) 0 0; color: white; background: #c83237; font: inherit; font-size: calc(48 * var(--dialog-unit)); }
#switchChoice #switchYes { background: #4faec7; }
#switchChoice button b { position: absolute; right: calc(20 * var(--dialog-unit)); top: 50%; transform: translateY(-50%); width: calc(80 * var(--dialog-unit)); height: calc(80 * var(--dialog-unit)); font-size: 0; background: url("/classic/hud/emote-close.png") center/contain no-repeat; }
#switchChoice #switchYes b { background-image: url("/classic/hud/switch-circle.png"); }
@media (orientation:portrait) {
  #switchChoice { --dialog-unit: .085vw; }
  #hud #hudRoster { left: calc(var(--left) + 12 * var(--hu)); }
  #hud .round-compass { width: calc(270 * var(--hu)); }
  #hud #roundGoal { top: calc(var(--top) + 222 * var(--hu)); font-size: calc(32 * var(--hu)); max-width: 92%; white-space: normal; text-align: center; }
  #hud #health { bottom: calc(var(--bottom) + 34 * var(--hu)); width: calc(355 * var(--hu)); }
  #hud #fireLeft { left: 6%; bottom: 32%; }
  #hud .hud-stick { width: 25vw; left: 4%; bottom: 13%; }
  #hud #fire, #hud #act { right: 24%; }
  #hud #fire { bottom: 12%; }
  #hud #act { bottom: 24%; }
  #hud #jump { right: 3%; bottom: 16%; }
  #hud #hudEmote { right: 5%; bottom: 5%; }
  #hud #belt { right: calc(var(--right) + 15 * var(--hu)); bottom:calc(50% - 50 * var(--hu)); }
  #hud #belt .weapon-helper { width:max-content; max-width:38vw; height:auto; min-height:30px; white-space:pre-line; font-size:11px; }
  #hud #gameMessage { max-width: 90%; }
}

.practice-pick .practice-slots { flex-wrap: wrap; }

#hud #hudRoster .cs-player { pointer-events: auto; }
#hud #shoulder { width: calc(80 * var(--hu)); left: 50%; transform: translateX(-50%); bottom: calc(var(--bottom) + 150 * var(--hu)); }
#hud #shoulder img { width: 90%; height: 90%; }

/* Practice uses the same rounded cyan header and action buttons as the game pop-ups. */
.practice-pick {
  width: min(92vw, 138svh, 720px); max-height: 91svh; padding: 0 0 .65em;
  overflow: auto; overscroll-behavior: contain; color: #272727; border: 2px solid #dadada;
  border-radius: clamp(8px,1.8svh,16px); background: #fcfcfc; font-family: ClassicMaru, sans-serif;
  font-size: clamp(12px,3.2svh,19px); box-shadow: 0 3px 8px #0006;
}
.practice-pick::backdrop { backdrop-filter: none; background: #0005; }
.practice-pick .section-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: center; margin: 0; min-height: 2.25em; background: #4faec7; color: white; }
.practice-pick .section-head h2 { font: inherit; font-size: 1.25em; }
.practice-pick .section-head .x { position: absolute; right: .55em; top: 50%; transform: translateY(-50%); padding: 0; border: 1px solid white; border-radius: 50%; width: 1.45em; height: 1.45em; display: grid; place-items: center; color: white; background: #0002; font: 400 1.15em/1 system-ui; }
.practice-pick .practice-slots { display: flex; flex-wrap: wrap; justify-content: center; gap: .4em; margin: .65em 4%; }
.practice-slots button { min-width: 2.05em; height: 1.85em; padding: 0 .25em; border: 1px solid #ababab; border-radius: .35em; background: #ececec; color: #5b5b5b; }
.practice-slots button[aria-pressed=true] { background: #50adc3; color: white; border-color: #3c9bb2; }
.practice-pick h3 { margin: .3em 4%; text-align: center; color: #397c8c; font: inherit; }
.practice-pick .practice-items { display: grid; grid-template-columns: repeat(3,1fr); gap: .35em; margin: 0 4%; }
.practice-items button { display: flex; align-items: center; gap: .35em; min-height: 2.55em; padding: .2em .45em; color: #fff; border: 2px solid #fff; border-radius: .55em; background: #7298a2; font: inherit; font-size: .90em; box-shadow: 0 0 0 1px #b7c6c8; }
.practice-items button[aria-pressed=true] { background: #45aabe; box-shadow: 0 0 0 2px #3b889a; }
.practice-items img { width: 1.75em; height: 1.75em; object-fit: contain; flex: none; }
.practice-pick .practice-status { min-height: 1.1em; margin: .2em 4%; font-size: .8em; text-align: center; }
.practice-pick .practice-reset { display: block; margin: 0 auto; padding: .38em 1.2em; color: white; background: #56adbe; border-radius: .5em; font: inherit; }

#hud .base-withdraw { width: calc(120 * var(--hu)); bottom: calc(var(--bottom) + 90 * var(--hu)); left: calc(var(--left) + 510 * var(--hu)); }
#hud .base-withdraw:disabled { opacity: .6; }
#hud .base-status { position: absolute; top: calc(var(--top) + 30 * var(--hu)); left: calc(var(--left) + 380 * var(--hu)); width: calc(268 * var(--hu)); padding: calc(10 * var(--hu)) calc(8 * var(--hu)); border-radius: calc(9 * var(--hu)); background: #0007; text-align: center; font-size: calc(22 * var(--hu)); }
#hud .base-marks { display: flex; align-items: center; justify-content: space-between; margin-bottom: calc(5 * var(--hu)); }
#hud .base-marks i { display: block; mask: var(--mark) center/contain no-repeat; background: var(--base-color); }
#hud .base-heart { --mark: url('/ui/heart.png'); width: calc(35 * var(--hu)); height: calc(35 * var(--hu)); }
#hud .base-marks .base-star { display: grid; place-items: center; padding-top: calc(3 * var(--hu)); box-sizing: border-box; color: #333; text-shadow: none; font-style: normal; font-size: calc(15 * var(--hu)); line-height: 1; --mark: url('/classic/hud/star.png'); width: calc(25 * var(--hu)); height: calc(25 * var(--hu)); }
.conquer-map { max-height: 92svh; padding: 0 2% .55em; color: #242424; background: white; border: 2px solid #ddd; border-radius: 10px; font: clamp(12px,2.8svh,16px) ClassicMaru,sans-serif; }
.conquer-map::backdrop { backdrop-filter: none; background: #0005; }
.conquer-map .section-head { position: relative; justify-content: center; margin: 0 -7% .4em; padding: .38em 1em; background: #4faec7; color: white; }
.conquer-map .section-head h2 { font-size: 1.25em; }
.conquer-map .section-head .x { position: absolute; right: 6%; top: 50%; transform: translateY(-50%); width: 1.5em; height: 1.5em; padding: 0; border: 1px solid white; border-radius: 50%; color: white; background: transparent; font: inherit; }
.conquer-map .retreat-targets button { padding: .35em .8em; color: white; background: #51afc1; border: 0; }
@media (orientation:portrait) {
  #hud .minimap-toggle { left: calc(var(--left) + 18 * var(--hu)); top: calc(var(--top) + 10 * var(--hu)); width: calc(150 * var(--hu)); }
  #hud .base-status { left: calc(var(--left) + 18 * var(--hu)); top: calc(var(--top) + 162 * var(--hu)); width: calc(160 * var(--hu)); font-size: calc(17 * var(--hu)); }
  #hud .base-withdraw { left: 5%; bottom: 5%; }
}
@media (orientation:portrait) {
  #hud { --hu: min(.14vw, .078svh); }
  #hud #hudRoster { --hu: .094vw; }
  #hud .round-compass { top: calc(var(--top) + 175 * var(--hu)); width: calc(425 * var(--hu)); }
  #hud #roundGoal { top: calc(var(--top) + 340 * var(--hu)); width: max-content; }
  #hud #fire, #hud #act { right: 30%; }
  #hud #jump { bottom: 18%; }
  #hud #shoulder { bottom: 5%; }
}

#hud #roundCountdown {
  position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);
  min-width:52%; max-width:85%; padding:.48em .5em; box-sizing:border-box;
  border-radius:.25em; background:rgba(225,219,213,.34);
  text-align:center; white-space:nowrap; color:#292520;
  font:400 clamp(17px,6.5svh,42px)/1.2 ClassicMaru,sans-serif;
  -webkit-text-stroke:.07em rgba(255,255,255,.83); paint-order:stroke fill;
  text-shadow:none; pointer-events:none;
}
#hud #roundCountdown:empty, #hud[data-preparing] :is(#roundGoal,#fire,#fireLeft) { display:none; }

#hud[data-spinning] :is(#belt,#fire,#fireLeft,#jump,#shoulder,#act) { visibility:hidden; }
