/* 상선 — "sailcloth glass" UI shell.
   Layout: full-bleed 3D canvas; two glass pills on top, one stitched glass bar at the bottom, notices stacked under the pills,
   dialogs as glass sheets. One deliberate light-on-scene look (it floats over day, dusk and night), so colours are explicit. */
:root {
  /* colour */
  --ink: #1b2740;            /* ink navy: all text and line icons */
  --ink-2: #4a5872;          /* secondary text */
  --ink-3: #7b8498;          /* tertiary, disabled */
  --brass: #a8803a;          /* accent: progress, active, focus halo */
  --brass-deep: #7a5a22;     /* brass text on light glass (AA on the panel) */
  --brass-glow: #e9cd8b;
  --cloth: #f3ecdd;          /* solid sailcloth (reduced transparency, boot, exit) */
  --cloth-2: #e7dcc6;
  --glass-top: rgba(255, 250, 241, .66);  /* translucent: the deck and sea read through the HUD (it never outshines the scene) */
  --glass-bot: rgba(250, 243, 229, .56);
  --glass-soft: rgba(255, 250, 241, .46); /* one-line hint: same family, a step quieter */
  --glass-edge: rgba(255, 255, 255, .5);
  --glass-solid: #f6f0e3;
  --line: rgba(27, 39, 64, .12);
  --line-2: rgba(27, 39, 64, .2);
  --stitch: rgba(122, 90, 34, .26);
  --hi: rgba(255, 255, 255, .9);
  --scrim: rgba(12, 19, 36, .34);
  --ok: #3d7558;
  --warn: #9b5f24;
  --shade: rgba(10, 17, 33, .42);
  /* type */
  --font-ui: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Noto Sans KR", "WenQuanYi Zen Hei", system-ui, sans-serif;
  --font-title: "Song Myung", "AppleMyungjo", "Batang", "Noto Serif KR", serif;
  --fs-xs: 11.5px; --fs-s: 12.5px; --fs-m: 14px; --fs-l: 15.5px; --fs-xl: 19px;
  /* shape */
  --r-pill: 999px; --r-card: 22px; --r-sheet: 26px;
  --tap: 44px;
  --gap: 12px;
  --edge-x-l: max(16px, env(safe-area-inset-left, 0px));
  --edge-x-r: max(16px, env(safe-area-inset-right, 0px));
  --edge-top: calc(env(safe-area-inset-top, 0px) + 12px);
  --edge-bot: calc(env(safe-area-inset-bottom, 0px) + 12px);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --shadow: 0 14px 34px -14px rgba(8, 14, 30, .55), 0 2px 6px -1px rgba(8, 14, 30, .16);
  --blur: blur(22px) saturate(140%) brightness(1.08);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { word-break: keep-all; overflow-wrap: break-word; }
body { margin: 0; background: #16203a; color: var(--ink); font-family: var(--font-ui); font-size: var(--fs-m);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow: hidden; overscroll-behavior: none; }
button, input, output, summary { font: inherit; color: inherit; }
button { -webkit-user-select: none; user-select: none; }
[hidden] { display: none !important; }

.app { position: fixed; inset: 0; bottom: auto; height: 100%; height: 100dvh; overflow: hidden; overflow: clip; touch-action: none; }
.scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }

/* ---------- icons ---------- */
.ico { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ico--sm { width: 18px; height: 18px; }
.ico--chev { width: 16px; height: 16px; stroke-width: 1.8; opacity: .55; margin-left: 1px; }
.ico--fill { fill: currentColor; stroke-width: 1.2; }

/* ---------- glass ---------- */
.glass {
  position: relative;
  background: linear-gradient(180deg, var(--glass-top), var(--glass-bot));
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--hi), inset 0 -1px 0 rgba(122, 90, 34, .10), var(--shadow);
  color: var(--ink);
}
/* night: the HUD turns to smoky navy glass with cream ink, so it sits at scene level instead of glowing over a dark deck */
.app[data-phase="night"] .hud {
  --ink: #f2ecdf; --ink-2: #c8ccd8; --ink-3: #8d94a8; --brass-deep: #e6c886; --brass: #d7b46a;
  --glass-top: rgba(30, 39, 62, .54); --glass-bot: rgba(22, 30, 50, .46); --glass-soft: rgba(24, 32, 54, .40);
  --glass-edge: rgba(255, 255, 255, .14); --hi: rgba(255, 255, 255, .12); --line-2: rgba(255, 255, 255, .22);
  --stitch: rgba(233, 205, 139, .26);
}
.app[data-phase="night"] .hud .glass::before { display: none; }
.app[data-phase="night"] .hud :is(.pill__btn, .bar__btn):hover { background: rgba(255, 255, 255, .1); }
.app[data-phase="night"] .hud :is(.pill__btn, .bar__btn):active { background: rgba(255, 255, 255, .16); }
.app[data-phase="night"] .hud .bar__btn[aria-pressed="true"] { background: rgba(255, 255, 255, .13);
  box-shadow: inset 0 0 0 1px rgba(233, 205, 139, .34); }
.app[data-phase="night"] .hud .conn__act { background: rgba(255, 255, 255, .1); }
/* faint sailcloth weave, only visible up close */
.glass::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(120, 96, 52, .022) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(120, 96, 52, .018) 0 1px, transparent 1px 4px);
  mix-blend-mode: multiply;
}

