:root {
  color-scheme: dark;
  --paper: #0b1713;
  --panel: #14261f;
  --ink: #f5e8c9;
  --muted: #aebaa7;
  --pine: #0d1d17;
  --accent: #b88943;
  --accent-hover: #d0a258;
  --gold: #f0c46e;
  --line: #536252;
  --soft: #20372d;
  --danger: #d06b51;
  --water: #79aaa1;
  --serif: Georgia, 'Times New Roman', serif;
  --body: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-family: var(--body);
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; min-height: 100dvh; overflow-x: hidden; background: radial-gradient(circle at 18% 0%, #34503b55, transparent 34%), linear-gradient(145deg, #0a1511, #10241c 58%, #09130f); }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
button, input, canvas { outline-offset: 3px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
:where(h1, h2, h3, p, ul, ol) { margin: 0; }
.frame { width: min(1540px, calc(100% - 48px)); margin-inline: auto; }

.masthead { background: linear-gradient(90deg, #0a1712f5, #1b3328f5 50%, #0a1712f5); color: var(--ink); min-height: 54px; border-bottom: 1px solid #a67d42; box-shadow: 0 2px 0 #07100c, inset 0 -1px #e0b86933; }
.masthead-inner { min-height: 53px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.masthead-tools { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 11px; font: bold clamp(1rem, 2vw, 1.28rem)/1.1 var(--serif); letter-spacing: .04em; text-transform: uppercase; color: #f7dfaa; }
.brand-mark { width: 22px; height: 22px; display: inline-grid; place-items: center; border: 1px solid var(--gold); transform: rotate(45deg) scale(.82); background: #1e3329; box-shadow: inset 0 0 0 2px #07110d; }
.brand-mark::before { content: ''; width: 12px; height: 14px; transform: rotate(-45deg); background: var(--gold); clip-path: polygon(50% 0, 90% 44%, 70% 44%, 100% 79%, 59% 79%, 59% 100%, 40% 100%, 40% 79%, 0 79%, 29% 44%, 10% 44%); }
.network { display: inline-flex; align-items: center; gap: 8px; color: #d8dfcf; font-size: .76rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #ddb776; box-shadow: 0 0 0 2px #0b1713, 0 0 10px #e9bd6d88; }
.status-dot.online { background: #9fcf8a; box-shadow: 0 0 0 2px #0b1713, 0 0 10px #9fcf8a88; }

main.frame { padding-block: 18px 24px; }
.introduction { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 13px; }
h1 { font: 500 clamp(2rem, 4vw, 3.7rem)/.98 var(--serif); letter-spacing: -.035em; color: #f5e5bd; text-shadow: 0 2px 0 #07110d; }
.introduction p { margin-top: 7px; max-width: 760px; color: var(--muted); line-height: 1.45; font-size: .9rem; }
button { transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease; }
.secondary { min-height: 44px; background: #172b23; color: var(--ink); padding: 9px 15px; border: 1px solid #8f754a; border-radius: 4px; font-weight: 700; white-space: nowrap; box-shadow: inset 0 0 0 1px #ffffff0b; }
.secondary:hover, .quiet:hover { background: #294237; }
.secondary:active, .quiet:active { background: #3a513f; }
.invite { display: inline-flex; align-items: center; gap: 8px; }
.link-icon { position: relative; width: 16px; height: 14px; transform: rotate(-35deg); }
.link-icon::before, .link-icon::after { position: absolute; top: 4px; width: 8px; height: 5px; border: 1.5px solid currentColor; border-radius: 9px; content: ''; }
.link-icon::before { left: 0; } .link-icon::after { right: 0; }
.invite-result { background: #13251e; border: 1px solid #6d785f; padding: 10px 14px; margin: -4px 0 12px; border-radius: 4px; max-width: 420px; }

.world { min-width: 0; }
.map-frame { border: 1px solid #8a7046; border-radius: 5px; padding: 5px; background: linear-gradient(135deg, #1e3329, #0b1813); box-shadow: 0 0 0 1px #07100c, 0 12px 34px #020604aa, inset 0 0 0 1px #d7ad6133; }
.map-view { position: relative; background: #527858; border: 1px solid #c7a35f; overflow: hidden; border-radius: 2px; box-shadow: inset 0 0 0 1px #07110d, inset 0 0 42px #06100ccc; }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 34 / 20; image-rendering: pixelated; background: #527858; }
canvas:focus-visible { outline: 3px solid var(--gold); outline-offset: -4px; }
.map-heading { position: absolute; display: flex; align-items: center; gap: 7px; top: 9px; left: 9px; color: #fff0c8; background: linear-gradient(180deg, #14261ff5, #0a1712f5); padding: 7px 10px; border: 1px solid #b38b4e; border-radius: 3px; font: 700 .86rem/1.1 var(--serif); letter-spacing: .025em; pointer-events: none; box-shadow: 0 2px 0 #050b08aa, inset 0 0 0 1px #ffffff0d; }
.diamond { width: 6px; height: 6px; background: var(--gold); transform: rotate(45deg); box-shadow: 0 0 8px #f0c46e99; }
.compass { position: absolute; top: 9px; right: 9px; display: grid; justify-items: center; place-content: center; width: 39px; height: 45px; color: #faeacd; background: linear-gradient(180deg, #172c23ef, #0b1713ef); border: 1px solid #a67d42; border-radius: 4px; font: 700 10px/1 var(--serif); gap: 2px; pointer-events: none; box-shadow: 0 2px 0 #050b08aa, inset 0 0 0 1px #ffffff0d; }
.compass-needle { width: 13px; height: 18px; background: var(--gold); clip-path: polygon(50% 0,100% 78%,50% 60%,0 78%); filter: drop-shadow(0 0 4px #f0c46e88); }
.feedback { position: absolute; max-width: min(420px, calc(100% - 22px)); bottom: 10px; left: 50%; transform: translateX(-50%); background: linear-gradient(180deg, #172d25f8, #0a1712fa); border: 1px solid #c49b58; border-radius: 4px; padding: 8px 13px; color: #fff4d9; font-size: .85rem; line-height: 1.4; text-align: center; pointer-events: none; width: max-content; box-shadow: 0 2px 0 #050b08aa, 0 0 18px #f0c46e22; }
.view-tools { position: absolute; top: 9px; right: 9px; display: flex; gap: 5px; z-index: 4; }
.map-overview, .journal-toggle { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 3px; border: 1px solid #a67d42; color: #fff0c8; background: linear-gradient(180deg, #1b3328f5, #0c1b15f5); font: 700 .78rem/1 var(--body); box-shadow: 0 2px 0 #050b08aa, inset 0 0 0 1px #ffffff0d; }
.map-overview:hover, .journal-toggle:hover, .hud-actions button:hover { background: #315444; }
.map-overview[aria-pressed="true"] { background: var(--gold); color: #17251d; border-color: #ffe0a0; }
.journal-toggle[aria-expanded="true"] { background: #8f6939; color: #fff4d9; }
.map-overview:focus-visible, .journal-toggle:focus-visible, .hud-actions button:focus-visible { outline-color: var(--gold); }
.alert-stack { position: absolute; top: 58px; right: 9px; display: grid; justify-items: end; gap: 6px; width: min(260px, calc(100% - 18px)); pointer-events: none; z-index: 3; }
.alert-stack .alert, .alert-stack .world-event { margin: 0; background: linear-gradient(180deg, #172d25f5, #0b1713f7); border: 1px solid #a67d42;  border-radius: 3px; padding: 7px 9px; color: #fff0c8; font-size: .75rem; line-height: 1.3; box-shadow: 0 2px 0 #050b08aa; }
.alert-stack .alert-danger { border-color: var(--danger); color: #ffe0cf; }
.alert-stack .watchers-met, .alert-stack .travel-hint { border-color: var(--water); color: #d9f1ea; }
.world-hud { position: absolute; inset: auto 9px 8px; display: flex; justify-content: space-between; gap: 6px; align-items: end; pointer-events: none; z-index: 3; }
.hud-vitals, .hud-actions button { border: 1px solid #a67d42; border-radius: 3px; color: #fff0c8; background: linear-gradient(180deg, #172d25f5, #0b1713f7); font: 700 .78rem/1.2 var(--body); box-shadow: 0 2px 0 #050b08aa, inset 0 0 0 1px #ffffff0d; }
.hud-vitals { display: grid; gap: 3px; width: min(176px, 34%); min-height: 44px; padding: 6px 8px; align-content: center; }
.hud-vitals div { display: flex; justify-content: space-between; flex-wrap: wrap; column-gap: 4px; }
.hud-vitals strong { color: var(--gold); font-variant-numeric: tabular-nums; }
.hud-vitals .song-status { color: #ffe1aa; font-size: .7rem; line-height: 1.22; }
.hud-vitals .spirit-status { color: #c1f0e7; font-size: .72rem; line-height: 1.25; overflow-wrap: anywhere; }
.hud-vitals .spirit-status.in-danger { color: #ffd099; }
.hud-vitals meter { width: 100%; height: 9px; display: block; }
.hud-vitals meter::-webkit-meter-bar { background: #263d33; border-color: #7a8064; border-radius: 2px; }
.hud-vitals meter::-webkit-meter-optimum-value, .hud-vitals meter::-webkit-meter-suboptimum-value { background: linear-gradient(90deg, #b95f4e, #e0a15d); }
.hud-vitals meter::-moz-meter-bar { background: #cb8c73; }
.hud-actions { display: flex; gap: 6px; pointer-events: auto; }
.hud-actions button { min-height: 44px; display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; }
.hud-actions button:active { background: var(--gold); color: #17251d; }
.map-view.is-playing .feedback { bottom: 60px; }
.map-view.in-vault .feedback { top: 61px; bottom: auto; }
.map-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; padding: 4px 7px 0; color: #e9dfc2; font-size: .78rem; }
.map-location { display: flex; gap: 8px; align-items: center; font-weight: 650; }
.pin { position: relative; width: 8px; height: 8px; border: 1px solid var(--gold); border-radius: 50% 50% 50% 0; transform: rotate(-45deg); }
.pin::after { content: ''; width: 2px; height: 2px; position: absolute; left: 2px; top: 2px; background: var(--gold); border-radius: 50%; }
.coordinates { color: #e4d8b9; font-variant-numeric: tabular-nums; }

.sidebar { display: grid; gap: 12px; position: sticky; top: 14px; }
body:not(.is-playing) .panel { background: linear-gradient(180deg, #172b23fa, #0c1914fa); backdrop-filter: blur(2px); }
.panel { background: linear-gradient(180deg, #172b23f5, #102019f5); padding: 14px; border: 1px solid #6f765d; border-radius: 5px; box-shadow: 0 0 0 1px #07100c, 0 8px 24px #02060477, inset 0 0 0 1px #ffffff0a; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
h2 { font: 600 1.18rem/1.1 var(--serif); letter-spacing: -.015em; color: #f4dfad; }
.count { white-space: nowrap; padding: 4px 7px; color: #ffe1a0; background: #263b31; border: 1px solid #8f754a; border-radius: 3px; font-weight: 700; font-size: .74rem; font-variant-numeric: tabular-nums; }
.roster { padding: 0; list-style: none; display: grid; gap: 5px; margin-bottom: 12px; }
.roster-row:has(.portrait-empty), .roster:not(:has(.portrait:not(.portrait-empty))) { display: none; }
.roster-row { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 9px; align-items: center; background: #0d1b16a8; border: 1px solid #4e5f50; border-radius: 4px; padding: 6px 7px; min-height: 45px; }
.roster-row strong, .roster-row small { display: block; overflow-wrap: anywhere; }
.roster-row strong { font-size: .82rem; line-height: 1.22; color: #f5e8c9; }
.roster-row small { font-size: .72rem; color: var(--muted); line-height: 1.32; margin-top: 2px; }
.portrait { width: 31px; height: 31px; border-radius: 2px; background: #d7ad61; display: grid; place-items: center; box-shadow: inset 0 0 0 1px #07100c, 0 0 0 1px #ffffff18; }
.portrait::before { content: ''; width: 18px; height: 22px; background: linear-gradient(to bottom, #623b32 16%, #ac614a 16% 30%, #f2d299 30% 53%, #4b4030 53% 61%, #994932 61% 87%, #4b4030 87%); clip-path: polygon(16% 0, 83% 0, 83% 12%, 100% 12%, 100% 37%, 83% 37%, 83% 53%, 100% 53%, 100% 85%, 76% 85%, 76% 100%, 55% 100%, 55% 85%, 44% 85%, 44% 100%, 23% 100%, 23% 85%, 0 85%, 0 53%, 16% 53%, 16% 37%, 0 37%, 0 12%, 16% 12%); }
.portrait-1 { background: #bad9d0; }
.portrait-1::before { background: linear-gradient(to bottom, #2e4a57 16%, #468589 16% 30%, #f2d299 30% 53%, #4b4030 53% 61%, #346b73 61% 87%, #4b4030 87%); }
.portrait-2 { background: #e0d1a2; }
.portrait-2::before { background: linear-gradient(to bottom, #484c30 16%, #777a43 16% 30%, #f2d299 30% 53%, #4b4030 53% 61%, #5d6238 61% 87%, #4b4030 87%); }
.portrait-3 { background: #dcd1e1; }
.portrait-3::before { background: linear-gradient(to bottom, #4f3e59 16%, #786080 16% 30%, #f2d299 30% 53%, #4b4030 53% 61%, #66476b 61% 87%, #4b4030 87%); }
.portrait-empty { background: #26372d; border: 1px dashed #8a9278; box-shadow: none; }
.portrait-empty::before { width: 12px; height: 12px; background: #b5b99f; clip-path: polygon(42% 0,58% 0,58% 42%,100% 42%,100% 58%,58% 58%,58% 100%,42% 100%,42% 58%,0 58%,0 42%,42% 42%); }
label { display: block; margin-bottom: 5px; font-size: .76rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: #d9cda9; }
input, #player-class { width: 100%; min-height: 44px; padding: 7px 10px; background: #0b1713; color: var(--ink); border: 1px solid #8f754a; border-radius: 3px; box-shadow: inset 0 2px 6px #00000044; }
input::placeholder { color: #9aa794; }
.primary { width: 100%; color: #1b2118; background: linear-gradient(180deg, #f0c46e, #bd8a43); border: 1px solid #ffd88d; border-radius: 3px; min-height: 48px; padding: 8px 12px; margin-top: 10px; display: flex; justify-content: space-between; align-items: center; font-weight: 850; text-align: left; box-shadow: inset 0 1px #fff3c9aa, 0 2px 0 #4d351b; }
.primary:hover { background: linear-gradient(180deg, #ffd783, #ce9a4f); }
.primary:active { transform: translateY(1px); box-shadow: inset 0 1px #fff3c9aa, 0 1px 0 #4d351b; }
.primary:disabled { background: #66705e; border-color: #8a9278; color: #d8ddcf; box-shadow: none; }
.form-error { color: #ff9c82; font-size: .8rem; margin-top: 6px; }
.session { border-top: 1px solid #536252; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-top: 7px; font-size: .82rem; }
.quiet { background: none; border: 1px solid transparent; color: var(--ink); border-radius: 3px; min-height: 44px; padding: 5px 9px; font-weight: 700; }

.journal { border-top: 1px solid var(--accent); }
.journal-icon { width: 16px; height: 18px; border: 1.5px solid #d7ad61;  border-radius: 2px; background: #0b1713; }
.journal-icon::after { content: ''; display: block; border-block: 1px solid #d7ad61; width: 6px; height: 4px; margin: 4px auto 0; }
.journal h3 { font-size: .93rem; margin-bottom: 5px; line-height: 1.25; color: #fff0c8; }
.journal p { color: var(--muted); font-size: .82rem; line-height: 1.45; }
.objectives { padding: 0; list-style: none; display: grid; gap: 8px; margin-top: 10px; color: var(--muted); }
.objectives li { display: grid; grid-template-columns: 12px 1fr max-content; align-items: center; gap: 6px; font-size: .76rem; }
.objectives strong { color: #ffe1a0; font-variant-numeric: tabular-nums; }
.check { width: 10px; height: 10px; border: 1px solid #9aa794; border-radius: 50%; }
.check.done { background: var(--accent); border-color: #ffd88d; box-shadow: 0 0 8px #f0c46e66; }
.inventory { display: grid; gap: 4px; padding-top: 10px; margin-top: 12px; border-top: 1px solid #536252; font-size: .79rem; color: #fff0c8; }
.inventory span { color: var(--muted); }
.world-event { padding: 9px 10px; background: linear-gradient(180deg, #3a2b1ef5, #1d1712f5); border-color: #d06b51; border-radius: 3px; }
.titan-status { font-weight: 700; }
.player-level { color: var(--gold); }
.rescue-clock { color: #fff1ce; background: #8f3f32; border: 1px solid #e08a68; padding: 2px 7px; border-radius: 3px; font-weight: 800; font-variant-numeric: tabular-nums; }
.journal :is(.watchers-met, .travel-hint) { margin-top: 8px; font-size: .8rem; font-weight: 650; color: #bfe2d9; }
.world-event strong { display: block; color: #ffd0a1; font-size: .82rem; line-height: 1.35; margin-bottom: 3px; }

.controls { margin-top: 10px; padding: 9px 10px; border: 1px solid #4e5f50; border-radius: 4px; background: #0d1b16a8; }
.controls p, .controls p span { display: flex; align-items: center; }
.controls p { gap: 6px 13px; flex-wrap: wrap; color: var(--muted); font-size: .76rem; line-height: 1.35; }
.controls p span { gap: 3px; }
.controls p strong { color: #ffe1a0; letter-spacing: .04em; text-transform: uppercase; }
kbd { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding-inline: 3px; border: 1px solid #8f754a; border-bottom-width: 2px; border-radius: 2px; font: 800 .68rem/1 var(--body); color: #fff0c8; background: #1b3328; box-shadow: inset 0 0 0 1px #ffffff0d; }
.touch-controls { display: none; justify-content: flex-start; align-items: center; gap: 12px; margin-top: 9px; }
.dpad { display: grid; grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(2, 48px); gap: 5px; }
.dpad button:first-child { grid-column: 2; grid-row: 1; width: 48px; height: 48px; }
.dpad button[data-direction="west"] { grid-column: 1; grid-row: 2; }
.dpad button[data-direction="south"] { grid-column: 2; grid-row: 2; }
.dpad button[data-direction="east"] { grid-column: 3; grid-row: 2; }
.touch-controls button { min-width: 48px; min-height: 48px; background: linear-gradient(180deg, #1b3328, #0c1b15); color: #fff0c8; border: 1px solid #a67d42; border-radius: 4px; font-size: .9rem; font-weight: 800; box-shadow: inset 0 0 0 1px #ffffff0d, 0 2px 0 #050b08; }
.touch-controls button:active { background: var(--gold); color: #17251d; transform: translateY(1px); box-shadow: none; }
.dpad button { touch-action: none; font-size: 1.2rem; }

@media (max-width: 1030px) {
  .frame { width: calc(100% - 32px); }
}
@media (max-width: 760px) {
  .frame { width: calc(100% - 20px); }
  .masthead, .masthead-inner { min-height: 50px; }
  .brand { font-size: 1rem; gap: 7px; }
  .network { font-size: .7rem; }
  main.frame { padding-top: 12px; }
  .introduction { align-items: start; margin-bottom: 10px; }
  h1 { font-size: clamp(1.8rem, 9vw, 2.6rem); }
  .introduction p { margin-top: 5px; font-size: .8rem; }
  .invite { font-size: .75rem; padding-inline: 8px; gap: 4px; }
  .map-frame { padding: 3px; }
  .map-heading { top: 6px; left: 6px; padding: 5px 6px; font-size: .72rem; }
  .compass { top: 6px; right: 6px; width: 29px; height: 32px; font-size: 9px; }
  .compass-needle { height: 11px; width: 9px; }
  .view-tools { top: 6px; right: 6px; gap: 4px; }
  .map-overview, .journal-toggle { min-height: 44px; padding-inline: 7px; font-size: .72rem; }
  .alert-stack { top: 54px; right: 6px; width: min(230px, calc(100% - 12px)); }
  .world-hud { inset: auto 6px 6px; }
  .hud-vitals { width: min(158px, 42%); }
  .hud-vitals, .hud-actions button { font-size: .7rem; }
  .hud-actions button { padding-inline: 6px; }
  .map-view.is-playing .feedback { bottom: 56px; }
  .sidebar { position: static; grid-template-columns: 1fr; gap: 10px; }
  .touch-controls { display: flex; }
}
@media (pointer: coarse) { .touch-controls { display: flex; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }

.class-label { display: block; margin-top: 10px; }
#player-class { font-weight: 650; padding-right: 34px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, #f0c46e 50%), linear-gradient(135deg, #f0c46e 50%, transparent 50%); background-position: calc(100% - 17px) 19px, calc(100% - 12px) 19px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.class-description { margin: 6px 0 4px; font-size: .76rem; color: #c8d0bd; line-height: 1.35; }
.roster-row:has(.party-target) { display: block; padding: 0; }
.party-target { appearance: none; width: 100%; min-height: 47px; padding: 6px 7px; display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 8px; text-align: left; font: inherit; color: inherit; background: transparent; border: 1px solid transparent; border-radius: 3px; }
.party-target:hover { background: #263b31; }
.party-target[aria-pressed="true"] { border-color: #f0c46e; background: #2d4437; box-shadow: inset 3px 0 var(--gold); }
.party-target small { margin-top: 3px; }
.party-target .song-status { color: #ffe1aa; }
.party-health { font-size: .74rem; font-weight: 800; color: #9fd2c6; white-space: nowrap; font-variant-numeric: tabular-nums; }
.quest-tracker { margin-top: 10px; padding: 9px 11px; border: 1px solid #6f765d;  border-radius: 4px; background: linear-gradient(90deg, #172b23f2, #0d1b16f2); color: #fff0c8; font-size: .84rem; line-height: 1.35; box-shadow: inset 0 0 0 1px #ffffff0a; }
.quest-tracker:not(:empty)::before { content: 'Objective'; display: block; margin-bottom: 2px; color: #d7ad61; font-size: .68rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.combat-bar { margin-top: 9px; background: linear-gradient(180deg, #14261ffa, #0b1713fa); border: 1px solid #8f754a; border-radius: 4px; padding: 7px 8px; box-shadow: inset 0 0 0 1px #ffffff0a, 0 2px 0 #050b08aa; }
.target-frame { min-height: 32px; display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; row-gap: 1px; padding: 1px 1px 5px; border-bottom: 1px solid #4e5f50; margin-bottom: 6px; }
.target-frame strong { font-size: .86rem; color: #fff0c8; }
.target-frame span, .ability-tip { font-size: .72rem; color: #bdc8b8; }
.hotbar { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.hotbar button { position: relative; min-width: 44px; min-height: 48px; padding: 4px; overflow: hidden; display: grid; justify-items: start; align-content: space-between; gap: 2px; color: #fff0c8; background: linear-gradient(180deg, #263b31, #102019); border: 1px solid #8f754a; border-radius: 3px; text-align: left; font-weight: 750; font-size: .64rem; line-height: 1.05; box-shadow: inset 0 0 0 1px #ffffff0d, 0 1px 0 #050b08; }
.hotbar button kbd { min-width: 17px; height: 17px; font-size: .62rem; }
.hotbar button:not(:disabled):hover { background: linear-gradient(180deg, #355044, #172b23); border-color: #d7ad61; }
.hotbar button:focus-visible { outline-color: var(--gold); z-index: 1; }
.hotbar button[aria-disabled="true"] { filter: saturate(.55); background: linear-gradient(180deg, #4a5147, #242b26); border-color: #7f8678; }
.hotbar button:disabled { color: #9aa794; background: #17211d; border-color: #4e5f50; box-shadow: none; }
.hotbar button .cooldown { position: absolute; inset: auto 3px 3px; color: #ffe1a0; font-size: .62rem; text-align: right; font-variant-numeric: tabular-nums; }
.ability-tip { margin: 5px 0 0; min-height: 1.2em; }

/* The scene owns the viewport. Only the interactive HUD surfaces intercept input. */
body {
  --hud-x: max(14px, env(safe-area-inset-left));
  --hud-right: max(14px, env(safe-area-inset-right));
  --hud-top: max(10px, env(safe-area-inset-top));
  --hud-bottom: max(12px, env(safe-area-inset-bottom));
  --hud-side: clamp(210px, 22vw, 288px);
  position: fixed;
  inset: 0;
  overflow: hidden;
}

body main.frame,
body .layout,
body:not(.is-playing) .layout,
body .world,
body .map-frame,
body .map-view {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: none;
}

body .map-view { overflow: visible; }
body #map { width: 100%; height: 100%; aspect-ratio: auto; touch-action: none; }
body.is-playing #map:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
body .map-view::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, #07110dbb, transparent 21%, transparent 75%, #07110d99);
}
body.is-playing .introduction,
body #controls-text {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
}
body .masthead {
  position: fixed;
  inset: var(--hud-top) var(--hud-right) auto var(--hud-x);
  z-index: 6;
  min-height: 0;
  border: 0;
  background: none;
  box-shadow: none;
  pointer-events: none;
}
body .masthead-inner { width: 100%; min-height: 44px; }
body .masthead-tools .invite { pointer-events: auto; }
body.is-playing .brand, body.is-playing .network { text-shadow: 0 2px 4px #050b08; }
body.is-playing .map-heading { z-index: 2; left: var(--hud-x); top: calc(var(--hud-top) + 51px); }
body.is-playing .view-tools { right: var(--hud-right); top: calc(var(--hud-top) + 51px); }
body.is-playing .world-hud { inset: auto; z-index: 4; }
body.is-playing .hud-vitals {
  position: fixed;
  left: var(--hud-x);
  top: calc(var(--hud-top) + 91px);
  min-width: 142px;
  max-width: min(248px, 46vw);
}
body.is-playing .hud-identity {
  gap: 7px;
  margin-bottom: 4px;
  color: #fff0c8;
  font: bold .87rem/1.2 var(--serif);
}
body.is-playing #hud-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.is-playing #hud-level { white-space: nowrap; color: var(--gold); }
body.is-playing .hud-actions {
  position: fixed;
  right: var(--hud-right);
  bottom: calc(var(--hud-bottom) + 115px);
  pointer-events: auto;
}
body.is-playing .map-footer {
  position: fixed;
  z-index: 2;
  left: var(--hud-x);
  bottom: var(--hud-bottom);
  max-width: min(225px, 100%);
  min-height: 0;
  flex-wrap: wrap;
  justify-content: flex-start;
  color: #fff1d1;
  padding: 5px 8px;
  border-radius: 4px;
  background: #101e18e8;
  pointer-events: none;
}
body.is-playing .map-footer .map-location { display: none; }
body.is-playing .rescue-clock {
  position: fixed;
  z-index: 3;
  top: calc(var(--hud-top) + 12px);
  left: 50%;
  transform: translateX(-50%);
  max-width: 48vw;
}
body.is-playing .controls { padding: 0; margin: 0; border: 0; background: none; }
body.is-playing .touch-controls {
  position: fixed;
  z-index: 4;
  left: var(--hud-x);
  bottom: calc(var(--hud-bottom) + 120px);
  margin: 0;
}
body.is-playing .quest-tracker {
  position: fixed;
  z-index: 2;
  top: calc(var(--hud-top) + 209px);
  left: var(--hud-x);
  width: min(236px, 36vw);
  margin: 0;
  padding: 7px 9px;
  border-left-width: 1px;
  pointer-events: none;
}
body.is-playing .quest-tracker:empty { display: none; }
body.is-playing .alert-stack {
  z-index: 3;
  top: calc(var(--hud-top) + 72px);
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translateX(-50%);
  justify-items: center;
  width: min(390px, 43vw);
}
body.is-playing .feedback,
body.is-playing .map-view.in-vault .feedback,
body.is-playing .map-view.is-playing .feedback {
  z-index: 3;
  top: auto;
  bottom: calc(var(--hud-bottom) + 123px);
  left: 50%;
  right: auto;
  width: max-content;
  max-width: min(430px, 58vw);
  transform: translateX(-50%);
  margin: 0;
}
body .invite-result {
  position: fixed;
  z-index: 7;
  top: calc(var(--hud-top) + 48px);
  right: var(--hud-right);
  max-width: min(370px, 92vw);
}
body.is-playing .combat-bar {
  position: fixed;
  z-index: 4;
  inset: auto auto var(--hud-bottom) 50%;
  transform: translateX(-50%);
  width: min(660px, calc(100% - 2 * var(--hud-x)));
  margin: 0;
}
body.is-playing .hotbar { grid-template-columns: repeat(10, minmax(0, 1fr)); }
body.is-playing .hotbar button { min-height: 42px; min-width: 0; }
body.is-playing .target-frame, body.is-playing .ability-tip { font-size: .72rem; }
body.is-playing .ability-tip { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

body.is-playing .sidebar {
  position: fixed;
  z-index: 5;
  display: block;
  top: calc(var(--hud-top) + 101px);
  right: var(--hud-right);
  width: var(--hud-side);
  max-height: calc(100dvh - var(--hud-top) - 242px);
  overflow: auto;
  margin: 0;
  scrollbar-color: #8f754a #0b1713;
  pointer-events: auto;
}
body.is-playing .panel { padding: 10px; }
body.is-playing .party-frames { margin-bottom: 6px; }
body.is-playing .panel-heading { margin-bottom: 7px; }
body.is-playing .roster { gap: 4px; margin-bottom: 0; }
body.is-playing .roster-row,
body.is-playing .party-target { min-height: 44px; padding-block: 4px; }
body.is-playing .portrait { width: 27px; height: 27px; flex: 0 0 27px; }
body.is-playing .roster-row strong { font-size: .8rem; overflow-wrap: anywhere; }
body.is-playing .roster-row small { margin-top: 0; font-size: .66rem; }
body.is-playing .quiet { min-height: 44px; }
body.is-playing .session { flex-wrap: wrap; gap: 4px 8px; }
.panel-close { margin-left: auto; }
.invite-count {
  min-width: 19px;
  padding: 3px 4px;
  border-radius: 3px;
  background: var(--gold);
  color: var(--paper);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.social-heading { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.social-heading h3 { font: bold .91rem var(--serif); }
.social-note { margin-top: 5px; color: #c6cfb9; font-size: .75rem; line-height: 1.4; }
.traveler-list { display: grid; margin-top: 8px; padding: 0; list-style: none; }
.traveler-list li,
.social-invitation { display: flex; align-items: center; gap: 6px; justify-content: space-between; padding: 5px 0; border-top: 1px solid #526451; font-size: .8rem; }
.traveler-list li > div { min-width: 0; }
.traveler-list li strong, .social-invitation strong { overflow-wrap: anywhere; }
.traveler-list small { display: block; color: #c6cfb9; font-size: .69rem; }
.social-action { padding: 4px 7px; font-size: .73rem; }
.social-action:disabled { opacity: .65; }
.party-invitations { margin-bottom: 10px; }
.social-invitation { flex-wrap: wrap; }
.social-invitation strong { flex-basis: 100%; color: var(--gold); }

@media (max-width: 760px) {
  body.is-playing { --hud-x: max(7px, env(safe-area-inset-left)); --hud-right: max(7px, env(safe-area-inset-right)); --hud-side: min(340px, calc(100vw - var(--hud-x) - var(--hud-right))); }
  body.is-playing .brand { font-size: .86rem; gap: 5px; }
  body.is-playing .masthead-tools { gap: 5px; }
  body.is-playing .masthead-tools .invite { padding-inline: 8px; font-size: .76rem; }
  body.is-playing .masthead-tools .link-icon, body.is-playing .view-tools kbd { display: none; }
  body.is-playing .map-heading { max-width: 40vw; }
  body.is-playing .map-heading #map-area { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  body.is-playing .hud-vitals { top: calc(var(--hud-top) + 98px); }
  body.is-playing .quest-tracker { top: calc(var(--hud-top) + 215px); width: min(188px, 52vw); font-size: .72rem; }
  body.is-playing .sidebar { max-height: calc(100dvh - var(--hud-top) - 212px); }
  body.is-playing .party-frames { display: none; }
  body.is-playing .sidebar:has(.social-panel:not([hidden])) .party-frames { display: block; }
  body.is-playing .alert-stack { width: min(310px, 66vw); top: calc(var(--hud-top) + 143px); left: auto; right: var(--hud-right); transform: none; justify-items: end; }
  body.is-playing .map-footer { display: none; }
  body.is-playing .map-footer:has(.rescue-clock:not([hidden])) { display: flex; padding: 0; }
  body.is-playing .rescue-clock { top: calc(var(--hud-top) + 100px); right: var(--hud-right); left: auto; transform: none; }
  body.is-playing .hotbar { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  body.is-playing .hotbar button { min-height: 44px; }
  body.is-playing .combat-bar { padding: 5px; }
  body.is-playing .target-frame { gap: 3px 6px; }
  body.is-playing .ability-tip { display: none; }
  body.is-playing .touch-controls,
  body.is-playing .hud-actions { bottom: calc(var(--hud-bottom) + 154px); }
  body.is-playing .feedback,
  body.is-playing .map-view.in-vault .feedback,
  body.is-playing .map-view.is-playing .feedback { bottom: calc(var(--hud-bottom) + 253px); max-width: 88vw; }
}
@media (max-width: 455px) {
  body.is-playing .network { font-size: 0; }
  body.is-playing .masthead-tools { gap: 8px; }
  body.is-playing .hud-actions { flex-direction: column; }
}
@media (max-height: 500px) {
  body.is-playing .quest-tracker { display: none; }
  body.is-playing .social-panel .session { padding-top: 0; }
}

body:not(.is-playing) .introduction {
  position: fixed;
  z-index: 2;
  top: max(84px, calc(var(--hud-top) + 59px));
  left: var(--hud-x);
  max-width: min(610px, calc(100vw - 2 * var(--hud-x)));
  pointer-events: none;
}
body:not(.is-playing) .introduction p {
  max-width: min(53ch, 100%);
  color: #fff1d1;
  text-shadow: 0 1px 4px #050b08, 0 1px 12px #050b08;
}
body:not(.is-playing) .map-view::after {
  background: linear-gradient(180deg, #081611e8, #101e1873 28%, transparent 68%, #05100c80);
}
body:not(.is-playing) .map-heading,
body:not(.is-playing) .map-footer,
body:not(.is-playing) .controls,
body:not(.is-playing) .quest-tracker { display: none; }
body:not(.is-playing) .compass { inset: 68px var(--hud-right) auto auto; z-index: 2; }
body:not(.is-playing) .sidebar {
  position: fixed;
  inset: auto var(--hud-right) var(--hud-bottom) auto;
  width: min(345px, calc(100vw - var(--hud-x) - var(--hud-right)));
  max-height: min(420px, calc(100dvh - var(--hud-top) - 170px));
  overflow: auto;
  margin: 0;
}
@media (max-width: 550px) {
  body:not(.is-playing) .compass { display: none; }
  body:not(.is-playing) .masthead .network { font-size: 0; }
  body:not(.is-playing) .masthead .invite { padding-inline: 9px; font-size: .76rem; }
  body:not(.is-playing) .masthead .link-icon { display: none; }
  body:not(.is-playing) .sidebar { max-height: calc(100dvh - 155px); }
}
