:root {
  color-scheme: dark;
  --bg: #0c1517;
  --panel: #132123;
  --panel-deep: #101c1e;
  --border: #344340;
  --paper: #f0e5cc;
  --ink: #e7deca;
  --muted: #aeb8ac;
  --copper: #dbb27a;
  --mint: #a1cabb;
  --red: #eba79a;
  --serif: Georgia, 'Times New Roman', serif;
  font: 15px/1.5 system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(ellipse at 75% 4%, #20302b 0%, transparent 42%); }
button, input, select { font: inherit; }
button, input, select { border-radius: 6px; }
button { cursor: pointer; color: inherit; }
button:disabled, select:disabled { cursor: default; opacity: .63; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid #e8ba81; outline-offset: 3px; }
[hidden] { display: none !important; }
.frame { width: min(94%, 1330px); margin-inline: auto; }
#app { flex: 1; }
.topbar { border-bottom: 1px solid #3b4945; background: #0c1618e8; }
.bar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 67px; }
.brand { display: inline-flex; gap: .75rem; align-items: center; text-align: left; text-transform: uppercase; }
.brand > span:last-child { font: bold .85rem/1.12 var(--serif); letter-spacing: .13em; }
.sigil { width: 35px; aspect-ratio: 1; position: relative; border: 1px solid var(--copper); border-radius: 50%; display: grid; place-items: center; color: var(--copper); }
.sigil::before { content: ''; width: 17px; aspect-ratio: 1; border: 1px solid currentColor; transform: rotate(45deg); }
.sigil::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; position: absolute; }
.top-links { display: flex; align-items: center; gap: .85rem; }
.quiet { background: transparent; border: 1px solid transparent; padding: .48rem .6rem; }
.quiet:hover:not(:disabled) { background: #c9d6c510; color: var(--paper); }
.connection { font-size: .79rem; white-space: nowrap; color: var(--mint); }
.connection::before { content: '●'; margin-right: .4rem; font-size: .57rem; }
.connection.offline { color: var(--red); }
.footer { min-height: 57px; display: flex; align-items: center; justify-content: space-between; gap: .8rem; color: var(--muted); font-size: .76rem; border-top: 1px solid var(--border); margin-top: 1.8rem; }
.footer span:first-child { font-family: var(--serif); text-transform: uppercase; letter-spacing: .08em; }
h1, h2, p { margin: 0; }
h1, h2 { font-family: var(--serif); font-weight: normal; color: var(--paper); }
h2 { line-height: 1.15; font-size: 1.65rem; }
.kicker { text-transform: uppercase; letter-spacing: .14em; color: var(--copper); font-size: .7rem; font-weight: 650; }
.kicker > span { display: inline-block; vertical-align: middle; width: 22px; border-top: 1px solid; margin-right: .5rem; }
.muted, small { color: var(--muted); }
small { font-size: .8rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; white-space: nowrap; clip-path: inset(50%); }
.loading { margin: 4rem auto; }
.hero {
  position: relative; isolation: isolate; display: grid; grid-template-columns: minmax(0, 1fr) minmax(305px, 360px);
  align-items: center; gap: clamp(2rem, 5vw, 5rem); min-height: 565px; padding: clamp(1.6rem, 6vw, 6.3rem);
  margin: clamp(.8rem, 2.4vw, 2.25rem) 0 1.2rem; border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: linear-gradient(90deg, #0b1518bb 5%, #0b15182b 60%, #0b151869 100%), url('/harbor.webp') 66% 55% / cover, #142021;
}
.hero h1 { font-size: clamp(4.05rem, 8.6vw, 8.6rem); font-variant: small-caps; line-height: .83; letter-spacing: -.055em; margin: .2em 0 .28em; text-shadow: 0 7px 25px #070d0dbd; }
.lead { font-size: clamp(1rem, 1.55vw, 1.25rem); color: #e6decb; max-width: 39ch; text-wrap: pretty; }
.hero-meta { display: flex; flex-wrap: wrap; gap: .4rem .8rem; margin-top: 1.4rem; color: #d7ceba; font-size: .79rem; }
.hero-meta span { padding: .28rem .57rem; border: 1px solid #aeb8ac52; background: #0b151873; border-radius: 5px; white-space: nowrap; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 1.15rem; min-width: 0; }
.entry { padding: clamp(1rem, 3vw, 1.7rem); background: #101d1fef; border-color: #9c88645c; box-shadow: 0 16px 70px #080f11b0; }
.entry-heading { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.2rem; }
.entry-heading .kicker { margin-bottom: .15rem; }
.entry-icon { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; color: var(--copper); border: 1px solid #a38a616b; border-radius: 50%; font-size: 1.5rem; }
.switcher { display: flex; gap: .3rem; padding: .27rem; background: #0d181b; border: 1px solid #384743; border-radius: 8px; }
.switcher button { background: transparent; border: 1px solid transparent; flex: 1; font-size: .83rem; color: var(--muted); padding: .47rem .25rem; }
.switcher button[aria-pressed=true] { border-color: #526055; background: #223330; color: var(--paper); }
.switcher button:hover { color: var(--paper); }
label { display: block; font-size: .82rem; font-weight: 650; margin: .9rem 0 .34rem; }
input, select { width: 100%; color: var(--ink); background: #0d181b; border: 1px solid #465653; padding: .65rem .72rem; }
input::placeholder { color: #a9b5b1; }
input#code { letter-spacing: .13em; }
.primary, .secondary { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .63rem .9rem; font-weight: 680; border: 1px solid #687269; }
.primary { color: #191914; background: #e1b481; border-color: #e1b481; }
.primary:hover { background: #f0c995; }
.secondary { background: #1b2b2b; color: #f0e5ce; }
.secondary:hover { border-color: var(--copper); background: #263638; }
.primary:active, .secondary:active { transform: translateY(1px); }
.entry .primary, .station-panel .primary { display: flex; justify-content: space-between; width: 100%; margin-top: 1.1rem; text-align: left; }
.entry-note { color: var(--muted); margin-top: .75rem; font-size: .78rem; }
.resume { color: var(--copper); font-size: .78rem; margin-top: .4rem; padding-inline: 0; }
.field-guide { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.field-guide article { display: flex; align-items: flex-start; gap: .8rem; padding: .9rem 1rem; background: #141f20; border: 1px solid #34413d; border-radius: 8px; }
.field-guide article > span { margin-top: .05rem; width: 30px; aspect-ratio: 1; border: 1px solid #826e50; border-radius: 50%; color: var(--copper); flex: 0 0 auto; display: grid; place-items: center; }
.field-guide h2 { font-size: 1.12rem; }
.field-guide p { color: var(--muted); font-size: .82rem; margin-top: .23rem; }
.room-title { margin: 1.3rem 0; }
.room-title h1 { font-size: clamp(2.4rem, 5vw, 4.65rem); line-height: 1.02; letter-spacing: -.036em; margin: .2em 0; }
.room-title p:not(.kicker) { color: var(--muted); }
.room-bar { display: flex; align-items: center; gap: .7rem; margin-bottom: .7rem; }
.room-id { display: flex; gap: .5rem; align-items: center; padding: .38rem .55rem; background: #132123; border: 1px solid var(--border); border-radius: 6px; }
.room-id span { color: var(--muted); font-size: .78rem; }
.room-id strong { color: var(--copper); letter-spacing: .15em; font-size: .94rem; }
.compact { font-size: .82rem; min-height: 34px; padding: .34rem .6rem; }
.lobby-grid { display: grid; grid-template-columns: 1.02fr 1.3fr 1fr; gap: .9rem; align-items: start; }
.section-heading .kicker { margin-bottom: .22rem; }
.scenario-text, .role-description { color: var(--muted); margin-top: .6rem; font-size: .86rem; }
.members { padding: 0; list-style: none; margin: .74rem 0 0; }
.members li { display: flex; gap: .6rem; align-items: center; padding: .55rem .15rem; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.members li:last-child { border-bottom: 0; }
.members li small { display: block; }
.member-icon { display: grid; place-items: center; width: 35px; height: 35px; flex: 0 0 auto; border: 1px solid var(--role); border-radius: 50%; color: var(--role); font-size: 1.04rem; }
.divider-label { margin-top: .85rem; padding-top: .8rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .84rem; }
.role-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .42rem; margin-top: .55rem; }
.role-button { background: #112022; border: 1px solid #4a5852; padding: .45rem; display: flex; align-items: center; gap: .4rem; font-size: .77rem; text-align: left; min-width: 0; }
.role-button[aria-pressed=true], .role-button:hover:not(:disabled) { background: #26302b; border-color: var(--copper); }
.role-button .member-icon { width: 26px; height: 26px; font-size: .9rem; }
.role-button small { display: block; font-size: .7rem; }
.leave, .skip { color: var(--muted); margin-top: .55rem; font-size: .78rem; }
.score { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-bottom: .85rem; }
.score > div { background: var(--panel-deep); border: 1px solid var(--border); border-radius: 8px; display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .7rem; padding: .55rem .85rem; }
.score strong { color: var(--paper); font-size: 1.2rem; }
.score small { margin-left: auto; }
.score progress { height: .42rem; width: 100%; flex: 1 1 60px; accent-color: #db8d79; }
.table-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(248px, 308px); gap: .9rem; align-items: start; }
.map-view { isolation: isolate; position: relative; width: 100%; min-width: 0; min-height: 510px; aspect-ratio: 1.68; overflow: hidden; border: 1px solid #566257; border-radius: 10px; background:
  linear-gradient(0deg,#122424ed,#142b2ab9), url('/harbor.webp') 70% 37% / cover, #19312e; }
.map-view::before { content: ''; position: absolute; inset: 12px; border: 1px solid #9cad974a; pointer-events: none; background:
  repeating-linear-gradient(90deg,#c7d4be12 0 1px, transparent 1px 7%),
  repeating-linear-gradient(0deg,#c7d4be0f 0 1px, transparent 1px 11%); z-index: -1; }
.map-heading { position: absolute; top: 17px; left: 21px; }
.map-heading h2 { font-size: 1.23rem; }
.compass { text-align: center; position: absolute; top: 17px; right: 24px; color: #e2d0aa; font-size: .68rem; }
.compass span { display: block; font-size: 1.1rem; line-height: 1; }
.map-plot { position: absolute; inset: 0; }
#map-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: -1; }
.map-node { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); display: grid; justify-items: center;
  min-width: 78px; min-height: 50px; padding: .28rem .35rem; background: #122226; color: var(--paper); border: 1px solid #718477; border-radius: 7px; box-shadow: 0 4px 13px #070e1090; }
.map-node strong { font-size: clamp(.66rem, 1.18vw, .98rem); font-weight: 620; }
.map-icon { color: var(--copper); font-size: 1.15rem; line-height: 1.25; }
.map-node.walkable { border-color: #b6ccac; }
.map-node:hover, .map-node[aria-pressed=true] { background: #31453f; border-color: var(--copper); }
.map-node[aria-pressed=true] { box-shadow: 0 0 0 2px #e1b48175, 0 4px 13px #070e1090; }
.marks { display: flex; gap: .26rem; align-items: center; font-size: .69rem; height: .77rem; }
.trace { color: #e5c597; }
.closed-gate, .map-pawn { color: #ade1c4; }
.gate, .enemy { color: var(--red); }
.marks i, .pips i { display: inline-block; width: .48rem; height: .48rem; background: var(--role); border-radius: 50%; }
.marks i.down { background: transparent; border: 1px solid var(--role); }
.map-key { display: flex; gap: .45rem 1rem; align-items: center; justify-content: center; flex-wrap: wrap; position: absolute; bottom: 17px; left: 14px; right: 14px; color: #d4ddce; font-size: .72rem; }
.map-key b { margin-right: .15rem; }
.operations { display: grid; gap: .7rem; }
.operations .kicker, .event-card .kicker { margin-bottom: .25rem; }
.operations p:not(.kicker), .event-card p:not(.kicker) { font-size: .86rem; color: var(--muted); margin: .45rem 0; }
.turn-line { display: flex; align-items: center; justify-content: space-between; font-size: .84rem; color: var(--muted); margin: .52rem 0; }
.pips { display: inline-flex; align-items: center; gap: .33rem; }
.pips i { --role: #102124; width: .65rem; height: .65rem; border: 1px solid #8a9b91; }
.pips i.filled { --role: var(--copper); border-color: var(--copper); }
.action { display: flex; width: 100%; margin-top: .37rem; justify-content: flex-start; font-size: .84rem; }
.action span { width: 1.1rem; text-align: center; font-size: 1.02rem; }
.status-tags { display: flex; gap: .47rem; flex-wrap: wrap; font-size: .7rem; margin-bottom: .4rem; }
.status-tags:empty { display: none; }
.status-tags span { border: 1px solid #646956; border-radius: 5px; padding: .16rem .35rem; }
.dice { display: flex; flex-wrap: wrap; gap: .34rem; margin: .45rem 0 .3rem; }
.dice span { width: 28px; height: 28px; border-radius: 6px; background: #1b2a2b; border: 1px solid #51685f; display: grid; place-items: center; font-weight: 700; }
.dice span.hit { color: #16231d; background: #abd1b7; border-color: #abd1b7; }
.outcome.won { border-color: #77aa8b; }
.outcome.lost { border-color: #b77c73; }
.below-table { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.27fr) minmax(0, .85fr); gap: .9rem; align-items: start; margin-top: .9rem; }
.crew .members .current strong { color: var(--copper); }
.stats { display: flex; flex-wrap: wrap; gap: .25rem .52rem; color: var(--muted); font-size: .72rem; margin-top: .18rem; }
.feed { height: 155px; overflow-y: auto; list-style: none; padding: 0; margin: .7rem 0 .15rem; }
.feed li { border-bottom: 1px solid #283432; padding: .27rem .22rem; font-size: .8rem; display: flex; align-items: baseline; gap: .45rem; overflow-wrap: anywhere; }
.feed.chat li { display: block; }
.feed li small { color: var(--copper); min-width: 1em; }
.feed .good { color: #bbdcc2; }
.feed .bad { color: var(--red); }
.feed .event { color: #ebc78e; }
.feed.chat strong { color: var(--copper); margin-right: .25rem; }
#chat-form { display: flex; gap: .35rem; margin-top: .5rem; }
#chat-form input { min-width: 0; font-size: .8rem; }
#chat-form .secondary { padding-inline: .62rem; }
.notice { position: fixed; z-index: 4; left: 50%; bottom: max(1.3rem, env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: 91vw; padding: .75rem 1.05rem; border: 1px solid var(--copper); color: var(--paper); border-radius: 7px; background: #252621; box-shadow: 0 6px 25px #050808c2; }
dialog { background: #142224; color: var(--ink); border: 1px solid #7d805e; border-radius: 10px; width: min(600px, 92vw); max-height: 87vh; padding: 1.45rem; }
dialog::backdrop { background: #060c0ed1; }
dialog .close { position: absolute; right: .5rem; top: .42rem; font-size: 1.3rem; line-height: 1; }
dialog h2 { padding-right: 1.45rem; margin: .14rem 0 .45rem; }
dialog p:not(.kicker) { color: var(--muted); }
dialog .primary { margin-top: .72rem; }
.rules { padding-left: 1.25rem; margin: .65rem 0 .2rem; }
.rules li { padding: .24rem .07rem; }
.busy [data-action], .busy [data-command], .busy [type=submit] { cursor: progress; }
@media (max-width: 900px) {
  .hero { min-height: 500px; padding: 2.25rem; gap: 1.55rem; }
  .lobby-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-grid { grid-template-columns: minmax(0, 1fr) minmax(211px, 247px); }
  .map-view { min-height: 430px; }
  .map-node { min-width: 64px; }
  .below-table { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .frame { width: 94%; }
  .hero { grid-template-columns: 1fr; background-position: 64% center; padding: 1.25rem; min-height: 0; gap: 1.35rem; }
  .hero h1 { font-size: clamp(3.92rem, 14vw, 6.7rem); }
  .entry { max-width: none; }
  .field-guide { grid-template-columns: 1fr; gap: .5rem; }
  .lobby-grid, .table-grid, .below-table { grid-template-columns: 1fr; gap: .7rem; }
  .bar-inner { min-height: 55px; }
  .top-links { gap: .35rem; }
  .room-title { margin-top: .75rem; }
  .room-title h1 { font-size: clamp(1.86rem, 5.8vw, 2.4rem); }
  .room-bar { margin-bottom: .4rem; }
  .table-grid { grid-template-columns: minmax(0, 1fr); }
  .map-view { min-height: 0; aspect-ratio: auto; }
  .map-heading { position: static; padding: .6rem .8rem 0; }
  .compass { top: .58rem; right: .8rem; }
  .map-plot { position: relative; inset: auto; height: clamp(235px, 53vw, 300px); }
  .map-node { touch-action: manipulation; }
  .map-key { position: static; padding: .2rem .55rem .48rem; gap: .2rem .64rem; }
  .score { gap: .3rem; }
  .score > div { font-size: .72rem; padding: .35rem .48rem; gap: .1rem .3rem; }
  .score strong { font-size: .92rem; }
  .score small { margin-left: 0; flex: 1 1 100%; font-size: .66rem; }
  .score progress { flex-basis: 100%; }
  .operations { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); align-items: start; gap: .48rem; }
  .operations > .panel { padding: .57rem; }
  .operations > :is(.outcome, .roll), .outcome + .site-card { grid-column: 1 / -1; }
  .operations .action { padding-inline: .5rem; gap: .22rem; }
  .site-card { display: flex; flex-direction: column; }
  .site-card > p:not(.kicker) { order: 1; }
  .operations h2 { font-size: 1.27rem; overflow-wrap: anywhere; }
  .score, .room-title { margin-bottom: .7rem; }
}
@media (max-width: 370px) {
  .map-node { min-width: 57px; }
  .map-node strong { font-size: .61rem; }
  .hero h1 { font-size: 3.5rem; }
}

@media (any-pointer: coarse) {
  .primary, .secondary, .quiet, .switcher button, .role-button {
    min-height: 44px;
    touch-action: manipulation;
  }
  dialog { max-height: 87dvh; }
  dialog .close { min-width: 44px; }
  input, select, #chat-form input { font-size: 16px; }
}
