:root {
  color-scheme: dark;
  --ink: #102621;
  --deep: #101f1b;
  --panel: #172e27;
  --paper: #f4e9cd;
  --muted: #a9baaa;
  --jade: #99ceb1;
  --gold: #ddbc77;
  --red: #f4a38c;
  --edge: #78917c65;
  --serif: "Songti SC", "Noto Serif CJK SC", "SimSun", serif;
  --sans: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font: 15px/1.5 var(--sans);
  color: var(--paper);
  background: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
h1, h2, p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.entry { min-height: 100svh; display: grid; grid-template-columns: minmax(0, 1.24fr) minmax(480px, 1fr); }
.entry-scene { position: relative; isolation: isolate; overflow: hidden; min-height: 100%; background: #33594f; }
.entry-scene canvas { position: absolute; width: 100%; height: 100%; inset: 0; display: block; }
.entry-scene::after { content: ""; position: absolute; inset: 14px; border: 1px solid #f3e6ba48; pointer-events: none; }
.scene-inscription { position: absolute; top: 45px; left: 38px; writing-mode: vertical-rl; display: flex; gap: 13px; align-items: center; font: 600 18px var(--serif); letter-spacing: .28em; color: #243c32; text-shadow: 0 0 14px #f5e6b5; }
.scene-inscription i { width: 1px; height: 24px; background: #476652; }
.scene-caption { position: absolute; bottom: 39px; left: 38px; color: #f1e4c0; letter-spacing: .12em; font: 600 17px var(--serif); text-shadow: 0 2px 8px #081f19; }
.scene-caption span { color: var(--gold); margin-right: 9px; }
.entry-side { padding: clamp(24px, 4.2vw, 86px); width: 100%; display: grid; align-content: center; position: relative; isolation: isolate; background: radial-gradient(ellipse at 100% 0%, #284238, transparent 66%), var(--ink); }
.entry-side::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .16; background: repeating-linear-gradient(0deg, transparent 0 3px, #b1bc9b14 4px 5px); pointer-events: none; }
.entry-head, .entry-footer { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.entry-head { border-bottom: 1px solid var(--edge); padding-bottom: 18px; margin-bottom: clamp(23px, 4vh, 52px); }
.edition { display: flex; align-items: center; gap: 10px; font: 600 17px var(--serif); letter-spacing: .06em; }
.edition small { display: block; margin-top: 3px; font: 11px var(--sans); color: var(--muted); }
.seal, .vitals-seal { display: grid; place-items: center; flex: none; background: #933e32; border: 1px solid #d38a63; box-shadow: inset 0 0 0 2px #943e32, inset 0 0 0 3px #d38a6377; color: #f9dfb2; width: 36px; height: 36px; font: 700 23px var(--serif); border-radius: 2px; }
.network { color: var(--muted); font-size: 12px; white-space: nowrap; }
.network::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 7px 2px 0; background: var(--gold); border-radius: 50%; }
.network[data-state=online]::before { background: var(--jade); box-shadow: 0 0 8px #8ee2ac8c; }
.network[data-state=offline]::before { background: var(--red); }
.overline { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 650; color: var(--gold); letter-spacing: .18em; }
.overline > span { width: 5px; height: 5px; transform: rotate(45deg); background: var(--gold); }
h1, .display-title { font: 700 clamp(47px, 5.5vw, 90px)/1.13 var(--serif); letter-spacing: -.065em; margin: 9px 0 12px; white-space: nowrap; }
h1 span { color: var(--gold); display: inline-block; margin: 0 .15em; font-size: .68em; vertical-align: .12em; }
.display-title { font-size: clamp(37px, 4.35vw, 70px); letter-spacing: .06em; margin-bottom: 17px; }
.lede { color: #c3cdb7; max-width: 31em; margin-bottom: clamp(17px, 3vh, 32px); }
.field-label, .disciplines legend { display: block; color: #d6dfc8; font-size: 13px; font-weight: 650; margin-bottom: 7px; }
input[type=text], input[type=url] { min-height: 45px; width: 100%; min-width: 0; padding: 9px 12px; color: var(--paper); background: #0b1d19; border: 1px solid var(--edge); border-radius: 3px; }
input::placeholder { color: #a1ad99; }
#room-input, #room-code { text-transform: uppercase; letter-spacing: .16em; font-variant-numeric: tabular-nums; }
.disciplines { border: 0; margin: 15px 0 16px; padding: 0; min-width: 0; }
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.choice { position: relative; min-width: 0; }
.choice input { position: absolute; left: 9px; top: 10px; opacity: 0; }
.choice label { display: grid; align-content: start; gap: 4px; height: 100%; min-height: 66px; padding: 9px 7px; text-align: center; background: #0f231e; border: 1px solid var(--edge); border-radius: 3px; cursor: pointer; color: #c1cbb9; }
.choice label:hover { border-color: var(--jade); }
.choice strong { font: 700 18px var(--serif); letter-spacing: .06em; color: var(--paper); overflow-wrap: anywhere; }
.choice small { font-size: 11px; overflow-wrap: anywhere; }
.choice input:checked + label { border-color: #d0b87c; background: #2c4030; box-shadow: inset 0 0 0 1px #c6ae6440; }
.choice input:checked + label::after { content: ""; position: absolute; right: 6px; top: 6px; width: 5px; height: 5px; transform: rotate(45deg); background: var(--gold); }
.choice input:focus-visible + label { outline: 2px solid var(--gold); outline-offset: 2px; }
.choice input:disabled + label { cursor: default; }
.discipline-detail { min-height: 2.7em; margin-top: 8px; font-size: 12px; color: var(--muted); }
.action { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 13px; background: #253c31; border: 1px solid #779580a0; border-radius: 3px; color: var(--paper); font-weight: 650; white-space: nowrap; }
.action:not(:disabled):hover { background: #355345; border-color: var(--jade); }
.primary { background: #d8ba7b; border-color: #e9ca8c; color: #1d2b20; box-shadow: inset 0 0 0 2px #7d6b423c; }
.primary:not(:disabled):hover { background: #ebcf94; border-color: #f4d99e; }
.full { width: 100%; }
#create-room { justify-content: space-between; padding-inline: 15px; }
.join-row { margin-top: 8px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.entry-footer { border-top: 1px solid var(--edge); margin-top: clamp(16px, 3vh, 34px); padding-top: 12px; }
.entry-footer p { color: #d5dbc4; font-size: 12px; line-height: 1.65; }
.entry-footer p span { color: var(--muted); }
.quiet { color: var(--jade); padding: 6px 0; min-height: 40px; border: 0; background: none; font-size: 13px; }
.quiet:hover { color: var(--paper); }
.feedback { font-size: 13px; color: var(--gold); margin-top: 8px; overflow-wrap: anywhere; }
.feedback[data-tone=error] { color: var(--red); }
.room-invite { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 12px; background: #0d201b; border: 1px solid var(--edge); }
.room-invite .field-label { margin: 0; font-size: 11px; }
#room-code { color: var(--gold); font-size: 23px; }
#invite-text { margin-top: 6px; font-size: 12px; }
.room-roster-title { display: flex; justify-content: space-between; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.room-roster { list-style: none; padding: 0; margin: 0; }
.room-roster li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 9px; min-height: 35px; padding: 5px 8px; border-bottom: 1px solid var(--edge); font-size: 13px; }
.roster-name { overflow-wrap: anywhere; }
.roster-tag { color: var(--jade); font-size: 11px; }
.roster-tag.hostile { color: var(--red); }
.room-roster small { color: var(--muted); }
.room-actions { display: grid; grid-template-columns: 1fr 1.25fr; gap: 8px; }
.room-help { color: var(--muted); font-size: 12px; margin: 0 0 8px; }

.expedition { position: fixed; inset: 0; isolation: isolate; overflow: hidden; background: #142e28; }
#world { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.hud-top { position: absolute; z-index: 1; inset: 14px 14px auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 9px; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.vitals, .expedition-clock, .map-card, .interaction, .channel, .field-event, .match-feedback, .key-strip { background: #0c211ce8; border: 1px solid #a9b69463; box-shadow: 0 3px 15px #06161255; }
.vitals { width: min(100%, 257px); padding: 8px 10px 9px; }
.vitals-head { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.vitals-seal { width: 26px; height: 26px; font-size: 17px; }
.hostiles { margin-left: auto; text-align: right; color: var(--red); font-size: 11px; font-weight: 550; }
.meter { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; color: #eee3c7; font-size: 11px; font-variant-numeric: tabular-nums; }
.track { height: 6px; background: #061511; box-shadow: inset 0 0 0 1px #91b29936; }
.track i { display: block; height: 100%; background: #82be96; }
.mana .track i { background: #7cb9cf; }
.expedition-clock { min-width: 105px; text-align: center; padding: 3px 12px 5px; color: #e6c98d; line-height: 1.3; }
.expedition-clock span, .expedition-clock small { display: block; font-size: 10px; }
.expedition-clock small { color: var(--muted); letter-spacing: .09em; }
.expedition-clock strong { display: block; font-size: 23px; font-variant-numeric: tabular-nums; }
.expedition-clock[data-urgent=true] strong { color: var(--red); }
.hud-tools { display: flex; justify-content: end; gap: 5px; }
.hud-button { min-height: 42px; font-size: 13px; background: #122a23ed; }
.map-card { position: absolute; right: 14px; top: 64px; width: 158px; padding: 5px 7px; color: #ced6bd; font-size: 10px; pointer-events: none; }
.map-card > div { display: flex; justify-content: space-between; }
#minimap { width: 100%; height: 109px; display: block; margin: 2px 0; }
.field-event, .interaction, .channel, .match-feedback { position: absolute; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 30px); padding: 6px 11px; text-align: center; color: var(--paper); font-size: 13px; pointer-events: none; }
.field-event { top: 83px; color: #ead7ac; }
.match-feedback { top: 119px; z-index: 2; color: var(--red); }
.interaction { bottom: 63px; color: var(--gold); }
.channel { bottom: 103px; width: 224px; }
.channel progress { display: block; width: 100%; height: 8px; margin: 5px 0; accent-color: var(--gold); }
.channel small { color: var(--muted); font-size: 11px; }
.desktop-controls { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 20px); }
.key-strip { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 3px 14px; padding: 7px 11px; color: #d0d9c5; font-size: 12px; }
.key-strip > span { white-space: nowrap; }
.key-strip b { color: var(--gold); font-weight: 600; }
.key-strip kbd { color: var(--paper); border: 1px solid #91aa8e6e; border-radius: 2px; padding: 1px 3px; font: 11px var(--sans); margin-right: 2px; }
.touch-controls { position: absolute; inset: auto 0 0; pointer-events: none; }
.joystick, .touch-action { touch-action: none; user-select: none; pointer-events: auto; }
.joystick { position: absolute; left: max(15px, env(safe-area-inset-left)); bottom: max(20px, env(safe-area-inset-bottom)); width: 105px; height: 105px; border: 1px solid #b9cfab88; background: #143029ba; border-radius: 50%; box-shadow: inset 0 0 0 9px #152e2477; }
.joystick i { position: absolute; top: calc(50% - 19px); left: calc(50% - 19px); width: 38px; height: 38px; border-radius: 50%; border: 1px solid #d1d9a7; background: #62836ac9; pointer-events: none; }
.touch-actions { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 53px); gap: 7px; align-items: end; }
.touch-action { display: grid; align-content: center; justify-content: center; width: 53px; height: 53px; padding: 2px; border-radius: 50%; border: 1px solid #a3b79aa8; background: #152d27e8; color: var(--paper); font-size: 11px; text-align: center; font-weight: 650; }
.touch-action small { color: var(--gold); line-height: 1; }
.touch-action[data-held=true] { background: #476747; }
.touch-action.skill { border-color: #dec384; }
.touch-action.attack { width: 57px; height: 57px; background: #375544f2; }
.touch-action.small { height: 38px; border-radius: 4px; }
#touch-interact { grid-area: 1 / 2; }
#touch-extract { grid-area: 1 / 3; }
#touch-dash { grid-area: 2 / 1; }
#touch-skill { grid-area: 2 / 2; }
#touch-attack { grid-area: 2 / 3; }
.reopen-result { position: absolute; bottom: 65px; left: 50%; transform: translateX(-50%); }

dialog { width: min(530px, calc(100% - 24px)); max-height: min(85dvh, 740px); padding: 0; color: var(--paper); background: #172e27; border: 1px solid #bdab7f; box-shadow: 0 20px 100px #071410cc; overflow: hidden; }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: #091a16b8; }
.panel-header { flex: none; display: flex; justify-content: space-between; gap: 10px; padding: 15px 18px 12px; border-bottom: 1px solid var(--edge); }
.panel-header h2 { font: 700 30px/1.2 var(--serif); margin-top: 4px; letter-spacing: .08em; }
.panel-close { padding: 0 7px; min-width: 42px; font-size: 28px; align-self: start; line-height: 1; }
.panel-body { padding: 15px 18px 19px; overflow: auto; overscroll-behavior: contain; }
.panel-body p + p { margin-top: 8px; }
.panel-body h3 { margin: 15px 0 5px; color: var(--gold); font-size: 14px; }
.panel-muted { color: var(--muted); font-size: 13px; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.panel-list { list-style: none; padding: 0; margin: 0; }
.panel-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--edge); overflow-wrap: anywhere; }
.panel-list strong { color: var(--gold); white-space: nowrap; }
.panel-danger { color: var(--red); }
.panel-alert { margin-top: 10px; color: var(--gold); }
body:has(dialog[open]) { overflow: hidden; }

@media (max-width: 1000px) {
  .entry { grid-template-columns: minmax(0, 1fr) minmax(430px, 1fr); }
  .entry-side { padding-inline: 28px; }
}
@media (max-width: 730px) {
  .entry { display: block; }
  .entry-scene { min-height: 0; height: clamp(132px, 25svh, 240px); }
  .entry-scene::after { inset: 8px; }
  .scene-inscription { top: 16px; left: 17px; font-size: 12px; gap: 6px; }
  .scene-inscription i { height: 10px; }
  .scene-caption { bottom: 13px; left: auto; right: 17px; font-size: 13px; }
  .entry-side { padding: 16px clamp(15px, 5vw, 33px) 21px; }
  .entry-head { margin-bottom: 15px; padding-bottom: 9px; }
  .entry-footer { margin-top: 14px; }
  h1 { font-size: clamp(39px, 11vw, 61px); margin-bottom: 7px; }
  .lede { font-size: 14px; }
  .hud-top { inset: 8px 8px auto; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; }
  .vitals { width: 100%; max-width: 260px; padding: 4px 6px 5px; }
  .vitals-head { font-size: 12px; }
  .meter { font-size: 10px; }
  .expedition-clock { grid-column: 2; grid-row: 1; justify-self: end; min-width: 73px; padding-inline: 6px; }
  .expedition-clock strong { font-size: 19px; }
  .hud-tools { grid-column: 1 / -1; justify-content: start; }
  .hud-button { min-height: 40px; font-size: 12px; padding-inline: 9px; }
  .map-card { right: 8px; top: 72px; width: 93px; padding: 3px; }
  .map-card > div { font-size: 9px; }
  #minimap { height: 62px; }
  .field-event { top: 158px; }
  .match-feedback { top: 189px; }
  .key-strip { gap: 2px 8px; padding: 4px 6px; }
}
.expedition[data-touch=true] .interaction { bottom: max(137px, calc(env(safe-area-inset-bottom) + 121px)); }
.expedition[data-touch=true] .channel { bottom: max(172px, calc(env(safe-area-inset-bottom) + 156px)); }
@media (max-height: 440px) {
  .map-card { display: none; }
  .field-event { top: 63px; }
  .match-feedback { top: 98px; }
  .touch-actions { bottom: 6px; }
  .joystick { bottom: 7px; width: 84px; height: 84px; }
}
