:root {
  color-scheme: dark;
  --viewport-unit: 1vh;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  --ivory: #f5efd9;
  --gold: #e4c68c;
  --muted: #c2c7b7;
  --edge: #d4d5a637;
  --spell: #86e7cb;
  --safe-top: max(24px, env(safe-area-inset-top));
  --safe-right: max(27px, env(safe-area-inset-right));
  --safe-bottom: max(25px, env(safe-area-inset-bottom));
  --safe-left: max(27px, env(safe-area-inset-left));
}
@supports (height: 1dvh) { :root { --viewport-unit: 1dvh; } }
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body[data-screen="playing"], body[data-screen="playing"] button { touch-action: none; }
body {
  background: #172723;
  color: var(--ivory);
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 2px solid #f8dc9d; outline-offset: 4px; }
button:disabled { opacity: .38; cursor: default; }
#scene, .view-shade, .menu-shade { position: absolute; inset: 0; width: 100%; height: 100%; }
#scene { display: block; touch-action: none; }
.view-shade, .menu-shade { pointer-events: none; }
.view-shade {
  background: linear-gradient(0deg, #0f1914ad, transparent 24%), linear-gradient(#101b1952, transparent 20%),
    radial-gradient(ellipse at 52% 45%, transparent 45%, #121d1a2c 100%);
}
.menu-shade {
  background: linear-gradient(90deg, #101d17f0 0%, #13221bdb 16%, #11221aa3 31%, #15211a33 54%, transparent 74%);
  transition: opacity .22s ease;
}
body[data-mode="playing"] .menu-shade { opacity: 0; }
body[data-mode="paused"] .menu-shade { background: #101a17b9; }
.hud-header {
  position: absolute;
  inset: var(--safe-top) var(--safe-right) auto var(--safe-left);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}
.world-label {
  display: flex;
  align-items: center;
  gap: 12px;
  text-shadow: 0 2px 5px #09100be8;
}
.world-label strong { display: block; font-size: .92rem; font-weight: 650; letter-spacing: .03em; }
.world-label small { display: block; margin-top: 2px; color: #d4d5bd; font-size: .79rem; font-variant-numeric: tabular-nums; }
.world-mark {
  position: relative;
  display: block;
  width: 35px;
  height: 35px;
  border: 1px solid #e7ce9480;
  border-radius: 7px;
  background: #15261e99;
  box-shadow: inset 0 0 11px #debc6718;
}
.world-mark i {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #dfc187;
  transform: rotate(45deg);
}
.world-mark i:first-child { left: 13px; top: 7px; }
.world-mark i:nth-child(2) { left: 8px; top: 15px; opacity: .6; }
.world-mark i:last-child { left: 18px; top: 15px; opacity: .83; }
.actions { display: flex; gap: 7px; pointer-events: auto; }
.locale-switch {
  display: flex;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--edge);
  border-radius: 7px;
  background: #1d221fd9;
}
.locale-switch button {
  min-width: 35px;
  padding: 0 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
}
.locale-switch button:hover { color: var(--ivory); }
.locale-switch button[aria-pressed="true"] { background: var(--gold); color: #212118; }
body[data-screen="playing"] .locale-switch { display: none; }
.glass, .icon-button {
  border: 1px solid var(--edge);
  border-radius: 9px;
  background: linear-gradient(127deg, #202e26ea, #162019eb);
  box-shadow: 0 5px 23px #10192333, inset 0 1px #e4e6c20a;
}
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; }
.icon-button:hover:enabled, .secondary-button:hover { background: #364235; border-color: #ead0967c; }
.pause-icon { width: 11px; height: 13px; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }
.speaker { position: relative; width: 18px; height: 17px; display: block; }
.speaker::before {
  content: ""; position: absolute; width: 10px; height: 13px; left: 0; top: 2px;
  background: currentColor; clip-path: polygon(0 31%, 38% 31%, 100% 0, 100% 100%, 38% 69%, 0 69%);
}
.speaker i { position: absolute; left: 7px; top: 3px; width: 8px; height: 11px; border-right: 1.5px solid; border-radius: 50%; }
.speaker i + i { left: 8px; top: 0; width: 10px; height: 17px; opacity: .7; }
#audio[aria-pressed="false"] .speaker i { visibility: hidden; }
#audio[aria-pressed="false"] .speaker::after {
  content: ""; position: absolute; left: 12px; top: 5px; width: 1.5px; height: 10px;
  background: currentColor; transform: rotate(42deg);
}
.map {
  position: absolute;
  right: var(--safe-right);
  top: calc(var(--safe-top) + 50px);
  width: 142px;
  padding: 8px;
  pointer-events: none;
}
.map-heading, .coordinates {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #d0d0b8;
  font-size: .72rem;
  letter-spacing: .09em;
  font-weight: 650;
}
.map-heading { padding: 0 2px 6px; }
.map-heading b { color: var(--gold); font-size: .76rem; }
#minimap { display: block; width: 100%; height: auto; border: 1px solid #c8c79d37; border-radius: 4px; }
.coordinates { padding: 6px 1px 0; justify-content: center; font-variant-numeric: tabular-nums; letter-spacing: .055em; }

.menu {
  position: absolute;
  top: 47%;
  left: max(6%, var(--safe-left));
  transform: translateY(-50%);
  max-width: min(88vw, 415px);
}
.genre { display: flex; align-items: center; gap: 10px; color: #ebcd93; font-size: .78rem; text-transform: uppercase; font-weight: 650; letter-spacing: .155em; }
.genre span { display: block; width: 23px; height: 1px; background: #e7c3809e; }
h1, h2 {
  margin: 14px 0 16px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  text-shadow: 0 3px 20px #0e1b1499;
}
h1 { font-size: clamp(4.6rem, 7.6vw, 8rem); line-height: .83; letter-spacing: -.062em; }
h2 { font-size: clamp(2.7rem, 5.7vw, 5.2rem); line-height: 1; letter-spacing: -.045em; }
.intro {
  max-width: 305px;
  margin: 24px 0;
  color: #e0e2cc;
  font-size: 1.02rem;
  line-height: 1.57;
  text-wrap: pretty;
}
.primary-button, .secondary-button {
  min-height: 51px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 25px;
  border-radius: 6px;
  letter-spacing: .012em;
  font-weight: 700;
  font-size: .99rem;
}
.primary-button {
  min-width: 163px;
  border: 1px solid #fcdeb0;
  background: linear-gradient(160deg, #f3dba4, #d8ae6d);
  color: #251e12;
  box-shadow: 0 4px 26px #ebba512b, inset 0 1px 0 #fff0c580;
}
.primary-button:hover { background: #ffe1a5; box-shadow: 0 4px 24px #ebba515c; }
.play-icon { width: 10px; height: 12px; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.secondary-button { background: #1c2b27; border: 1px solid #d9c4a063; }
.control-guide { display: flex; flex-wrap: wrap; gap: 13px 16px; margin-top: 23px; }
.control-guide > div { display: grid; gap: 6px; justify-items: start; align-items: center; font-size: .75rem; color: #c4cbb9; }
kbd {
  font: inherit;
  display: inline-block;
  min-width: 29px;
  padding: 2px 6px 3px;
  border: 1px solid #ebe4c549;
  border-radius: 4px;
  background: #15241bcc;
  color: #f4efd6;
  font-size: .73rem;
}
.touch-guide, .touch-controls { display: none; }
.guide-stick, .guide-drag {
  width: 19px; height: 19px; border: 1px solid #e0e1bf88; border-radius: 50%; position: relative;
}
.guide-stick::after, .guide-drag::after {
  content: ""; width: 6px; height: 6px; position: absolute; top: 6px; left: 6px; border-radius: 50%; background: #ead7a4;
}
.guide-drag { border-radius: 4px; }
.guide-drag::after { height: 2px; width: 11px; top: 8px; left: 3px; border-radius: 1px; transform: rotate(-30deg); }
body[data-mode="paused"] .menu { left: 50%; top: 43%; transform: translate(-50%, -50%); text-align: center; }
.pause-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }
body[data-mode="playing"] .menu { display: none; }
body[data-mode="error"] .spell-dock, body[data-mode="error"] .map, body[data-mode="error"] .tally { display: none; }

.tally {
  position: absolute;
  left: var(--safe-left);
  bottom: var(--safe-bottom);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 13px 8px 10px;
  pointer-events: none;
}
.tally output { display: block; color: #f8e7ba; font-size: 1rem; font-weight: 680; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tally div > span { display: block; margin-top: 3px; color: #c1c6b2; font-size: .72rem; }
.blocks-icon { display: block; width: 25px; height: 26px; position: relative; color: #cfbc87; }
.blocks-icon i { display: block; position: absolute; width: 8px; height: 8px; border: 1px solid; transform: rotate(15deg); }
.blocks-icon i:first-child { left: 4px; top: 3px; transform: rotate(-13deg); background: #d8c59235; }
.blocks-icon i:nth-child(2) { left: 14px; top: 7px; width: 6px; height: 6px; opacity: .75; }
.blocks-icon i:last-child { left: 7px; top: 15px; width: 10px; height: 10px; background: #d8c59263; }
.spell-dock { position: absolute; left: 50%; bottom: var(--safe-bottom); transform: translateX(-50%); width: max-content; }
.spell-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin-bottom: 11px;
  text-align: center;
  color: #e5e9d7;
  text-shadow: 0 2px 6px #101813, 0 0 11px #121a13;
  pointer-events: none;
}
.spell-info strong { color: var(--ivory); font: 600 1.26rem/1.1 Georgia, "Times New Roman", serif; }
.spell-info > span { font-size: .78rem; }
.spell-slots { display: grid; grid-template-columns: repeat(4, minmax(59px, 79px)); gap: 7px; }
.spell {
  position: relative;
  isolation: isolate;
  min-height: 69px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  overflow: hidden;
  padding: 5px 2px 6px;
  border: 1px solid #e0d7ae43;
  border-radius: 8px;
  background: radial-gradient(ellipse at 50% 35%, var(--wash), transparent 66%), #1a271eea;
  color: #dcdccc;
  box-shadow: 0 4px 17px #1117104a, inset 0 0 0 2px #ffffff06;
}
.spell::after {
  position: absolute; inset: auto 9px 0; content: ""; height: 1px; background: var(--tint);
  opacity: 0; box-shadow: 0 -1px 12px var(--tint);
}
.spell:hover { border-color: var(--tint); }
.spell[aria-pressed="true"] {
  color: #f4f0d8;
  border-color: var(--tint);
  background: radial-gradient(ellipse at 50% 38%, var(--wash), transparent 76%), #1b2d25f5;
  box-shadow: 0 0 24px var(--wash), inset 0 0 0 2px var(--wash);
}
.spell[aria-pressed="true"]::after { opacity: .82; }
.spell canvas { width: 38px; height: 38px; z-index: 1; pointer-events: none; }
.spell .spell-key { position: absolute; left: 6px; top: 5px; color: #d2d3bf; font-size: .66rem; line-height: 1; z-index: 1; }
.spell .spell-label { font-size: .73rem; font-weight: 580; z-index: 1; }
.spell .cooldown {
  position: absolute; inset: 0; transform-origin: bottom; transform: scaleY(var(--remaining, 0));
  background: #0b1514a6; pointer-events: none;
}
.spell .countdown {
  position: absolute; right: 5px; top: 3px; z-index: 1; color: #f6e9c5; font-size: .66rem;
  font-variant-numeric: tabular-nums;
}
.reticle {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%);
  color: #edf1d6;
  opacity: .8;
  filter: drop-shadow(0 1px 2px #20291d);
  pointer-events: none;
}
body[data-mode="playing"] .reticle { display: block; }
.reticle i, .reticle b { position: absolute; background: currentColor; }
.reticle i:nth-child(1), .reticle i:nth-child(2) { width: 6px; height: 1px; top: 13.5px; }
.reticle i:nth-child(2) { right: 0; }
.reticle i:nth-child(3), .reticle i:nth-child(4) { height: 6px; width: 1px; left: 13.5px; }
.reticle i:nth-child(4) { bottom: 0; }
.reticle b { width: 2px; height: 2px; left: 13px; top: 13px; transform: rotate(45deg); }
body[data-flash="true"] .reticle { color: var(--spell); opacity: 1; transform: translate(-50%, -50%) scale(1.26); }
.play-hint {
  position: absolute;
  left: 50%;
  top: calc(var(--safe-top) + 5px);
  transform: translateX(-50%);
  padding: 6px 11px;
  border: 1px solid #dfd8af3b;
  border-radius: 5px;
  color: #e9e9d4;
  background: #1a2620bd;
  font-size: .77rem;
  text-align: center;
  max-width: 44%;
  pointer-events: none;
}
@media (max-height: 680px) and (min-width: 651px) {
  .menu { top: 46%; }
  h1 { font-size: clamp(3.65rem, 9.5vh, 5.8rem); }
  .intro { margin: 17px 0; }
  .control-guide { margin-top: 13px; }
  .spell-info { margin-bottom: 6px; }
}
body[data-input="touch"][data-mode="playing"] .touch-controls { display: contents; }
body[data-input="touch"] .spell-key { display: none; }
.stick {
  position: absolute; left: calc(var(--safe-left) + 5px); bottom: calc(var(--safe-bottom) + 63px);
  width: 106px; height: 106px; border: 1px solid #e7e9ce61; border-radius: 50%;
  background: #1d2b2187; box-shadow: inset 0 0 0 10px #f8f7da0a;
  display: grid; place-items: center; touch-action: none;
}
.stick span {
  width: 43px; height: 43px; border: 1px solid #e6e4bda3; border-radius: 50%;
  background: #bfc39b4a; transform: translate(var(--jx, 0px), var(--jy, 0px)); pointer-events: none;
}
.touch-button {
  position: absolute; border: 1px solid #e3deac82; border-radius: 50%; padding: 0;
  display: grid; place-items: center; background: #1d2b21b7; touch-action: none;
}
.jump { width: 48px; height: 48px; right: calc(var(--safe-right) + 12px); bottom: calc(var(--safe-bottom) + 139px); }
.jump i { width: 15px; height: 15px; border: solid #ebdfbc; border-width: 2px 0 0 2px; transform: translateY(3px) rotate(45deg); }
.cast {
  right: var(--safe-right); bottom: calc(var(--safe-bottom) + 58px); width: 72px; height: 72px;
  border-color: var(--spell); box-shadow: inset 0 0 20px #b8f4cb20;
}
.cast canvas { width: 53px; height: 53px; pointer-events: none; }
.cast:active, .jump:active { background: #47674c; }
@media (max-width: 650px) {
  :root { --safe-top: max(17px, env(safe-area-inset-top)); --safe-left: max(17px, env(safe-area-inset-left)); --safe-right: max(17px, env(safe-area-inset-right)); --safe-bottom: max(15px, env(safe-area-inset-bottom)); }
  .map { width: 105px; padding: 6px; }
  .map-heading, .coordinates { font-size: .61rem; }
  .world-label { gap: 8px; }
  .world-label strong { font-size: .82rem; }
  .world-label small { font-size: .72rem; }
  .world-mark { scale: .88; transform-origin: left center; }
  .menu { top: 45%; left: max(6.1%, var(--safe-left)); }
  .menu-shade { background: linear-gradient(90deg, #101d17eb, #13221b99 49%, transparent 100%); }
  h1 { font-size: clamp(3.8rem, 15vw, 6rem); }
  .intro { max-width: 260px; margin: 17px 0; font-size: .94rem; }
  .genre { font-size: .7rem; letter-spacing: .11em; }
  .control-guide { margin-top: 15px; }
  .spell-slots { grid-template-columns: repeat(4, minmax(56px, 72px)); }
  .spell { min-height: 58px; padding: 3px 2px 4px; }
  .spell canvas { width: 32px; height: 32px; }
  .spell .spell-label { font-size: .67rem; }
  .spell-info { margin-bottom: 6px; }
  .spell-info strong { font-size: 1.1rem; }
  .spell-info > span { font-size: .71rem; }
  .tally { left: var(--safe-left); top: calc(var(--safe-top) + 48px); bottom: auto; gap: 6px; padding: 5px 8px 6px 6px; }
  .tally output { font-size: .91rem; }
  .tally div > span { font-size: .64rem; margin-top: 1px; }
  .play-hint { top: calc(var(--safe-top) + 91px); max-width: 70%; }
  .stick { bottom: calc(var(--safe-bottom) + 119px); width: 88px; height: 88px; }
  .stick span { width: 37px; height: 37px; }
  .cast { width: 64px; height: 64px; bottom: calc(var(--safe-bottom) + 112px); }
  .jump { bottom: calc(var(--safe-bottom) + 181px); width: 42px; height: 42px; }
}
@media (max-height: 480px) {
  :root { --safe-bottom: max(9px, env(safe-area-inset-bottom)); --safe-top: max(10px, env(safe-area-inset-top)); }
  .menu { left: max(5%, var(--safe-left)); top: 45%; max-width: 340px; }
  h1 { font-size: clamp(2.8rem, 10vh, 4.1rem); }
  .intro { margin: 11px 0; line-height: 1.35; font-size: .86rem; }
  .control-guide { margin-top: 8px; }
  .primary-button, .secondary-button { min-height: 38px; padding: 7px 16px; }
  .map { width: 94px; top: calc(var(--safe-top) + 45px); }
  .spell { min-height: 51px; }
  .spell canvas { width: 28px; height: 28px; }
  .stick { bottom: calc(var(--safe-bottom) + 51px); width: 77px; height: 77px; }
  .cast { bottom: calc(var(--safe-bottom) + 40px); width: 58px; height: 58px; }
  .jump { bottom: calc(var(--safe-bottom) + 104px); width: 41px; height: 41px; }
}
@media (max-height: 390px) and (orientation: landscape) {
  .control-guide { display: none; }
  .menu { top: 43%; }
}

:root { --health: #87c29b; }
body[data-mode="overlay"] .menu-shade { background: #0d1916bb; }
body[data-mode="playing"] #scene { cursor: crosshair; }
body[data-screen="error"] .map, body[data-screen="error"] .spell-dock,
body[data-screen="book"] .vitals, body[data-screen="book"] .spell-dock,
body[data-screen="room"] .vitals, body[data-screen="room"] .spell-dock,
body[data-screen="connect"] .spell-dock { display: none; }
body[data-hurt="true"] .view-shade { box-shadow: inset 0 0 min(15vw, 130px) #f45c5677; }
body[data-screen="playing"] .touch-controls { pointer-events: none; }
.stick, .touch-button { pointer-events: auto; }
.opening { max-width: 395px; }
.opening-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.opening-actions .secondary-button { min-width: 159px; }
.room-button { display: flex; align-items: center; justify-content: center; gap: 7px; width: auto; padding: 0 10px; font-size: .8rem; }
.online-dot { width: 7px; height: 7px; border-radius: 100%; background: #90e3ae; box-shadow: 0 0 8px #9de8b36b; }
body[data-net="bad"] .online-dot { background: #ecb279; box-shadow: none; }
.panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(530px, calc(100% - 28px));
  max-height: min(calc(88 * var(--viewport-unit)), 760px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(17px, 3.2vw, 30px);
  background: radial-gradient(ellipse at 10% 0%, #334438ed, transparent 58%), #17251ffb;
  border-color: #d9c69552;
  border-radius: 10px;
  box-shadow: 0 14px 75px #07110bdc, inset 0 1px #fae3a21c;
}
.panel h2 { margin: 0 0 2px; font-size: clamp(2.15rem, 5.5vw, 3.4rem); line-height: .96; }
.panel.narrow { width: min(350px, calc(100% - 28px)); text-align: center; }
.panel.narrow .intro { margin-inline: auto; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 19px; }
.panel-kicker { display: block; color: #e5c98e; font-weight: 650; font-size: .75rem; letter-spacing: .125em; text-transform: uppercase; margin-bottom: 7px; }
.close-button { flex-shrink: 0; font-size: 1.5rem; line-height: 1; color: #e8e2cc; }
.panel input:not([type="radio"]), .panel select {
  width: 100%;
  min-height: 41px;
  background: #101e18;
  border: 1px solid #e0d3a451;
  color: #f5efd9;
  border-radius: 5px;
  padding: 8px 11px;
  font: inherit;
  font-size: 1rem;
  user-select: text;
  -webkit-user-select: text;
}
.panel input::placeholder { color: #a4ad9c; }
.panel input:focus, .panel select:focus { outline: 1px solid #e0bf7a; border-color: #e0bf7a; }
.panel label, .panel legend { font-size: .89rem; color: #e9e7d4; font-weight: 580; }
#connect-form { display: grid; gap: 9px; }
.create-options { display: grid; gap: 9px; }
.game-modes { padding: 0; border: 0; margin: 4px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.game-modes legend { margin-bottom: 8px; }
.game-modes label {
  min-width: 0;
  padding: 9px;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 58px;
  background: #23342a;
  border: 1px solid #d9c79b36;
  border-radius: 6px;
  cursor: pointer;
  font-size: .89rem;
}
.game-modes label:has(:checked) { border-color: #cbbb81; background: #3a4732; }
.game-modes input { margin: 0; accent-color: #e6ca86; }
.game-modes small { display: block; margin-top: 3px; color: #c1c7b4; font-size: .73rem; font-weight: 400; }
#connect-form .primary-button { justify-self: start; }
.join-row { display: flex; align-items: end; gap: 8px; margin-top: 5px; }
.join-row label { display: grid; gap: 5px; flex: 1 1 auto; min-width: 0; }
.join-row input { text-transform: uppercase; }
.join-row input::placeholder { text-transform: none; }
.join-row .secondary-button, .invite-row .secondary-button { min-height: 41px; padding: 7px 13px; }
.panel-message { margin: 12px 0 0; color: #c9cfbe; font-size: .89rem; line-height: 1.42; }
#connect-message { color: #f2cc92; }
.invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  padding: 9px 12px;
  border: 1px solid #d5c89c30;
  border-radius: 6px;
  background: #13221ac7;
}
.invite-row output { display: block; user-select: text; font: 600 1.13rem/1.55 ui-monospace, monospace; letter-spacing: .11em; color: #f2d596; }
.room-start-city { display: block; color: #ded9c4; font-size: .75rem; }
.muted { color: #b6c3b2; font-size: .78rem; }
.goals { margin-bottom: 13px; color: #dddcca; font-size: .83rem; }
#goal-buttons, #assign-slots { display: flex; flex-wrap: wrap; gap: 5px; }
#goal-buttons { margin-top: 6px; }
.goal, .assign {
  min-width: 39px; height: 33px; padding: 3px 8px;
  border: 1px solid #e4d5ab56; border-radius: 5px; background: #20352a; font-size: .86rem;
}
.goal[aria-pressed="true"], .assign[aria-pressed="true"] { border-color: #efd194; color: #f4d99e; background: #4d4831; }
.goal:disabled[aria-pressed="true"] { opacity: .82; }
.winner { padding: 10px; margin-bottom: 12px; color: #f4d597; background: #c5a3532b; border: 1px solid #d1b67464; border-radius: 5px; }
.leaderboard { overflow: hidden; border: 1px solid #d1cfa337; border-radius: 5px; }
.score-head, .score-row { display: grid; grid-template-columns: minmax(0,1fr) 36px 36px; align-items: center; gap: 7px; font-size: .87rem; }
.score-head { background: #354637; color: #e0e1cc; padding: 6px 10px; }
.score-row { min-height: 33px; padding: 4px 10px; color: #f4edd7; border-top: 1px solid #d2cdb01c; }
.score-row > span:first-child { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 8px; overflow-wrap: anywhere; }
.score-row > span:nth-child(n+2), .score-head > span:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; }
.score-row small { color: #d8c788; font-size: .68rem; }
.score-row[data-offline="true"] { opacity: .58; }
#room-screen .panel-heading { align-items: center; }
#continue-room { flex: 0 0 auto; min-height: 44px; padding: 7px 14px; }
.score-row .meet-player { min-height: 38px; padding: 4px 9px; margin-left: auto; font-size: .75rem; }
#room-message:empty { display: none; }
#room-screen .leaderboard { margin-bottom: 10px; }
.panel-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.panel-actions button, #connect-form .primary-button { min-height: 42px; padding: 8px 13px; }
.book { width: min(760px, calc(100% - 24px)); display: flex; flex-direction: column; }
.book .panel-heading { flex: 0 0 auto; }
.book-tools { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(100px,1fr); gap: 9px; }
.book-tools label { display: grid; gap: 5px; }
.book-slot-row { display: flex; align-items: center; gap: 9px; font-size: .82rem; color: #dfe1cc; margin: 11px 0; }
.assign { min-width: 30px; height: 29px; padding: 2px 6px; }
.spell-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px; padding: 1px 5px 2px 1px; min-height: 90px; overflow: auto; scrollbar-color: #8e9273 #16241c; }
.book-spell {
  display: grid; grid-template-columns: 37px minmax(0,1fr); align-items: center; gap: 7px;
  min-height: 63px; text-align: left; padding: 6px 7px; border: 1px solid #cbcda437;
  border-radius: 6px; background: #1d3026; color: #f3eed5;
}
.book-spell:hover, .book-spell:focus-visible { border-color: var(--tint); background: #2b4031; }
.book-spell[data-equipped="true"] { border-left: 3px solid var(--tint); padding-left: 5px; }
.book-spell canvas { width: 36px; height: 36px; }
.book-spell strong, .book-spell small { display: block; }
.book-spell strong { font-size: .86rem; line-height: 1.16; }
.book-spell small { color: #c2c8b5; font-size: .71rem; line-height: 1.24; margin-top: 3px; }
.dock-actions { display: flex; gap: 7px; align-items: stretch; }
.book-button { width: 72px; padding-inline: 2px; --tint: #d2c181; --wash: #b5a76625; font-size: .75rem; gap: 5px; }
.book-button i { position: relative; width: 23px; height: 21px; color: #e4c985; }
.book-button i::before, .book-button i::after { content: ""; width: 11px; height: 17px; border: 1.5px solid; position: absolute; top: 2px; border-radius: 2px; }
.book-button i::before { left: 0; transform: skewY(8deg); }
.book-button i::after { right: 0; transform: skewY(-8deg); }
.spell-info > span { display: block; max-width: min(560px, 91vw); }
.spell-slots { grid-template-columns: repeat(4, minmax(62px, 78px)); }
.spell .spell-label { width: 100%; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-inline: 2px; }
.vitals { position: absolute; left: var(--safe-left); bottom: var(--safe-bottom); display: grid; gap: 7px; pointer-events: none; }
.vitals .tally { position: static; }
.health { min-width: 126px; padding: 7px 10px 9px; }
.health strong { font-size: 1.12rem; font-variant-numeric: tabular-nums; color: #f3ead3; }
.health > div > span { font-size: .7rem; color: #cbd1be; }
.health-bar { height: 5px; margin-top: 4px; overflow: hidden; border-radius: 99px; background: #101a15; }
.health-bar > span { display: block; width: var(--hp, 100%); height: 100%; background: var(--health); transition: width .12s linear; }
.respawn {
  position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%);
  padding: 10px 17px; width: max-content; max-width: 90vw; border-radius: 6px;
  background: #15201bd9; color: #f9ddb1; border: 1px solid #f2c69283; text-align: center;
  font-weight: 650; pointer-events: none;
}
.kill-feed { position: absolute; right: var(--safe-right); top: calc(var(--safe-top) + 219px); display: grid; justify-items: end; gap: 4px; max-width: min(38vw, 280px); color: #f0e9d1; font-size: .78rem; pointer-events: none; }
.kill-feed > div { padding: 4px 7px; background: #17251ccc; border-radius: 4px; text-align: right; overflow-wrap: anywhere; }
@media (max-width: 650px) {
  .opening { max-width: min(86vw, 340px); }
  .opening-actions .primary-button, .opening-actions .secondary-button { min-width: 0; padding: 8px 12px; min-height: 41px; font-size: .83rem; gap: 8px; }
  .dock-actions, .spell-slots { gap: 5px; }
  .spell-slots { grid-template-columns: repeat(4, minmax(47px, 62px)); }
  .book-button { width: clamp(46px, 13.4vw, 62px); font-size: .63rem; }
  .spell .spell-label { font-size: .62rem; }
  .vitals { top: calc(var(--safe-top) + 48px); bottom: auto; gap: 5px; }
  .vitals .tally { inset: auto; }
  .health { min-width: 110px; }
  .play-hint { top: calc(var(--safe-top) + 130px); }
  .kill-feed { top: calc(var(--safe-top) + 170px); max-width: 45vw; }
  .panel { max-height: calc(89 * var(--viewport-unit)); }
}
@media (max-width: 445px) {
  .spell-list { grid-template-columns: 1fr; }
  .spell-info > span { line-height: 1.18; max-width: 84vw; }
  .spell-info strong { max-width: 87vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-height: 480px) {
  .panel { max-height: calc(94 * var(--viewport-unit)); padding: 11px 15px; }
  .panel-heading { margin-bottom: 10px; }
  .panel h2 { font-size: 1.92rem; }
  .invite-row { margin-bottom: 7px; }
  .score-row { min-height: 26px; }
  .vitals .tally { display: none; }
  .spell-info > span { display: none; }
}

.view-shade {
  background: linear-gradient(0deg, #120f18bd, transparent 23%), linear-gradient(#15121c64, transparent 20%),
    radial-gradient(ellipse at 51% 46%, transparent 48%, #16132345 100%);
}
.menu-shade { background: linear-gradient(90deg, #14121ef5, #182020db 18%, #181d239d 34%, #110c1f22 60%, transparent 78%); }
.glass, .icon-button { background: linear-gradient(132deg, #262a2def, #191721ed); }
.spell { background: radial-gradient(ellipse at 50% 37%, var(--wash), transparent 73%), #1e1b27ef; }
.spell[aria-pressed="true"] { background: radial-gradient(ellipse at 50% 38%, var(--wash), transparent 76%), #242233f5; }
@media (max-width: 650px) {
  .menu-shade { background: linear-gradient(90deg,#171320ec,#18191e8c 56%,#14132021); }
}

.map-heading button {
  border:0; padding:2px 3px; background:transparent; color:inherit;
  font:inherit; letter-spacing:inherit; border-radius:3px; pointer-events:auto;
}
.map-heading button:hover { color:#f6d59a; background:#ecd5a21b; }
.route-distance {
  display:block; text-align:center; color:#edce90; font-size:.70rem;
  margin-top:6px; line-height:1.2; white-space:normal;
}
.threat-option { display:flex; align-items:center; gap:8px; margin:3px 0; }
.threat-option input[type="checkbox"] { width:18px; height:18px; padding:0; accent-color:#e6c78a; }
.room-threats {
  display:flex; justify-content:space-between; align-items:center; gap:12px; padding:8px 10px;
  margin:10px 0; border-radius:6px; border:1px solid #ebd3a731; background:#161c21c9;
}
.room-threats strong { display:block; font-size:.91rem; }
.room-threats small { display:block; color:#c6ccbc; font-size:.77rem; margin-top:3px; }
#mobs-toggle {
  border:1px solid #d7c6a379; padding:6px 9px; min-width:54px; border-radius:5px;
  background:#30323a; color:#f1e4cc; font-size:.82rem;
}
#mobs-toggle[aria-checked="true"] { color:#bfe9bf; border-color:#87be9b; background:#263a30; }
#built-stat { color:#e6c891; }
#built-stat output { display:inline; font-size:inherit; }
.mob-focus {
  position:absolute; top:calc(50% + 24px); left:50%; transform:translateX(-50%);
  color:#ffd3a6; padding:4px 7px; text-shadow:0 2px 4px #140a09;
  border-radius:4px; background:#191319b2; font-weight:600; font-size:.76rem;
  pointer-events:none; white-space:nowrap;
}
.mob-focus[data-ally="true"] { color:#a5f0cd; }
body[data-screen="atlas"] .spell-dock { display:none; }
.atlas { width:min(580px,calc(100% - 24px)); }
.atlas-content { display:grid; justify-items:stretch; gap:10px; }
#atlas {
  width:min(100%,48vh,480px); height:auto; display:block; margin-inline:auto;
  border:1px solid #d6b57271; border-radius:5px; box-shadow:0 7px 27px #080a1399;
}
.atlas-content label { display:grid; grid-template-columns:auto minmax(0,1fr); align-items:center; gap:12px; }
@media(max-height: 510px) and (min-width: 670px) {
  .atlas-content { grid-template-columns:minmax(155px,1.28fr) 1fr; align-items:start; }
  .atlas-content label { display:grid; grid-template-columns:1fr; }
  #atlas { width:100%; max-width:54vh; }
}

/* The title screen and the game controls share the compact, high-contrast palette. */
:root {
  --ink: #191b1c;
  --panel: #242628;
  --ivory: #f1efe5;
  --gold: #edc45b;
  --soft-text: #b8b7ab;
}
body { background: var(--ink); }
body[data-screen="title"] .world-label,
body[data-screen="title"] .map,
body[data-screen="title"] .spell-dock { display: none; }
body[data-screen="title"] .hud-header { z-index: 3; justify-content: flex-end; }
body[data-screen="title"] .menu-shade {
  background: linear-gradient(90deg,#141516 0%,#171819fa 24%,#151618bc 57%,#17181967),linear-gradient(0deg,#111213c9,transparent 60%);
}
#title-screen {
  inset: max(35px,var(--safe-top)) max(6vw,var(--safe-right)) max(35px,var(--safe-bottom)) max(7vw,var(--safe-left));
  transform: none;
  max-width: none;
  display: grid;
  grid-template-columns: minmax(0,.88fr) minmax(0,1fr);
  align-items: center;
  gap: clamp(24px,5vw,78px);
  max-height: 850px;
  margin-block: auto;
}
.menu-main { justify-self: start; width: 100%; min-width: 0; }
.opening h1 {
  margin: 0 0 clamp(25px,6.4vh,65px) -.047em;
  font-family: Impact,"Arial Black",system-ui,sans-serif;
  font-size: clamp(3rem,6.18vw,7.3rem);
  line-height: .82;
  font-weight: 950;
  letter-spacing: -.074em;
  text-transform: uppercase;
  text-shadow: none;
}
.opening h1 span,.opening h1 em { display: block; }
.opening h1 em { color: var(--gold); font-style: normal; margin-top: .09em; }
.menu-label {
  margin-bottom: 9px;
  color: var(--soft-text);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .095em;
  text-transform: uppercase;
}
#skins { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 6px; width: min(100%,432px); }
.skin-card {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  min-width: 0;
  min-height: 54px;
  border: 1px solid #f2efdc28;
  border-radius: 3px;
  padding: 0;
  background: #292b2ddc;
  color: #e6e5dc;
  overflow: hidden;
}
.skin-card[aria-pressed="true"] { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); background: #424035; }
.skin-card:hover:not([aria-pressed="true"]) { background: #393b3a; }
.skin-card canvas { display: block; width: 100%; height: clamp(36px,8.4vh,76px); object-fit: contain; align-self: end; }
.skin-card span { border-top: 1px solid #ffffff10; padding: 5px 0; font-size: .82rem; font-weight: 690; overflow-wrap: anywhere; }
.skin-card[aria-pressed="true"] span { background: var(--gold); color: #201b0d; }
.opening-actions { margin-top: clamp(18px,3.5vh,34px); width: min(100%,432px); display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
.opening-actions .primary-button, .opening-actions .secondary-button { min-width: 0; text-align: center; padding: 9px 14px; }
.opening-actions #solo { display: block; overflow-wrap: anywhere; }
.primary-button,.secondary-button { border-radius: 4px; letter-spacing: normal; box-shadow: none; }
.primary-button { background: var(--gold); border-color: var(--gold); color: #231e12; }
.primary-button:hover:enabled { background: #f6d47d; box-shadow: none; }
.secondary-button { background: #282b2c; border-color: #e7e4ce44; }
.secondary-button:hover:enabled,.icon-button:hover:enabled { background: #373a3a; border-color: #e7e4ce78; }
.menu-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 19px; margin-top: 12px; }
.menu-tools button { padding: 5px 0; font-size: .83rem; color: #c9c9b9; border: 0; border-bottom: 1px solid #d9d6bb52; background: none; }
.menu-tools button:hover { color: var(--gold); border-color: var(--gold); }
.fighter {
  display: grid;
  isolation: isolate;
  align-items: end;
  justify-items: center;
  position: relative;
  height: min(77vh,690px);
  min-height: 0;
  width: 100%;
  overflow: hidden;
  margin: 0;
  border-bottom: 1px solid #b5ae8e57;
}
.fighter-plane {
  position: absolute;
  z-index: -1;
  inset: 10% 4% 9%;
  background: linear-gradient(143deg,#b18a46 0%,#5e4f30 53%,#211f1a 100%);
  clip-path: polygon(16% 0,100% 0,84% 100%,0 100%);
  opacity: .83;
}
.fighter-plane::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg,#f0e1b30c 0 1px,transparent 1px 8px),repeating-linear-gradient(90deg,#f0e1b30c 0 1px,transparent 1px 8px);
}
#fighter-model {
  position: absolute;
  bottom: 6%;
  display: block;
  width: auto;
  max-width: 100%;
  height: 91%;
  object-fit: contain;
  filter: drop-shadow(13px 13px 0 #14110f5e);
  touch-action: none;
  cursor: grab;
}
#fighter-model:active { cursor: grabbing; }
.fighter figcaption {
  position: absolute;
  right: 0;
  bottom: 0;
  margin: 0 0 .45em;
  color: #f8f0d6;
  background: #181919e5;
  border-left: 3px solid var(--gold);
  font-size: clamp(1.05rem,2.4vw,2.1rem);
  font-weight: 850;
  line-height: 1;
  padding: .34em .55em;
}
.panel { background: #222426fa; border-color: #e5dec84c; border-radius: 6px; }
.panel h2 { font-family: system-ui,sans-serif; font-weight: 820; font-size: clamp(1.68rem,3.8vw,2.65rem); letter-spacing: -.044em; text-shadow: none; }
.panel .panel-kicker { color: var(--gold); }
.panel input,.panel select,.game-modes label>span,.book-spell,.goal,.assign,.invite-row,.room-threats { background: #191b1d; border-color: #ded9c544; }
.score-head { background: #363737; }
.panel input,.panel select { font-size: max(16px,1rem); }
#auto-jump,#auto-aim { justify-content: space-between; }
#auto-jump small,#auto-aim small { color: var(--gold); font-weight: 650; }
.atlas-options { display: grid; gap: 11px; }
.biome-key { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; color: #e0ddd0; font-size: .75rem; }
.biome-key li { display: inline-flex; align-items: center; gap: 5px; }
.biome-key i { width: 10px; height: 10px; border-radius: 2px; border: 1px solid #fff4; }
.ship-focus {
  position: absolute;
  top: calc(50% + 25px);
  left: 50%;
  transform: translateX(-50%);
  max-width: 85%;
  padding: 5px 9px;
  background: #1b1d20dc;
  border: 1px solid #ecd0916b;
  border-radius: 4px;
  color: #fae2a2;
  font-size: .79rem;
  white-space: nowrap;
  text-align: center;
  pointer-events: none;
}
.flight-status {
  position: absolute;
  top: calc(var(--safe-top) + 52px);
  left: var(--safe-left);
  min-width: 132px;
  max-width: 38vw;
  display: grid;
  gap: 3px;
  padding: 7px 9px;
  background: #1b1d20dd;
  border: 1px solid #ecdec453;
  border-radius: 4px;
  font-size: .76rem;
  pointer-events: none;
}
.flight-status strong { color: #fae2a2; font-size: .89rem; }
.flight-keys { color: #d1cfbb; }
.ship-hp { display: grid; grid-template-columns: repeat(3,1fr); gap: 3px; margin-block: 2px; }
.ship-hp i { height: 5px; background: #74665a; border-radius: 1px; }
.ship-hp i[data-full] { background: #efc765; }
.helm-button {
  position: absolute;
  z-index: 2;
  bottom: calc(var(--safe-bottom) + 132px);
  left: 50%;
  transform: translateX(-50%);
  background: #211e16ed;
  border: 1px solid #e9c367;
  border-radius: 4px;
  min-height: 43px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #ffedba;
  font-size: .86rem;
  white-space: nowrap;
}
.helm-button kbd { min-width: 23px; text-align: center; }
#turn-phone { display: none; }

@media (max-height: 540px) and (orientation: landscape) {
  .opening h1 { margin-bottom: clamp(11px,4vh,22px); font-size: clamp(1.85rem,min(5.95vw,12.4vh),4.4rem); }
  .menu-label { font-size: .69rem; margin-bottom: 5px; }
  .opening-actions { margin-top: 12px; }
  .opening-actions .primary-button,.opening-actions .secondary-button { min-height: 43px; font-size: .81rem; padding: 5px 7px; gap: 7px; }
  .menu-tools { margin-top: 4px; }
  .menu-tools button { padding-block: 5px; }
  .flight-status { top: calc(var(--safe-top) + 75px); }
  .helm-button { bottom: calc(var(--safe-bottom) + 81px); }
  .atlas { max-height: calc(94 * var(--viewport-unit)); width: min(650px,calc(100% - 28px)); }
  .atlas-content { grid-template-columns: auto minmax(115px,1fr); align-items: start; gap: 15px; }
  #atlas { width: clamp(130px,calc(65 * var(--viewport-unit)),365px); }
  .atlas-content label { grid-template-columns: 1fr; }
  .panel { max-height: calc(94 * var(--viewport-unit)); padding: 12px 16px; }
  .panel-heading { margin-bottom: 10px; }
}
@media (max-width: 650px) and (orientation: portrait) {
  #title-screen {
    inset: max(32px,var(--safe-top)) var(--safe-right) max(17px,var(--safe-bottom)) var(--safe-left);
    grid-template-columns: 1fr;
    grid-template-rows: minmax(170px,1fr) auto;
    align-items: center;
    gap: 14px;
  }
  .fighter { grid-row: 1; height: 100%; }
  .menu-main { grid-row: 2; }
  .opening h1 { margin-bottom: 17px; font-size: clamp(1.95rem,8.3vw,4.4rem); }
  .opening h1 span,.opening h1 em { display: inline; }
  .opening-actions { width: 100%; margin-top: 14px; }
  #skins { width: 100%; }
}
@media (orientation: landscape) {
  body[data-input="touch"] { --safe-left:max(14px,env(safe-area-inset-left)); --safe-right:max(14px,env(safe-area-inset-right)); }
  body[data-input="touch"][data-screen="playing"] .world-label small { display: none; }
  body[data-input="touch"] .stick {
    width: clamp(83px,calc(25 * var(--viewport-unit)),124px); height: clamp(83px,calc(25 * var(--viewport-unit)),124px);
    left: var(--safe-left); bottom: max(13px,var(--safe-bottom));
    background: #1d2024ad; border-color: #efead17d;
  }
  body[data-input="touch"] .touch-button { background: #1e2126cf; border-color: #efead17d; }
  body[data-input="touch"] .cast {
    width: clamp(62px,calc(19 * var(--viewport-unit)),94px); height: clamp(62px,calc(19 * var(--viewport-unit)),94px);
    right: var(--safe-right); bottom: max(13px,var(--safe-bottom));
    border-color: var(--spell);
  }
  body[data-input="touch"] .cast canvas { width: min(calc(12 * var(--viewport-unit)),54px); height: min(calc(12 * var(--viewport-unit)),54px); }
  body[data-input="touch"] .jump { width: 46px; height: 46px; bottom: calc(max(13px,var(--safe-bottom)) + clamp(69px,calc(21 * var(--viewport-unit)),102px)); }
  body[data-input="touch"] .jump { right: var(--safe-right); }
  body[data-input="touch"] .touch-button:active { background: #525446; }
  body[data-input="touch"] .vitals { left: var(--safe-left); top: calc(var(--safe-top) + 43px); bottom: auto; }
  body[data-input="touch"] .flight-status { top: calc(var(--safe-top) + 95px); }
  body[data-input="touch"] .vitals .tally,body[data-input="touch"] .spell-info>span,body[data-input="touch"] .flight-keys,body[data-input="touch"] .route-distance,body[data-input="touch"] .helm-button kbd { display: none; }
  body[data-input="touch"] .map { width: clamp(70px,calc(24 * var(--viewport-unit)),114px); padding: 4px; right: var(--safe-right); }
  body[data-input="touch"] .map .coordinates { display: none; }
  body[data-input="touch"] .map-heading { padding: 0; }
  body[data-input="touch"] .map-heading button { min-height: 26px; }
  body[data-input="touch"][data-screen="playing"] .actions .icon-button { width: 42px; height: 40px; }
  body[data-input="touch"][data-screen="playing"] .actions .room-button { width: auto; min-width: 52px; }
  body[data-input="touch"] .spell-dock { bottom: max(9px,var(--safe-bottom)); width: min(47vw,345px); }
  body[data-input="touch"] .dock-actions,body[data-input="touch"] .spell-slots { gap: 4px; }
  body[data-input="touch"] .spell-slots { width: 100%; grid-template-columns: repeat(4,minmax(0,1fr)); }
  body[data-input="touch"] .spell { min-height: 48px; }
  body[data-input="touch"] .spell .spell-label { font-size: .64rem; }
  body[data-input="touch"] .book-button { width: 54px; flex: 0 0 54px; }
  body[data-input="touch"] .spell-info { margin-bottom: 4px; }
  body[data-input="touch"] .spell-info strong { font-family: system-ui,sans-serif; font-size: .78rem; line-height: 1.1; }
  body[data-input="touch"] .play-hint { top: var(--safe-top); max-width: 49%; font-size: .69rem; }
  body[data-input="touch"] .kill-feed { top: calc(var(--safe-top) + 167px); }
  body[data-input="touch"] .helm-button { bottom: calc(max(15px,var(--safe-bottom)) + clamp(62px,calc(17 * var(--viewport-unit)),87px)); }
}
.aim-target {
  position: absolute;
  z-index: 1;
  width: 23px;
  aspect-ratio: 1;
  transform: translate(-50%,-50%);
  border: 1px solid #e8d695;
  border-radius: 50%;
  box-shadow: 0 0 8px #cfad5c56,inset 0 0 6px #e1c77436;
  pointer-events: none;
}
.aim-target::before {
  content:"";
  position:absolute;
  inset:8px;
  border-radius:50%;
  background:#f9e7aa;
}
.shield-action {
  --ward:#83dce8;
  position:absolute;
  z-index:2;
  right:var(--safe-right);
  bottom:var(--safe-bottom);
  display:grid;
  grid-template-columns:auto auto auto;
  align-items:center;
  justify-content:center;
  gap:3px 7px;
  min-width:105px;
  min-height:53px;
  padding:5px 8px 8px;
  overflow:hidden;
  color:#ddf6f7;
  border:1px solid #b9eeec78;
  border-radius:5px;
  background:#202c33ed;
  font-size:.8rem;
  font-weight:720;
}
.shield-action::after {
  content:"";
  position:absolute;
  left:0;
  bottom:0;
  width:var(--charge,100%);
  height:3px;
  background:var(--ward);
}
.shield-action[aria-pressed="true"] { background:#215669ee; border-color:#a4f4ff; box-shadow:0 0 10px #74d7ec43; }
.shield-action[data-empty="true"] { color:#cbccc8; border-color:#c2c4c16b; }
.shield-icon {
  display:block;
  width:17px;
  height:20px;
  background:currentColor;
  clip-path:polygon(50% 0,93% 17%,87% 66%,50% 100%,13% 66%,7% 17%,50% 0,50% 10%,19% 23%,24% 62%,50% 86%,76% 62%,81% 23%,50% 10%);
}
.shield-charge { grid-column:1/-1; color:#a9eafa; font-variant-numeric:tabular-nums; font-size:.72rem; line-height:1.1; }
.shield-action kbd { font-size:.68rem; line-height:1; min-width:0; padding:3px 5px; }
body[data-guard-hit="true"] .view-shade { box-shadow:inset 0 0 min(11vw,86px) #55cce65e; }

@media (orientation: landscape) {
  body[data-input="touch"] .shield-action {
    right:calc(var(--safe-right) + clamp(67px,calc(20 * var(--viewport-unit)),97px) + 8px);
    bottom:max(13px,var(--safe-bottom));
    grid-template-columns:1fr;
    justify-items:center;
    gap:3px;
    width:51px;
    min-width:0;
    min-height:51px;
    padding:5px 4px;
    border-radius:10px;
  }
  body[data-input="touch"] .shield-action .shield-label,body[data-input="touch"] .shield-action kbd { display:none; }
}
@media (max-width: 635px) and (orientation: landscape) {
  body[data-input="touch"] .spell-dock { width:min(43vw,290px); }
  body[data-input="touch"] .book-button { width:42px; flex-basis:42px; }
}

.field-icon i { position: relative; display: block; color: #e9dfbf; }
.pack-icon { width: 15px; height: 15px; border: 1px solid currentColor; border-radius: 3px; }
.pack-icon::before { content: ''; position: absolute; left: 4px; top: -5px; width: 6px; height: 4px; border: 1px solid currentColor; border-radius: 2px 2px 0 0; }
.pack-icon::after { content: ''; position: absolute; inset: 6px 2px 3px; border-top: 1px solid currentColor; border-bottom: 1px solid currentColor; }
.camera-icon { width: 17px; height: 12px; border: 1px solid currentColor; border-radius: 2px; }
.camera-icon::before { content: ''; position: absolute; width: 6px; height: 6px; inset: 2px auto auto 4px; border: 1px solid currentColor; border-radius: 50%; }
.camera-icon::after { content: ''; position: absolute; width: 7px; height: 3px; left: 4px; top: -4px; border: 1px solid currentColor; border-radius: 2px 2px 0 0; }
#view-camera[aria-pressed="true"] { background: #61502b; border-color: #d8aa55; }
#pause-view { justify-content: space-between; }
#pause-view small { color: var(--gold); }
body[data-screen="gear"] .spell-dock, body[data-screen="gear"] .map { display: none; }
.context-actions { position: absolute; z-index: 2; left: 50%; bottom: calc(var(--safe-bottom) + 181px); transform: translateX(-50%); display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; max-width: 63vw; width: max-content; pointer-events: none; }
.context-actions button { pointer-events: auto; background: #23221aee; border: 1px solid #caa567b2; border-radius: 4px; padding: 4px 8px; min-height: 36px; display: flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 650; }
.context-actions button:active { background: #5b4930; }
.context-actions kbd { min-width: 18px; text-align: center; }
.town-speech { position: absolute; z-index: 2; inset: 0; pointer-events: none; }
.town-speech span { position: absolute; transform: translate(-50%,-100%); color: #f4ebd8; background: #1e2022eb; border: 1px solid #d8c49d9a; border-radius: 6px 6px 6px 1px; padding: 5px 9px; font-size: .76rem; line-height: 1.18; white-space: nowrap; max-width: min(230px,40vw); overflow: hidden; text-overflow: ellipsis; }
.player-labels { position: absolute; z-index: 2; inset: 0; pointer-events: none; }
.player-labels span {
  position: absolute;
  transform: translate(-50%,-100%);
  max-width: 32vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #192523e8;
  border: 1px solid #a5d4c17d;
  border-radius: 4px;
  color: #eff9e8;
  font-size: clamp(.68rem,1.6vw,.87rem);
  font-weight: 700;
  line-height: 1.2;
  padding: 3px 7px;
}
.mob-focus[data-neutral="true"] { border-color: #e6d3a17c; color: #f0dfb6; }
@media (orientation:landscape) {
  body[data-input="touch"] .context-actions { max-width: 48vw; bottom: calc(max(14px,var(--safe-bottom)) + clamp(103px,calc(29 * var(--viewport-unit)),137px)); }
  body[data-input="touch"] .context-actions button { min-height: 41px; }
  body[data-input="touch"] .context-actions kbd { display: none; }
}
.settings-panel { width: min(620px,calc(100% - 28px)); }
.settings-panel .panel-heading { align-items: center; }
#close-settings { min-height: 42px; padding: 6px 13px; }
.graphics-settings { min-inline-size: 0; margin: 0; padding: 0; border: 0; }
.graphics-settings legend { margin-bottom: 8px; color: var(--gold); font-size: .87rem; font-weight: 700; }
.graphics-settings label { display: grid; gap: 4px; min-width: 0; color: #d9d9ca; font-size: .84rem; }
.graphics-preset { grid-template-columns: minmax(0,1fr) minmax(0,2fr); align-items: center; padding-bottom: 10px; }
.graphics-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px 14px; padding-top: 10px; border-top: 1px solid var(--edge); }
.settings-panel select:disabled { opacity: .5; }
.look-settings { border-top: 1px solid var(--edge); margin-top: 12px; padding-top: 9px; }
.look-settings label { display: flex; justify-content: space-between; gap: 12px; font-size: .85rem; }
.look-settings output { color: var(--gold); font-variant-numeric: tabular-nums; }
.settings-panel .look-settings input { width: 100%; min-height: 32px; padding: 0; accent-color: var(--gold); }
@media (max-height: 450px) and (orientation: landscape) {
  .graphics-options { grid-template-columns: repeat(auto-fit,minmax(126px,1fr)); gap: 6px 10px; }
  .settings-panel select { min-height: 34px; }
}
.room-button #net-latency { opacity: .81; font-size: .65rem; font-variant-numeric: tabular-nums; }
.round-score {
  width: max-content;
  padding: 6px 10px;
  color: var(--gold);
  font-size: .78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.map-tools { display: flex; flex-wrap: wrap; gap: 5px; }
.map-tools button { min-height: 34px; padding: 4px 7px; flex: 1 0 auto; font-size: .73rem; }
#atlas { cursor: crosshair; touch-action: none; }
#atlas-distance { color: var(--gold); font-size: .78rem; }
.render-status {
  position: absolute;
  z-index: 10;
  top: calc(var(--safe-top) + 51px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  border: 1px solid var(--edge);
  border-radius: 5px;
  background: #1a2129;
  font-size: .84rem;
}
.hit-mark, .hit-direction, .damage-values { position: absolute; z-index: 2; pointer-events: none; }
.hit-mark {
  top: 50%;
  left: 50%;
  width: 25px;
  aspect-ratio: 1;
  transform: translate(-50%,-50%) rotate(45deg);
  background:
    linear-gradient(currentColor,currentColor) center top / 2px 8px,
    linear-gradient(currentColor,currentColor) center bottom / 2px 8px,
    linear-gradient(currentColor,currentColor) left center / 8px 2px,
    linear-gradient(currentColor,currentColor) right center / 8px 2px;
  background-repeat: no-repeat;
  color: #fff0b5;
  filter: drop-shadow(0 1px 2px #140f0b);
}
.hit-mark[data-down="true"] { width: 32px; color: #fca87a; }
.hit-direction {
  top: 50%;
  left: 50%;
  width: 113px;
  aspect-ratio: 1;
  transform: translate(-50%,-50%) rotate(var(--bearing, 0rad));
}
.hit-direction::before {
  content: '';
  display: block;
  margin: auto;
  width: 27px;
  height: 8px;
  border-top: 4px solid #ff805e;
  border-radius: 50%;
  filter: drop-shadow(0 1px 2px #1c0a08);
}
.damage-values { inset: 0; }
.damage-values span {
  position: absolute;
  transform: translate(-50%,-50%);
  color: #fff0b5;
  font-weight: 800;
  font-size: clamp(.88rem,calc(2.2 * var(--viewport-unit)),1.25rem);
  text-shadow: 0 1px 2px #19110c, 0 0 6px #241809;
}
.damage-values span[data-down="true"] { color: #fda684; }
body[data-input="touch"] .cast {
  isolation: isolate;
  -webkit-user-select: none;
  user-select: none;
}
body[data-input="touch"] .cast::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: conic-gradient(var(--spell) calc(var(--ready, 1) * 1turn), #e8ead921 0);
  mask: radial-gradient(transparent 62%, black 64%);
  pointer-events: none;
}
body[data-input="touch"] .cast[data-held="true"] {
  background: #393a32;
  box-shadow: 0 0 20px color-mix(in srgb,var(--spell) 32%,transparent);
}
@media (orientation: landscape) {
  body[data-input="touch"] .round-score { padding: 4px 7px; font-size: .69rem; }
  .map-tools button { min-height: 39px; }
}

:root {
  --gold: #e5c692;
  --ivory: #f1eee5;
  --edge: #c7c3af3d;
}
body:not([data-screen="playing"]) :is(.map,.spell-dock,.touch-controls,.reticle,.flight-status,.focus-gear,.boss-status,.summit-signs) {
  display: none;
}
body[data-mode="overlay"] .menu-shade { background: #11171bc4; }
body[data-mode="overlay"] .world-label { visibility: hidden; }
.panel {
  z-index: 5;
  max-height: min(820px,calc(calc(100 * var(--viewport-unit)) - max(20px,env(safe-area-inset-top)) - max(20px,env(safe-area-inset-bottom))));
  background: linear-gradient(150deg,#252c2f,#1a2023 67%);
  border: 1px solid #d4caad4e;
  border-radius: 12px;
  box-shadow: 0 18px 64px #050a0dc5;
  scrollbar-width: thin;
}
.panel h2 { letter-spacing: -.035em; line-height: 1; }
.primary-button, .secondary-button { border-radius: 7px; }
.primary-button { background: #e9c991; border-color: #e9c991; color: #241c13; }
.primary-button:hover:enabled { background: #f6dca8; border-color: #f6dca8; }
.secondary-button { background: #252d30; border-color: #d7d0b33d; }
.secondary-button:hover:enabled { background: #354042; border-color: #dccba875; }
.spawn-select {
  display: grid;
  grid-template-columns: max-content minmax(0,1fr);
  align-items: center;
  gap: 7px 12px;
  font-size: .82rem;
  color: #d2d1c4;
}
.spawn-select select {
  max-width: 100%;
  min-height: 40px;
  border: 1px solid #d5cbb34f;
  border-radius: 6px;
  padding: 6px 9px;
  color: var(--ivory);
  background: #222b2df5;
  font: 600 max(.85rem,16px) system-ui,sans-serif;
}
.menu-main .spawn-select { margin-top: 16px; width: min(100%,432px); }
#connect-form .spawn-select { grid-column: 1/-1; }
#room-spawn-row { margin: 12px 0; }
#title-screen .fighter-plane {
  background: radial-gradient(ellipse at 50% 65%,#bf92674b,transparent 66%);
  border-color: #dcc59a5f;
}
.opening h1 { margin-bottom: clamp(17px,5vh,52px); }
.skin-card { border-radius: 7px; background: #20292bdc; }
.skin-card[aria-pressed="true"] { background: #515043; }
.pause-panel { width: min(475px,calc(100% - 28px)); }
.pause-panel .panel-heading { align-items: baseline; margin-bottom: 17px; }
.pause-place { color: #d8c59f; font-size: .78rem; text-align: right; }
.pause-actions {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 7px;
  margin-top: 0;
}
.pause-actions > button { min-height: 44px; padding: 7px 10px; font-size: .85rem; }
.pause-actions > :is(#resume,#pause-view,#pause-room,#pause-settings) { grid-column: 1 / -1; }
.pause-actions #resume { min-height: 48px; }
.pause-actions :is(#auto-jump,#auto-aim) { gap: 5px; }
.pause-actions :is(#auto-jump,#auto-aim,#pause-view) small { white-space: nowrap; font-size: .71rem; }
.focus-gear {
  position: absolute;
  top: calc(50% + 58px);
  left: 50%;
  transform: translateX(-50%);
  max-width: 75vw;
  width: max-content;
  text-align: center;
  padding: 4px 7px;
  color: #f1dcab;
  background: #152023ea;
  border-radius: 4px;
  font-size: .73rem;
  pointer-events: none;
}
.boss-status {
  position: absolute;
  z-index: 2;
  top: max(27px,var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(39vw,400px);
  min-width: 160px;
  padding: 7px 11px;
  background: #141a20e9;
  border: 1px solid #dcaa8580;
  border-radius: 6px;
  pointer-events: none;
}
.boss-status > div:first-child { display:flex; align-items:baseline; justify-content:space-between; gap:5px; }
.boss-status strong { color: #f8d8b2; font-size: clamp(.74rem,1.6vw,.95rem); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.boss-status span { color:#f4c098; font-size:.71rem; font-variant-numeric:tabular-nums; white-space:nowrap; }
.boss-bar { height: 5px; background:#3c2a2b; margin-top: 5px; border-radius: 8px; overflow: hidden; }
.boss-bar i { display:block; height:100%; width:var(--boss-hp,100%); background:linear-gradient(90deg,#a74441,#f49a65); }
.summit-signs { position:absolute; inset:0; z-index:1; pointer-events:none; }
.summit-signs > div {
  position:absolute;
  transform:translate(-50%,-50%) scale(var(--sign-size,1));
  border:1px solid #c0975b;
  border-radius:3px;
  padding:4px 8px;
  background:#49362af2;
  text-align:center;
  text-shadow:0 1px 2px #1b140e;
  color:#ffe4a2;
  letter-spacing:.06em;
  white-space:nowrap;
}
.summit-signs > div strong,.summit-signs > div span { display:block; font-size:.69rem; line-height:1.25; }
.summit-signs > div span { font-size:.53rem; }
@media (max-width: 650px) and (orientation: portrait) {
  .menu-main .spawn-select { margin-top:10px; }
  .opening h1 { line-height:.94; }
  .pause-panel { max-height: calc(calc(100 * var(--viewport-unit)) - 36px); }
  .pause-panel .panel-heading { margin-bottom:13px; }
  .pause-actions > button { min-height: 47px; }
}
@media (max-height: 455px) and (orientation: landscape) {
  .menu-main .spawn-select { margin-top: 7px; }
  .pause-panel { padding: 11px 14px; }
  .pause-actions > button { min-height: 38px; }
  .pause-actions #resume { min-height: 40px; }
  body[data-input="touch"] .boss-status { top:calc(var(--safe-top) + 44px); width: min(38vw,270px); padding:5px 7px; }
  body[data-input="touch"] .focus-gear { top:calc(50% + 44px); }
}

.atlas { width: min(1010px,calc(100% - 28px)); max-height: calc(calc(100 * var(--viewport-unit)) - 24px); }
.atlas .panel-heading { margin-bottom: 10px; }
.atlas-content { grid-template-columns: minmax(0,1fr) minmax(210px,278px); align-items: start; gap: 14px; }
.atlas-stage { position: relative; width: min(100%,calc(calc(100 * var(--viewport-unit)) - 134px)); justify-self: center; }
#atlas { display: block; width: 100%; max-width: none; cursor: grab; margin-inline: auto; border-radius: 7px; }
#atlas[data-dragging="true"] { cursor: grabbing; }
.atlas-navigation { position: absolute; left: 8px; top: 8px; display: grid; gap: 5px; }
.atlas-navigation button { width: 36px; height: 36px; font-size: 1.2rem; background: #202b2af0; }
.atlas-options { gap: 9px; }
.atlas-options label { gap: 4px; grid-template-columns: 1fr; font-size: .77rem; color: #e5ddc7; }
.atlas-options label > :is(input,select) { min-height: 36px; font-size: 16px; }
.atlas-toggles { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.atlas-options .atlas-toggles label { display: flex; gap: 5px; align-items: center; }
.atlas-options .atlas-toggles input[type="checkbox"] { width: 16px; min-height: 16px; accent-color: var(--gold); padding: 0; }
.atlas-site { display: grid; gap: 4px; border-radius: 6px; background: #151c1c; border: 1px solid #e8c98735; padding: 8px 10px; }
.atlas-site small { color: #d1cbb8; font-size: .74rem; }
.atlas-site strong { font-size: .9rem; color: #fff0d0; }
#atlas-scale { display: block; margin-top: 5px; }
.map-tools { gap: 5px; }
.map-tools .secondary-button { padding: 3px 8px; min-height: 33px; font-size: .72rem; }
.book-tools { grid-template-columns: minmax(0,1.5fr) repeat(2,minmax(0,1fr)); }
.companion-hud {
  position: absolute; left: var(--safe-left); top: calc(var(--safe-top) + 49px); z-index: 6; width: max-content;
  color: #f0ead7; font-size: .76rem;
}
#companion-toggle { display: inline-flex; gap: 6px; align-items: center; border-radius: 5px; padding: 4px 8px; min-height: 33px; }
#companion-count { color: #a6d9bd; font-variant-numeric: tabular-nums; }
#companion-controls {
  margin-top: 6px; padding: 9px; width: min(271px,60vw); display: grid; gap: 7px;
  max-height: min(calc(54 * var(--viewport-unit)),270px); overflow: auto; background: #1b2220f5; border-radius: 6px;
}
#companion-controls label { display: grid; gap: 3px; }
#companion-list { width: 100%; min-height: 33px; background: #141b1b; border: 1px solid var(--edge); border-radius: 4px; color: inherit; font: 16px system-ui; }
#companion-info { color: #c0d5c7; }
.companion-orders { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.companion-orders button { padding: 4px 6px; min-height: 32px; font-size: .73rem; }
@media (max-height: 480px) and (orientation: landscape) {
  .atlas-stage { width: min(100%,calc(calc(100 * var(--viewport-unit)) - 86px)); }
  .atlas-content { grid-template-columns: minmax(0,1fr) minmax(175px,245px); gap: 8px; }
  .atlas-options { max-height: calc(calc(100 * var(--viewport-unit)) - 84px); overflow-y: auto; padding-inline: 3px; }
  .companion-hud { top: calc(var(--safe-top) + 39px); }
}
@media (max-width: 570px) and (orientation: portrait) {
  .atlas-content { grid-template-columns: 1fr; }
  .atlas-stage { width: min(100%,calc(51 * var(--viewport-unit))); }
  .book-tools { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .book-tools label:first-child { grid-column: 1/-1; }
}

/* Painted world and illustrated HUD */
:root {
  --ink: #2a1e2b;
  --gold: #f2c372;
  --ivory: #fff1d2;
  --edge: #d7a37168;
  --soft-text: #e1c6ae;
  --health: #ec7566;
}
.view-shade {
  background: radial-gradient(ellipse at 52% 43%,transparent 62%,#16233631 100%),
    linear-gradient(0deg,#13203252,transparent 25%),linear-gradient(180deg,#15233424,transparent 16%);
}
body[data-screen="title"] .menu-shade {
  background: linear-gradient(90deg,#322031f7,#342234ee 26%,#2f2234a3 51%,#23454c30 89%),
    linear-gradient(0deg,#30233683,transparent 46%);
}
body[data-mode="overlay"] .menu-shade, body[data-mode="paused"] .menu-shade { background: #281e31b7; }
.opening h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 900;
  letter-spacing: -.080em;
  line-height: .84;
  text-shadow: 2px 3px 0 #271b2b, 4px 6px 0 #211825a0;
}
.opening h1 em { color: #ffc66d; font-style: italic; letter-spacing: -.062em; }
.fighter { border-bottom-color: #e7b08680; }
.fighter-plane {
  inset: 9% 9% 13%;
  clip-path: none;
  border: 2px solid #e1ad72;
  border-radius: 47% 53% 46% 54% / 52% 46% 54% 48%;
  background: radial-gradient(ellipse at 42% 31%,#f8cb83 0 7%,#c97863 56%,#765060 100%);
  box-shadow: 0 0 0 7px #2b2338b5, 0 0 0 9px #d8a77d48;
  opacity: .94;
  transform: rotate(-9deg);
  overflow: hidden;
}
.fighter-plane::after {
  background: repeating-radial-gradient(ellipse at 42% 31%,#ffe6b81c 0 2px,transparent 3px 32px),
    repeating-linear-gradient(120deg,transparent 0 5px,#5035481f 6px 7px);
}
#fighter-model { filter: drop-shadow(9px 12px 0 #542e4b67); }
.fighter figcaption {
  border: 2px solid #2a1e2b;
  border-radius: 9px 9px 4px 9px;
  background: #f6d6a0;
  color: #3d293d;
  font-family: Georgia, serif;
  box-shadow: 3px 3px 0 #2d2138;
}
.skin-card { background: #503748; border: 2px solid #2e2033; border-radius: 8px; box-shadow: 1px 2px 0 #231827; }
.skin-card:nth-child(2) { background: #695044; }
.skin-card:nth-child(3) { background: #504265; }
.skin-card:nth-child(4) { background: #3c554b; }
.skin-card:nth-child(5) { background: #345267; }
.skin-card[aria-pressed="true"] { background: #b56b63; box-shadow: 1px 2px 0 #25182a, inset 0 0 0 1px #f5cca4; }
.skin-card span { background: #312536b8; color: #ffedce; }
.skin-card[aria-pressed="true"] span { background: #f3c681; color: #3b2534; }
.menu-label { color: #f4d9b2; }

:is(.panel,.icon-button,.locale-switch,.health,.map,.companion-hud,.flight-status,.boss-status,.focus-gear) {
  background: #382838f0;
  border: 2px solid #765263;
  box-shadow: 0 3px 0 #241c29cd;
}
.panel {
  background: linear-gradient(145deg,#503446,#342735 54%,#2f2535);
  border-color: #ad796d;
  border-radius: 15px;
  box-shadow: 0 5px 0 #211725,0 24px 64px #181221b8,inset 0 0 0 3px #2b203066;
}
.panel h2 { font-family: Georgia,serif; letter-spacing: -.031em; color: #ffe8bf; }
.panel :is(input:not([type="radio"]),select), .game-modes label>span, .book-spell, .goal, .assign,
.invite-row,.room-threats,.equipment-card,.atlas-site {
  border-color: #a6787d85;
  background-color: #2d2234;
}
.primary-button,.secondary-button {
  border: 2px solid #281d2b;
  border-radius: 8px;
  box-shadow: 0 3px 0 #251b28;
  font-weight: 740;
}
.primary-button { background: #f3c271; color: #3a2633; }
.primary-button:hover:enabled { background: #ffda90; border-color: #724655; }
.secondary-button { background: #5b4054; color: #fff0cc; border-color: #855664; }
.secondary-button:hover:enabled,.icon-button:hover:enabled { background: #745568; border-color: #d5a477; }
.control-row { border-radius: 8px; }
.world-label { text-shadow: 0 2px 2px #261b31; }
.world-mark { background: #633e4e; border-color: #d3a368; }
#minimap, #atlas { border: 2px solid #af8166; border-radius: 5px; }
.health-bar { height: 7px; border: 1px solid #ac7674; background: #231a2a; }
.health-bar > span { background: linear-gradient(#ffc097 0 28%,#e8735d 34% 78%,#bc524f 84%); }
.spell,.book-button {
  border: 2px solid #826678;
  border-radius: 10px;
  background: radial-gradient(ellipse at 50% 30%,var(--wash,#b5716133),transparent 79%),#3b2b40f2;
  box-shadow: 1px 3px 0 #291f2d;
}
.spell[aria-pressed="true"] {
  background: radial-gradient(ellipse at 50% 30%,var(--wash),transparent 79%),#5e4155;
  box-shadow: 1px 3px 0 #291f2d, inset 0 0 0 2px #291f2d4d;
}
.spell .cooldown { background: #261d3099; }
.reticle { color: #fff2cc; filter: drop-shadow(0 0 1px #2a1e2b) drop-shadow(0 1px 1px #2a1e2b); }
.reticle :is(i,b) { outline: 1px solid #301f36ab; border-radius: 50%; }
#shield,#cast,#jump { box-shadow: 0 3px 0 #2b2032, inset 0 0 0 2px #f0c98c2e; }

.gear {
  width: min(920px,calc(100% - 28px));
  padding: clamp(12px,2.3vw,27px);
}
.gear .panel-heading { margin-bottom: 13px; }
.gear .panel-heading p { margin: 7px 0 0; color: #e2c8ba; font-size: .82rem; line-height: 1.4; }
.gear-layout { display: grid; grid-template-columns: minmax(146px,.43fr) minmax(0,1fr); gap: clamp(10px,2vw,20px); }
.gear-preview {
  display: grid;
  min-width: 0;
  align-content: center;
  justify-items: center;
  margin: 0;
  padding: 8px;
  border: 1px solid #a87366;
  border-radius: 12px;
  background: radial-gradient(ellipse at 48% 39%,#7a5361 0%,#593e54 46%,#382b42 81%);
}
.gear-preview canvas { display: block; width: min(100%,225px); max-height: min(calc(34 * var(--viewport-unit)),282px); object-fit: contain; }
.gear-preview figcaption { display: grid; gap: 4px; padding: 4px 0; text-align: center; font-size: .75rem; }
#turn-gear { min-height: 34px; padding: 4px 8px; font-size: .72rem; }
.gear-stats { display: grid; gap: 3px; padding: 4px; color: #f6d5a1; }
.gear-browser { display: grid; align-content: start; gap: 8px; min-width: 0; }
.gear-tabs { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
.gear-tabs button {
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  place-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 41px;
  padding: 3px 7px;
  border: 1px solid #926274;
  border-radius: 7px;
  background: #422e43;
  color: #ffe5be;
  text-align: left;
  font-size: .76rem;
  font-weight: 740;
}
.gear-tabs button span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.gear-tabs button small { min-width: 1ch; color: #e9c195; font-size: .65rem; }
.gear-tabs button:hover { border-color: #d19f87; background: #5d4058; }
.gear-tabs button[aria-pressed="true"] { border-color: #f4c886; background: #664355; box-shadow: inset 0 -2px #e3ad7b; }
.gear-tabs .gear-icon { display: block; width: 23px; height: 23px; }
.gear-list-heading { display: flex; min-height: 27px; justify-content: space-between; align-items: center; gap: 8px; }
#gear-count { color: #e5c8ad; font-size: .74rem; font-variant-numeric: tabular-nums; }
#gear-remove { min-height: 30px; padding: 3px 10px; font-size: .72rem; }
#gear-empty { margin: 0; color: #e3c8b2; font-size: .84rem; line-height: 1.46; padding: 11px 12px; border: 1px solid #906476; border-radius: 8px; }
.gear-list { display: grid; max-height: min(calc(47 * var(--viewport-unit)),390px); gap: 6px; overflow-y: auto; padding-inline: 1px 4px; scrollbar-color: #a87883 #352539; }
.equipment-card {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 57px;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid #876476;
  border-radius: 8px;
  background: #33253a;
  text-align: left;
}
.equipment-card:hover,.equipment-card[aria-pressed="true"] { background: #563d50; border-color: #e5ac80; }
.equipment-card .gear-icon {
  flex: 0 0 39px; width: 39px; height: 39px; background: #473245;
  border-radius: 8px; border: 1px solid color-mix(in srgb,var(--gear-accent) 62%,#6f435b);
}
.equipment-card span { display: grid; gap: 2px; min-width: 0; }
.equipment-card strong { font-size: .83rem; }
.equipment-card small { color: #ddc9bc; font-size: .69rem; }
.equipment-card .gear-comparison { color: #eaa889; }
.equipment-card .gear-comparison[data-better="true"] { color: #a9dbab; }
.equipment-card :is(strong,small) { overflow-wrap: anywhere; }
.equipment-card .gear-rarity { color: #eec194; }
.equipment-card .gear-rarity:empty { display: none; }
.equipment-card .equipped-tag { flex: 0 0 auto; margin-left: auto; color: #f9cc8d; }
.ward-status { display: flex; width: fit-content; align-items: center; gap: 5px; margin-top: 6px; color: #f1ccdb; font-size: .68rem; }
.ward-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #d3a8c3; }
.ward-status[data-ready="true"]::before { background: #b8ebae; box-shadow: 0 0 5px #a1e6a0; }

@media (min-width: 660px) and (max-height: 480px) {
  .gear .panel-heading { margin-bottom: 8px; }
  .gear .panel-heading p { margin-top: 4px; }
  .gear-tabs { grid-template-columns: repeat(6,minmax(0,1fr)); }
  .gear-tabs button { grid-template-columns: minmax(0,1fr) auto; justify-items: start; gap: 1px 4px; padding: 3px 5px; text-align: center; }
  .gear-tabs button canvas { grid-column: span 2; justify-self: center; }
  .gear-list { max-height: calc(42 * var(--viewport-unit)); }
}
@media (max-width: 575px) and (orientation: portrait) {
  .gear-layout { grid-template-columns: minmax(0,1fr); }
  .gear-preview { grid-template-columns: minmax(75px,.48fr) minmax(0,1fr); align-items: center; }
  .gear-preview canvas { max-height: calc(19 * var(--viewport-unit)); }
  .gear-tabs button { min-height: 44px; }
  .gear-list { max-height: calc(37 * var(--viewport-unit)); }
}

/* The Right to Fire */
#story-start {
  grid-column: 1 / -1;
  background: #f4ce88;
  border-color: #421f2b;
  color: #342335;
  box-shadow: 0 3px 0 #683f49;
}
#story-start:hover { background: #ffe6b2; }
#story-start::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  background: #a6584b;
  transform: rotate(45deg);
}
.story-panel {
  width: min(960px,calc(100% - 34px));
  max-height: min(calc(88 * var(--viewport-unit)),740px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: clamp(14px,2.4vw,28px);
  background: radial-gradient(ellipse at 11% -20%,#664952 0,transparent 63%),#2d2431;
  border-color: #b88572;
}
.story-heading { margin-bottom: 14px; }
.story-heading #story-kicker { color: #f4c58c; font-size: .67rem; }
.story-panel h2 { font-size: clamp(1.52rem,4vw,2.75rem); }
.story-panel h3 { color: #ffe5bb; font: 700 clamp(1.06rem,2.8vw,1.4rem) Georgia,serif; margin: 0 0 6px; }
.story-panel p { color: #ece0ce; line-height: 1.52; margin: 0 0 10px; }
.story-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1px 6px 4px 0;
  scrollbar-width: thin;
  scrollbar-color: #a6776e #372a39;
}
.story-footer { display: flex; gap: 12px; justify-content: space-between; padding-top: 9px; margin-top: 9px; border-top: 1px solid #b885724f; color: #f3c990; font-size: .77rem; }
#story-result[data-error="true"] { color: #ffc1a9; }
.story-dialogue,.story-service { display: grid; grid-template-columns: minmax(110px,28%) minmax(0,1fr); align-items: start; gap: clamp(12px,3vw,29px); }
.story-speaker {
  margin: 0;
  padding: 7px 11px 11px;
  background: radial-gradient(ellipse at 50% 50%,#674b5b,#362c3a 69%);
  border: 1px solid #b3897168;
  border-radius: 9px;
  text-align: center;
}
.story-speaker canvas { display: block; width: 100%; max-width: 198px; height: auto; margin-inline: auto; }
.story-speaker figcaption { font: 700 1.05rem Georgia,serif; color: #ffe3ac; }
.story-speaker figcaption > span { display: block; margin-top: 8px; font: .78rem/1.45 system-ui,sans-serif; color: #e6cfbe; }
.story-words { min-width: 0; padding-block: 9px; }
.story-pages { color: #efbd8c; font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.story-words .story-line { font: 1.23rem/1.58 Georgia,serif; min-height: 84px; margin-block: 9px 16px; }
.story-words .story-last-line { color: #ddc6b9; margin-bottom: 13px; }
.story-choices,.story-tabs,.story-enchant-list { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 9px; }
.story-choices:has(button + button) { align-items: flex-start; }
.story-panel :is(.primary-button,.secondary-button) { min-height: 35px; padding: 6px 9px; font-size: .83rem; text-align: left; line-height: 1.22; }
.story-panel :is(.primary-button,.secondary-button):disabled { opacity: .53; cursor: default; }
.story-tabs button[aria-pressed="true"] { color: #231824; background: #f3ce99; border-color: #e7b877; }
.story-bench { min-width: 0; }
.story-bench:only-child { grid-column: 1 / -1; }
.story-stock { display: flex; flex-direction: column; gap: 5px; }
.story-stock-row { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; align-items: center; gap: 8px; min-height: 50px; background: #211c2a; border: 1px solid #9a6e7c61; border-radius: 7px; padding: 4px 7px; }
.story-stock-row canvas { width: 42px; height: 42px; }
.story-stock-row strong,.story-city strong { display: block; color: #ffebcc; font-size: .88rem; }
.story-stock-row small,.story-city small,.story-select small { display: block; color: #dac8be; line-height: 1.35; font-size: .72rem; }
.story-select { display: grid; gap: 5px; margin-block: 12px; }
.story-enchant-list { margin-block: 15px; }
.story-enchant-list :is(h3,p) { width: 100%; }
.story-panel .story-stock-row + button { margin-top: 10px; }
.story-journal-card { padding: 10px 13px; border: 1px solid #a4777380; border-radius: 8px; background: #262030; margin-bottom: 8px; }
.story-journal-card button { margin: 1px 5px 2px 0; }
.story-journal-card progress { width: min(100%,260px); height: 5px; margin: 5px 0 9px; accent-color: #d7ab72; }
.story-city-list { margin-block: 14px; }
.story-city { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 5px; margin-bottom: 4px; padding: 7px 8px 7px 10px; border-left: 3px solid var(--city); background: #211b2c; border-radius: 4px; }
.story-city small { margin-top: 2px; }
.story-history { color: #f2cfa8; padding: 8px 0; }
.story-history li { margin-bottom: 6px; }
.story-history li span { display: block; color: #d9c3b8; font-size: .82rem; }
.book-spell:disabled .book-requirement { color: #f2b47f; }
.book-spell:disabled { opacity: .66; cursor: default; }

.story-hud { position: absolute; z-index: 3; left: var(--safe-left); top: calc(var(--safe-top) + 126px); display: grid; justify-items: start; gap: 5px; max-width: min(230px,30vw); pointer-events: none; }
.story-hud button { pointer-events: auto; min-height: 32px; border-color: #ab7e69; font-size: .72rem; line-height: 1.17; padding: 5px 8px; }
.story-objective { display: grid; text-align: left; gap: 2px; background: #2b2029eb; color: #ffe9bd; }
.story-objective span { color: #ebc38b; font-size: .65rem; }
.story-objective small { color: #e6c7a4; }
#story-gift { background: #302338de; color: #edc9c8; }
#story-gift:disabled { opacity: .6; }
#story-markers { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
#story-markers span {
  position: absolute;
  transform: translate(-50%,-100%);
  max-width: 68vw;
  background: #232329dc;
  border: 1px solid #e6bc8780;
  padding: 3px 6px;
  white-space: nowrap;
  border-radius: 3px;
  color: #edddb5;
  font-size: .68rem;
}
#story-markers span[data-main="true"] { color: #fff0c7; border-color: #f0bf75; }
body[data-screen="story"] :is(.map,.spell-dock,.context-actions,.aim-ui),
body[data-screen="cinema"] :is(.map,.spell-dock,.hud-header,.crosshair,.context-actions,.view-shade,.menu-shade) { display: none; }
.cinema { position: absolute; z-index: 7; inset: 0; color: #ffedca; pointer-events: none; }
.cinema-top,.cinema-bottom { position: absolute; inset-inline: 0; padding-inline: var(--safe-left) var(--safe-right); background: #211824; }
.cinema-top { top: 0; min-height: clamp(44px,calc(9 * var(--viewport-unit)),90px); padding-top: max(5px,env(safe-area-inset-top)); display: flex; align-items: center; justify-content: space-between; gap: 6px; font: 700 clamp(1rem,3vw,1.5rem) Georgia,serif; }
#cinema-skip { pointer-events: auto; padding: 6px 10px; min-height: 35px; color: #f7daba; background: #423143; border: 1px solid #a67471; border-radius: 4px; font: .82rem system-ui,sans-serif; }
.cinema-bottom { bottom: 0; text-align: center; min-height: clamp(54px,calc(12 * var(--viewport-unit)),104px); padding-top: 8px; padding-bottom: max(6px,env(safe-area-inset-bottom)); }
.cinema-bottom p { margin: 0 auto; max-width: 63ch; font: clamp(.94rem,2.8vw,1.25rem)/1.26 Georgia,serif; }
#cinema-progress { position: absolute; inset: auto 0 0; height: 3px; transform-origin: left; transform: scaleX(var(--progress,0)); background: #d6a878; }

@media (max-height: 480px) and (orientation: landscape) {
  .story-panel { max-height: calc(calc(100 * var(--viewport-unit)) - 22px); padding-block: 9px; }
  .story-heading { margin-bottom: 7px; }
  .story-panel .panel-kicker { margin-bottom: 3px; }
  .story-dialogue,.story-service { grid-template-columns: minmax(98px,20%) minmax(0,1fr); }
  .story-speaker canvas { max-height: min(calc(36 * var(--viewport-unit)),148px); object-fit: contain; }
  .story-words { padding: 3px 0; }
  .story-words .story-line { min-height: 42px; font-size: 1.01rem; margin-block: 5px 8px; }
  .story-hud { max-width: min(181px,29vw); top: calc(var(--safe-top) + 62px); }
  .story-hud button { padding: 3px 6px; min-height: 29px; }
}
@media (max-width: 450px) and (orientation: portrait) {
  .story-dialogue,.story-service { grid-template-columns: minmax(0,1fr); }
  .story-speaker { display: grid; grid-template-columns: 77px 1fr; gap: 4px; padding: 3px 8px; align-items: center; text-align: left; }
  .story-speaker canvas { max-height: 76px; object-fit: contain; }
  .story-words .story-line { min-height: 0; font-size: 1.05rem; }
  .story-hud { top: calc(var(--safe-top) + 103px); max-width: 46vw; }
}