/* ---------- HUD frame ---------- */
.hud { position: absolute; inset: 0; z-index: 10; pointer-events: none;
  padding-left: var(--edge-x-l); padding-right: var(--edge-x-r);
  padding-block: var(--edge-top) var(--edge-bot);
  display: grid; grid-template-rows: auto 1fr auto; }
.hud > * { pointer-events: auto; }
.hud .notices { pointer-events: none; }

.app[data-ready="false"] .hud { visibility: visible; }

/* ---------- top bar ---------- */
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; min-width: 0; }
.pill--left { flex: 1; min-width: 0; }
.pill { display: flex; align-items: center; height: 48px; padding: 0 2px; border-radius: var(--r-pill); min-width: 0; }
.pill__btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: var(--tap); height: var(--tap); padding: 0 10px; border: 0; border-radius: var(--r-pill);
  background: transparent; cursor: pointer; white-space: nowrap;
  transition: background-color .16s var(--ease), transform .16s var(--ease);
}
.pill__btn--icon { padding: 0; width: var(--tap); }
.pill__btn:hover { background: rgba(255, 255, 255, .45); }
.pill__btn:active { background: rgba(255, 255, 255, .75); transform: scale(.95); }
.pill__sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 2px; flex: none; }
.pill__btn--ship { flex: 1; min-width: 0; padding: 0 6px 0 10px; font-size: var(--fs-l); }
.pill__btn--server { font-size: var(--fs-s); padding-inline: 9px; border-right: 1px solid var(--line-2); border-radius: 0; }
.pill__btn--ship .ship-name { max-width: 13em; overflow: hidden; text-overflow: ellipsis; }
.ship-name { font-weight: 600; letter-spacing: -.01em; }
.ship-no { font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pill__btn--count { flex: none; padding: 0 8px 0 4px; font-size: var(--fs-s); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.count { font-weight: 600; color: var(--ink); font-size: var(--fs-m); }
.count-cap { margin-left: 1px; }
.topbar__right { display: grid; justify-items: end; gap: 8px; flex: none; }
.pill--right .pill__btn[aria-pressed="true"] { color: var(--brass-deep); }

.chip { display: inline-flex; align-items: center; gap: 6px; height: var(--tap); padding: 0 14px 0 12px;
  border-radius: var(--r-pill); font-size: var(--fs-s); font-weight: 500; cursor: pointer; border: 1px solid rgba(255, 255, 255, .58);
  transition: transform .16s var(--ease), background-color .16s var(--ease); }
.chip:active { transform: scale(.96); }
.chip[aria-pressed="true"] { color: var(--brass-deep); }
.chip[aria-pressed="true"] .ico { animation: note 1.6s ease-in-out infinite; }
@keyframes note { 50% { transform: translateY(-1.5px); } }

/* ---------- notices: banner, connection, toasts, hint ---------- */
.notices { display: grid; align-content: start; justify-items: center; gap: 8px; padding-top: 10px; min-width: 0; }
.notices > * { pointer-events: auto; max-width: min(100%, 420px); }
.banner { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; width: min(100%, 420px);
  padding: 10px 14px 10px 10px; border-radius: 20px; overflow: hidden; animation: drop-in .6s var(--ease) both; }
.banner__icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6dc, var(--brass-glow) 60%, #c89c4d); color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(122, 90, 34, .35); }
.banner__icon .ico { width: 20px; height: 20px; }
.banner__text { display: grid; gap: 1px; min-width: 0; }
.banner__text strong { font-size: var(--fs-m); font-weight: 600; line-height: 1.35; }
.banner__text small { font-size: var(--fs-xs); color: var(--ink-2); }
.banner__time { font-size: var(--fs-xs); color: var(--brass-deep); font-variant-numeric: tabular-nums; font-weight: 500; }
.banner::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: calc(var(--left, 1) * 100%);
  background: linear-gradient(90deg, var(--brass), var(--brass-glow)); transition: width 1s linear; }
.banner.banner--line { display: inline-flex; width: auto; gap: 8px; padding: 5px 16px 5px 6px; border-radius: var(--r-pill); }
.banner--line .banner__icon { width: 28px; height: 28px; }
.banner--line .banner__icon .ico { width: 17px; height: 17px; }
.banner--line .banner__text strong { font-size: var(--fs-s); font-weight: 500; white-space: nowrap; }
.banner--line .banner__time, .banner--line::after { display: none; }

.conn { display: flex; align-items: center; gap: 10px; width: min(100%, 420px); min-height: 44px; padding: 4px 6px 4px 14px;
  border-radius: 18px; font-size: var(--fs-s); line-height: 1.45; animation: drop-in .5s var(--ease) both; }
.conn__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; animation: blink 1.4s ease-in-out infinite; }
.conn[data-state="none"] .conn__dot { background: var(--ink-3); animation: none; }
.conn__text { flex: 1; min-width: 0; padding-block: 6px; }
.conn__act { flex: none; min-height: 36px; padding: 0 12px; border-radius: 14px; border: 0; cursor: pointer;
  background: rgba(27, 39, 64, .07); font-weight: 600; font-size: var(--fs-s); color: var(--ink); }
.conn__act:active { background: rgba(27, 39, 64, .14); }
@keyframes blink { 50% { opacity: .35; } }

.toasts { display: grid; gap: 8px; justify-items: center; width: min(100%, 420px); }
.toast { display: flex; align-items: center; gap: 10px; max-width: 100%; min-height: 40px; padding: 9px 16px; border-radius: 18px;
  font-size: var(--fs-s); line-height: 1.5; text-align: center; text-wrap: balance; animation: drop-in .5s var(--ease) both; }
.toast.is-out { animation: fade-out .45s var(--ease) forwards; }
.toast__act { border: 0; background: none; padding: 6px 2px; min-height: 32px; color: var(--brass-deep); font-weight: 600; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(122, 90, 34, .4); }
@keyframes drop-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade-out { to { opacity: 0; transform: translateY(-6px); } }

.hint { margin: 2px 0 0; padding: 7px 14px; border-radius: 16px; font-size: var(--fs-s); font-weight: 500; line-height: 1.4; text-align: center;
  /* the toasts' glass and ink: the one-line hint must read over white cloud and over the night sky alike */
  color: var(--ink); background: linear-gradient(180deg, var(--glass-top), var(--glass-bot)); border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--hi), var(--shadow);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  transition: opacity .8s var(--ease), transform .8s var(--ease); }
/* never more than two notice rows under the pills */
.app.has-banner .toasts:not(:empty) ~ .hint, .toasts:has(> :nth-child(2)) ~ .hint { display: none; }
.app.has-tool .hint { opacity: 0; pointer-events: none; transition: none; }
.hint.is-hidden { opacity: 0; transform: translateY(-4px); pointer-events: none; }
.hint:empty { display: none; }

/* ---------- bottom bar ---------- */
.bar { justify-self: center; display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; width: min(100%, 460px);
  padding: 6px; border-radius: 28px; }
.bar[hidden] { display: none; }
.role-panel { justify-self: center; width: max-content; max-width: min(100%, 460px); border-radius: 24px; padding: 5px; }
.role-panel:has(.role-actions:not([hidden])) { width: min(100%, 460px); }
/* Keep the role and the general trial notice available to assistive technology
   without repeating the avatar label or crowding the compact action bar. */
.role-panel__heading, .role-panel__note { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.role-panel__status { max-width: 100%; max-height: 2.8em; overflow: hidden; margin: 3px 8px 5px; font-size: var(--fs-xs); line-height: 1.4; text-align: center; overflow-wrap: anywhere; }
.role-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; }
.role-actions[hidden], .role-proximity[hidden] { display: none; }
.role-proximity { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0; padding: 0 0 0 12px; font-size: var(--fs-s); }
.role-proximity button { min-height: 44px; font: inherit; font-weight: 700; padding: 0 15px; border: 1px solid rgba(255,255,255,.6); border-radius: 18px; color: inherit; background: rgba(255,255,255,.14); cursor: pointer; }
.role-proximity button:hover { background: rgba(255,255,255,.28); }
.role-proximity button:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.stair-launch, #interior-launch { min-height: 44px; }
.fleet-coordinates > summary { display: none; }
@media (max-width: 600px) {
  /* On a phone the server selector occupies a second row, so the server,
     ship and crew count remain individually readable without overflowing. */
  .pill__btn--server { position: absolute; top: 53px; left: 0; height: 44px; min-height: 44px;
    border: 1px solid var(--glass-edge); border-radius: 20px;
    background: linear-gradient(180deg, var(--glass-top), var(--glass-bot));
    box-shadow: var(--shadow); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
  .pill__btn--ship .ship-name { max-width: 100%; }
  .fleet-coordinates { position: fixed; left: 12px; top: 185px; z-index: 29; }
  .fleet-coordinates > summary { display: grid; place-items: center; min-height: 44px; padding: 0 12px; border: 1px solid #ead9ae; border-radius: 10px; background: #1b2a36ea; color: #fff; font: 13px system-ui; cursor: pointer; list-style: none; }
  .fleet-coordinates > summary::-webkit-details-marker { display: none; }
  .fleet-coordinates > div { position: static !important; margin-top: 4px; max-width: min(220px, calc(100vw - 24px)) !important; }
  .settings-exit { margin-top: 14px; }
}
.role-action { min-width: 0; min-height: 48px; border: 1px solid rgba(255,255,255,.24); border-radius: 18px; padding: 6px 4px; color: inherit; background: rgba(255,255,255,.08); cursor: pointer; font: inherit; font-size: var(--fs-s); font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.role-action:disabled { opacity: .55; cursor: default; }
.role-action:not(:disabled):hover { background: rgba(255,255,255,.38); }
.role-action:focus-visible { box-shadow: inset 0 0 0 2px var(--ink), 0 0 0 3px rgba(233, 205, 139, .95); outline: none; }
.role-panel__status:empty { display: none; }
.person__role { font-size: var(--fs-xs); color: var(--ink-2); flex: none; }
.bar::after { /* stitched sail seam */
  content: ""; position: absolute; inset: 4px; border-radius: 24px; border: 1px dashed var(--stitch); pointer-events: none; opacity: .9; }
.bar__btn { position: relative; display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 60px; padding: 6px 2px 7px;
  border: 0; border-radius: 22px; background: transparent; cursor: pointer; z-index: 1;
  transition: background-color .18s var(--ease), transform .18s var(--ease), color .18s var(--ease); }
.bar__btn:hover { background: rgba(255, 255, 255, .38); }
.bar__btn:active { transform: scale(.94); background: rgba(255, 255, 255, .7); }
.bar__btn[aria-pressed="true"] { background: linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(255, 250, 238, .78));
  box-shadow: inset 0 0 0 1px rgba(122, 90, 34, .28), 0 4px 12px -6px rgba(10, 17, 33, .4); color: var(--brass-deep); }
.bar__btn[aria-disabled="true"] { color: var(--ink-3); }
.bar__btn[aria-disabled="true"]:active { transform: none; }
.bar__btn[aria-busy="true"] .bar__label { color: var(--brass-deep); }
.bar__ico { position: relative; display: grid; place-items: center; width: 36px; height: 30px; }
.bar__ico .ico { width: 24px; height: 24px; }
.bar__label { font-size: var(--fs-s); font-weight: 500; letter-spacing: -.01em; white-space: nowrap; }
.bar__key { display: none; }
.ring { position: absolute; left: 50%; top: 50%; width: 38px; height: 38px; transform: translate(-50%, -50%) rotate(-90deg); opacity: 0;
  transition: opacity .3s var(--ease); fill: none; }
.ring__track { stroke: rgba(122, 90, 34, .18); stroke-width: 2.2; }
.ring__fill { stroke: var(--brass); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 106.8; stroke-dashoffset: 106.8; }
.bar__btn.is-pulling .ring { opacity: 1; }
.bar__btn.is-pulling .ico { transform: scale(.78); }
.bar__btn.is-hello .ico { animation: wave .9s var(--ease) 2; transform-origin: 60% 85%; }
@keyframes wave { 25% { transform: rotate(-14deg); } 60% { transform: rotate(10deg); } }

/* ---------- name tags ---------- */
.tags { position: absolute; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 3px 11px 3px 5px;
  border-radius: 14px; white-space: nowrap; font-size: 12.5px; font-weight: 500; color: var(--ink);
  background: rgba(255, 251, 243, .86); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 6px 16px -8px rgba(8, 14, 30, .55);
  transform: translate3d(var(--x, -999px), var(--y, -999px), 0) translate(-50%, -100%); will-change: transform;
  transition: opacity .35s var(--ease); }
.tag:not(.is-me) { padding-left: 11px; }
.tag__content { display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.15; }
.tag__role { color: #6b5435; font-size: 10.5px; font-weight: 700; }
.tag__name-row { display: flex; align-items: center; gap: 5px; }
.tag__me { display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; font-size: 10.5px; font-weight: 600;
  background: var(--ink); color: #fbf4e3; }
.tag.is-out { opacity: 0; }

/* ---------- tool screens (bell, scrub) ---------- */
.tool-host { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
.tool-host.is-over-boot { z-index: 31; }
.tool { position: absolute; inset: 0; pointer-events: auto; display: grid; grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center; align-items: center; gap: 14px;
  padding-left: var(--edge-x-l); padding-right: var(--edge-x-r);
  padding-block: calc(env(safe-area-inset-top, 0px) + 172px) calc(env(safe-area-inset-bottom, 0px) + 100px); }
/* The scene is paused while a tool is open, so it is blurred with a plain filter on the (static) canvas: the result is
   cached, unlike a full-screen backdrop-filter that is recomputed every frame the tool canvas animates. */
.scene, .tags, [data-scene] { transition: filter .45s var(--ease); }
.app.has-tool > :is(.scene, .tags, [data-scene]) { filter: blur(14px) saturate(1.08) brightness(.96); }
.tool::before { content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(120% 70% at 50% 55%, rgba(14, 22, 42, .06), rgba(14, 22, 42, .26)); animation: tool-in .45s var(--ease) both; }
.tool > * { animation: tool-pop .5s var(--ease) both; }
.tool > .tool__stage { animation-delay: .04s; }
.tool > .tool__ctrls { animation-delay: .08s; }
.tool > .tool__sr { animation: none; }
.tool-host.is-over-boot .tool::before { background:
    repeating-linear-gradient(0deg, rgba(120, 100, 60, .035) 0 1px, transparent 1px 3px),
    radial-gradient(120% 80% at 50% 38%, var(--cloth), var(--cloth-2)); }
.tool-host.is-over-boot .tool { padding-block: calc(env(safe-area-inset-top, 0px) + 28px) calc(env(safe-area-inset-bottom, 0px) + 24px); }
.tool.is-out::before, .tool.is-out > * { animation: tool-out .28s var(--ease) forwards; }
@keyframes tool-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes tool-pop { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes tool-out { to { opacity: 0; } }
.tool__stage { position: relative; width: min(100%, 360px); height: 100%; max-height: 480px; border-radius: 30px;
  box-shadow: inset 0 0 0 1.5px rgba(233, 205, 139, .78), 0 0 0 1px rgba(122, 90, 34, .18), 0 24px 60px -24px rgba(5, 10, 25, .7); }
.tool__stage::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 2;
  box-shadow: inset 0 0 0 1.5px rgba(233, 205, 139, .8), inset 0 1px 0 2px rgba(255, 244, 214, .18); }
.tool__stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: inherit; touch-action: none; outline: none; will-change: transform; }
.tool__stage canvas:focus-visible { box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px var(--brass-glow); }
.tool__cap { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 3; margin: 0; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 13px; border-radius: 16px;
  font-size: var(--fs-s); font-weight: 500; font-variant-numeric: tabular-nums; pointer-events: none; }
.tool__cap .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brass); }
.tool__ctrls { display: flex; align-items: center; height: 48px; padding: 0 2px; border-radius: var(--r-pill); }
.tool__ctrls .pill__btn { font-size: var(--fs-m); font-weight: 500; gap: 7px; padding: 0 16px; }
.tool__ctrls .pill__btn[aria-pressed="true"] { color: var(--brass-deep); }
.tool__note { position: absolute; left: 16px; right: 16px; bottom: 18px; margin: 0 auto; width: fit-content; z-index: 3;
  padding: 8px 14px; border-radius: 16px; font-size: var(--fs-s); line-height: 1.45; text-align: center; color: var(--ink);
  background: rgba(255, 251, 243, .9); box-shadow: 0 8px 20px -10px rgba(5, 10, 25, .6); animation: drop-in .4s var(--ease) both; }
.tool__count { position: absolute; left: 18px; bottom: 16px; display: grid; gap: 0; color: #fff8ea; pointer-events: none;
  text-shadow: 0 1px 2px rgba(20, 10, 0, .55), 0 0 18px rgba(20, 10, 0, .35); }
.tool__count b { font: 600 46px/1 var(--font-ui); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tool__count span { font-size: var(--fs-s); font-weight: 500; opacity: .92; }
.tool__count.is-bump b { animation: bump .6s var(--ease); }
@keyframes bump { 30% { transform: translateY(-4px) scale(1.08); color: var(--brass-glow); } }
.tool__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tool__fallback { position: absolute; inset: 0; display: grid; place-items: center; }
.tool__fallback svg { width: 62%; height: auto; overflow: visible; }

/* ---------- dialogs (glass sheets) ---------- */
dialog.sheet { margin: auto; padding: 18px 16px 18px; width: min(calc(100% - 32px), 430px); max-height: calc(100% - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  border-radius: var(--r-sheet); overflow: auto; overscroll-behavior: contain; color: var(--ink);
  scrollbar-width: thin; scrollbar-color: rgba(27, 39, 64, .25) transparent; }
dialog.sheet[open] { animation: sheet-in .5s var(--ease) both; display: grid; gap: 14px; align-content: start; }
dialog.sheet::backdrop { background: var(--scrim); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: tool-in .4s var(--ease) both; }
dialog.sheet { outline: 1px dashed var(--stitch); outline-offset: -6px; } /* stitched seam that does not scroll */
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.sheet__head { display: flex; align-items: flex-start; gap: 12px; padding: 2px 2px 0 6px; }
.sheet__titles { flex: 1; min-width: 0; display: grid; gap: 4px; padding-top: 6px; }
.sheet__title { margin: 0; font-size: var(--fs-xl); font-weight: 600; letter-spacing: -.015em; text-wrap: balance; }
.sheet__lead { margin: 0; font-size: var(--fs-s); color: var(--ink-2); line-height: 1.5; }
.sheet__foot, .sheet__note { margin: 0; padding: 0 6px; font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.55; }
.round-btn { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; cursor: pointer;
  border: 1.5px solid rgba(168, 128, 58, .7); background: rgba(255, 255, 255, .4); color: var(--ink);
  transition: transform .16s var(--ease), background-color .16s var(--ease); }
.round-btn:active { transform: scale(.93); background: rgba(255, 255, 255, .8); }

.today { display: flex; align-items: center; gap: 8px; margin: 0 6px; padding: 9px 12px; border-radius: 14px; font-size: var(--fs-s);
  background: rgba(168, 128, 58, .1); color: var(--brass-deep); font-weight: 500; }
.ships { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ship { display: grid; gap: 3px; width: 100%; min-height: 64px; padding: 11px 13px; border-radius: 16px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .42); transition: transform .16s var(--ease), background-color .16s var(--ease); }
.ship:hover { background: rgba(255, 255, 255, .65); }
.ship:active { transform: scale(.97); }
.ship__name { font-size: var(--fs-m); font-weight: 600; font-variant-numeric: tabular-nums; }
.ship__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: var(--fs-xs); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11px; font-weight: 600; letter-spacing: .01em; }
.badge--busy { background: rgba(61, 117, 88, .13); color: #2e5d45; }
.badge--full { background: rgba(155, 95, 36, .13); color: #7f4c1a; }
.badge--here { background: var(--ink); color: #fbf4e3; }
.badge--npc { background: rgba(168, 128, 58, .16); color: var(--brass-deep); }
.ship[aria-current="true"] { background: rgba(255, 255, 255, .82); border-color: rgba(168, 128, 58, .55); box-shadow: inset 0 0 0 1px rgba(168, 128, 58, .35); }
.ship[aria-disabled="true"] .ship__name { color: var(--ink-2); }
.ship-skeleton { grid-column: 1 / -1; padding: 18px 6px; font-size: var(--fs-s); color: var(--ink-2); text-align: center; }

.people { list-style: none; margin: 0; padding: 4px 0; display: grid; border-radius: 18px; background: rgba(255, 255, 255, .38); border: 1px solid var(--line); }
.person { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 6px 14px; }
.person + .person { border-top: 1px solid var(--line); }
.person__dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.person__name { flex: 1; min-width: 0; font-size: var(--fs-m); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person.is-me .person__name { font-weight: 600; }
.invite { display: grid; gap: 8px; justify-items: center; padding-top: 2px; }
.invite__sub { margin: 0; font-size: var(--fs-xs); color: var(--ink-2); }
.invite__field { width: 100%; height: 40px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, .8);
  font-size: var(--fs-s); color: var(--ink); }
.wide-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 50px; padding: 0 18px;
  border-radius: 25px; border: 0; cursor: pointer; font-size: var(--fs-m); font-weight: 600; color: #fbf4e3;
  background: linear-gradient(180deg, #25345a, var(--ink)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 8px 18px -10px rgba(10, 17, 33, .8);
  transition: transform .16s var(--ease), filter .16s var(--ease); }
.wide-btn:hover { filter: brightness(1.08); }
.wide-btn:active { transform: scale(.97); filter: brightness(.95); }
.wide-btn.is-done { background: linear-gradient(180deg, #3e7a5b, #2f6248); }

.set-group { display: grid; gap: 10px; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 4px 6px; }
.set-row__text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.set-row__title { margin: 0; font-size: var(--fs-l); font-weight: 600; }
.set-row__sub { margin: 0; font-size: var(--fs-s); color: var(--ink-2); line-height: 1.45; }
.set-note { margin: -4px 6px 2px; font-size: var(--fs-s); color: var(--brass-deep); }
.switch { position: relative; flex: none; width: 54px; height: 32px; border-radius: 16px; border: 0; cursor: pointer; padding: 0;
  background: rgba(27, 39, 64, .16); box-shadow: inset 0 1px 2px rgba(10, 17, 33, .18); transition: background-color .22s var(--ease); }
.switch::after { content: ""; position: absolute; inset: -6px -2px; } /* 44px target */
.switch__knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fffdf8;
  box-shadow: 0 2px 5px rgba(10, 17, 33, .3); transition: transform .26s var(--ease); }
.switch[aria-checked="true"] { background: var(--brass); }
.switch[aria-checked="true"] .switch__knob { transform: translateX(22px); }
.vol-card { display: grid; gap: 10px; padding: 12px 14px 12px; border-radius: 18px; background: rgba(255, 255, 255, .4); border: 1px solid var(--line); }
.vol-card__head { display: flex; gap: 10px; align-items: center; }
.vol-card__head > div { min-width: 0; }
.vol-card__ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: rgba(27, 39, 64, .07); flex: none; }
.vol-card__title { margin: 0; font-size: var(--fs-m); font-weight: 600; }
.vol-card__sub { margin: 1px 0 0; font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.45; }
.vol-card__slider { display: flex; align-items: center; gap: 12px; }
.vol-card__next { display: flex; align-items: center; gap: 7px; margin: -2px 0 0; font-size: var(--fs-xs); color: var(--brass-deep); font-weight: 500; }
.vol-card__next::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--brass); }
.vol-card output { width: 3.2em; text-align: right; font-size: var(--fs-s); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.set-group.is-muted .vol-card { opacity: .62; }
input[type="range"] { -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 32px; background: transparent; cursor: pointer; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--brass) 0 var(--v, 35%), rgba(27, 39, 64, .14) var(--v, 35%) 100%); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(27, 39, 64, .14); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--brass); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%;
  background: #fffdf8; border: 1px solid rgba(122, 90, 34, .35); box-shadow: 0 2px 6px rgba(10, 17, 33, .28); }
input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #fffdf8; border: 1px solid rgba(122, 90, 34, .35); }

.fold { border-top: 1px solid var(--line); padding: 4px 6px 0; }
.fold summary { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-size: var(--fs-m); font-weight: 500; list-style: none; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before { content: ""; width: 7px; height: 7px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg); transition: transform .2s var(--ease); margin: 0 4px 0 2px; }
.fold[open] summary::before { transform: rotate(45deg); }
.fold__list { margin: 0 0 8px; padding: 0 0 0 22px; display: grid; gap: 6px; font-size: var(--fs-s); color: var(--ink-2); line-height: 1.55; }
.credits { border-top: 1px solid var(--line); padding: 12px 6px 2px; display: grid; gap: 6px; }
.credits__title { margin: 0; font-size: var(--fs-s); font-weight: 600; color: var(--ink-2); }
.credits__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.5; }
.set-ver { margin: 0; padding: 10px 6px 2px; font-size: var(--fs-xs); color: var(--ink-2); text-align: center; letter-spacing: .04em; }

/* ---------- overlay (tab elsewhere) and exit card ---------- */
.overlay { position: fixed; inset: 0; z-index: 35; display: flex; align-items: center; justify-content: center; background: var(--scrim);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); padding-left: var(--edge-x-l); padding-right: var(--edge-x-r); }
.overlay__card { display: grid; justify-items: center; gap: 10px; width: min(100%, 360px); padding: 26px 22px 20px; border-radius: var(--r-sheet); text-align: center; }
.overlay__mark { width: 34px; height: 34px; fill: none; stroke: var(--ink); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.overlay__title { margin: 4px 0 0; font-size: var(--fs-xl); font-weight: 600; }
.overlay__body { margin: 0 0 8px; font-size: var(--fs-s); color: var(--ink-2); }

.exit { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; text-align: center;
  padding-left: var(--edge-x-l); padding-right: var(--edge-x-r); padding-block: var(--edge-top) var(--edge-bot);
  background:
    repeating-linear-gradient(0deg, rgba(120, 100, 60, .035) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(120, 100, 60, .03) 0 1px, transparent 1px 3px),
    radial-gradient(120% 80% at 50% 38%, var(--cloth), var(--cloth-2));
  animation: tool-in .9s var(--ease) both; }
.exit__col { display: grid; justify-items: center; gap: 10px; max-width: 320px; }
.exit__mark { width: 40px; height: 40px; fill: none; stroke: var(--ink); stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.exit__eyebrow { margin: 4px 0 0; font-size: var(--fs-s); letter-spacing: .18em; color: var(--ink-2); }
.exit__title { margin: 6px 0 0; font: 400 27px/1.3 var(--font-title); letter-spacing: .04em; text-wrap: balance; }
.exit__body { margin: 0 0 14px; font-size: var(--fs-m); line-height: 1.7; color: var(--ink-2); }
.exit__btn { min-height: 48px; padding: 0 28px; border-radius: 24px; cursor: pointer; font-size: var(--fs-m); font-weight: 500; color: var(--ink);
  border: 1px solid rgba(122, 90, 34, .55); background: rgba(255, 252, 245, .7); transition: transform .16s var(--ease), background-color .16s var(--ease); }
.exit__btn:active { transform: scale(.97); background: #fffdf7; }
.boot__acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* ---------- focus ---------- */
:where(button, a, input, summary, [tabindex]):focus-visible { outline: none;
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px rgba(233, 205, 139, .95); }
.pill__btn:focus-visible, .bar__btn:focus-visible { box-shadow: inset 0 0 0 2px var(--ink), 0 0 0 3px rgba(233, 205, 139, .95); }
input[type="range"]:focus-visible { box-shadow: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px rgba(233, 205, 139, .95); }

/* ---------- desktop ---------- */
@media (hover: hover) and (pointer: fine) and (min-width: 900px) {
  .bar { width: 400px; padding: 5px; border-radius: 24px; }
  .bar::after { border-radius: 20px; }
  .bar__btn { min-height: 54px; border-radius: 19px; }
  .bar__key { display: grid; place-items: center; position: absolute; top: 5px; right: 9px; min-width: 15px; height: 15px; padding: 0 3px;
    border-radius: 4px; font: 600 9.5px/1 var(--font-ui); color: var(--ink-2); border: 1px solid var(--line-2); background: rgba(255, 255, 255, .5); }
  /* night: the key digits sat grey-on-light-grey (blank chips); dark chip, cream digits */
  .app[data-phase="night"] .hud .bar__key { background: rgba(255, 255, 255, .08); color: var(--ink-2); }
  .hud { padding-block: calc(env(safe-area-inset-top, 0px) + 20px) calc(env(safe-area-inset-bottom, 0px) + 18px);
    padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
  .tool { padding-block: 150px 100px; }
  .tool__stage { width: min(100%, 400px); max-height: 520px; }
}
@media (max-width: 370px) {
  .pill__btn--ship { padding: 0 4px 0 8px; }
  .pill__btn--count { padding: 0 10px 0 4px; }
  .bar__label { font-size: 12px; }
}
@media (max-height: 700px) { .tool { padding-block: calc(env(safe-area-inset-top, 0px) + 128px) calc(env(safe-area-inset-bottom, 0px) + 92px); } }
@media (max-height: 520px) and (orientation: landscape) {
  .tool { padding-block: calc(env(safe-area-inset-top, 0px) + 70px) calc(env(safe-area-inset-bottom, 0px) + 84px); }
  .bar__btn { min-height: 50px; }
  .bar__label { font-size: 11.5px; }
}

/* ---------- preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .glass, .tag, .hint { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--glass-solid); }
  .glass::before { display: none; }
  .hint { color: var(--ink); text-shadow: none; }
  .app[data-phase="night"] .hud :is(.glass, .hint) { background: #1e2740; }
  .tool::before { background: rgba(14, 22, 42, .78); }
  .app.has-tool > :is(.scene, .tags, [data-scene]) { filter: none; }
  dialog.sheet::backdrop { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(12, 19, 36, .6); }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: linear-gradient(180deg, rgba(255, 252, 246, .95), rgba(246, 239, 224, .92)); }
  .app[data-phase="night"] .hud :is(.glass, .hint) { background: linear-gradient(180deg, rgba(32, 41, 64, .94), rgba(24, 32, 52, .92)); }
  .tag { background: rgba(255, 251, 243, .96); }
}
@media (forced-colors: active) {
  .glass, .tag, .bar__btn[aria-pressed="true"], .ship, .switch, .wide-btn, .exit__btn, .round-btn { border: 1px solid CanvasText; forced-color-adjust: auto; }
  .ring__fill { stroke: Highlight; }
  .switch[aria-checked="true"] { background: Highlight; }
  .ico { stroke: CanvasText; }
}

/* ---------- bell tool ---------- */
.bell-stage { background: radial-gradient(70% 55% at 50% 40%, rgba(255, 236, 196, .22), rgba(255, 236, 196, 0) 70%); overflow: hidden; }
.bell-stage canvas { cursor: pointer; }
.bell-rings { position: absolute; inset: 0; pointer-events: none; }
.bell-ring { position: absolute; left: 50%; top: 58%; width: 78%; aspect-ratio: 1; border-radius: 50%;
  border: 1.5px solid rgba(233, 205, 139, .85); box-shadow: 0 0 18px rgba(233, 205, 139, .35); transform: translate(-50%, -50%) scale(.55); opacity: 0; }
.bell-tap { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); margin: 0; padding: 6px 12px; border-radius: 14px;
  font-size: var(--fs-s); color: #fff8ea; white-space: nowrap; background: rgba(14, 22, 42, .28); pointer-events: none;
  transition: opacity .6s var(--ease); }
.bell-stage.is-touched .bell-tap { opacity: 0; }

/* ---------- scrub tool ---------- */
.scrub-stage { overflow: hidden; background: #20150d; }
.scrub-stage canvas { cursor: grab; }
.scrub-stage canvas:active { cursor: grabbing; }
.tool--scrub .tool__count { left: 18px; bottom: 14px; }
