:root {
  --bg: #121019; --fg: #efe6da; --muted: #b3a9bf; --line: rgba(255, 236, 214, 0.14); --accent: #f0a35e;
  --glass: rgba(24, 18, 34, 0.62); --glass-strong: rgba(24, 18, 34, 0.86); --chip: rgba(255, 240, 225, 0.08);
  --ink: #2a1d2a;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overflow: hidden; }
body { font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-tap-highlight-color: transparent; }
#world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: var(--fg); background: var(--chip); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; cursor: pointer; }
button:hover { border-color: rgba(240, 163, 94, 0.6); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); color: #23161f; border-color: var(--accent); font-weight: 650; }
button.primary:hover { background: #f6b779; }
button.ghost { background: transparent; }
input { font: inherit; color: var(--fg); background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; min-width: 0; }
input::placeholder { color: rgba(239, 230, 218, 0.45); }
.small { font-size: 13px; color: var(--muted); margin: 0; }

/* the join card */
.card { position: fixed; z-index: 5; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 22px; padding: 22px 22px 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.join h1 { font: 600 40px/1 ui-serif, Georgia, "Times New Roman", serif; letter-spacing: 0.02em; margin: 0 0 6px; color: #ffe2c4; }
.join .lead { color: var(--muted); margin: 0 0 14px; font-size: 14.5px; }
.maker { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: start; }
#preview { width: 120px; height: 90px; border-radius: 14px; background: radial-gradient(ellipse at 50% 80%, rgba(255, 179, 92, 0.18), rgba(0, 0, 0, 0)); }
.picks { display: grid; gap: 7px; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.pickrow { display: flex; flex-wrap: wrap; gap: 5px; }
.pickrow button { padding: 4px 10px; font-size: 13px; }
.pickrow button[aria-checked="true"] { background: rgba(240, 163, 94, 0.22); border-color: var(--accent); }
.pickrow .sw { width: 28px; height: 28px; padding: 0; border-width: 2px; }
#step { width: 100%; margin: 14px 0 8px; padding: 11px; font-size: 17px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 10px; }
.or { color: var(--muted); font-size: 13px; }
#code { width: 84px; text-transform: uppercase; letter-spacing: 0.15em; text-align: center; }
.msg { min-height: 1.2em; margin: 8px 0 0; color: #ffc9a0; font-size: 14px; }
footer { margin-top: 10px; font-size: 12px; color: rgba(179, 169, 191, 0.7); text-align: center; }
@media (max-width: 380px) { .maker { grid-template-columns: 1fr; } #preview { width: 100%; height: 100px; } }

/* the hud: small, soft, out of the way */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
#hud > * { pointer-events: auto; }
.top { position: absolute; top: calc(10px + var(--safe-t)); left: 12px; right: 12px; display: flex; gap: 6px; align-items: center; pointer-events: none; }
.top > * { pointer-events: auto; }
.spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; color: var(--fg); }
.pill svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.pill.round { padding: 7px; }
.where { color: var(--muted); }
.where #area-name { color: var(--fg); }
.dot { opacity: 0.6; }
#station-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottom { position: absolute; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; pointer-events: none; }
.bottom > * { pointer-events: auto; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; max-width: 100%; }
.actions button { background: var(--glass-strong); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 14px; padding: 8px 14px; }
.actions button.first { border-color: rgba(240, 163, 94, 0.75); }
.actions button kbd { font: 600 11px ui-monospace, monospace; opacity: 0.6; margin-right: 6px; }
.actions .wait { color: var(--muted); font-size: 13px; padding: 8px 4px; }
.chatrow { display: flex; gap: 6px; width: min(440px, 100%); }
.chatrow input { flex: 1; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 999px; }
.banner { position: absolute; top: calc(56px + var(--safe-t)); left: 50%; transform: translateX(-50%); max-width: min(560px, calc(100vw - 32px));
  background: rgba(255, 226, 196, 0.94); color: var(--ink); border-radius: 14px; padding: 9px 16px; font-weight: 600; text-align: center; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3); }
.notes { position: absolute; top: calc(56px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; width: min(440px, calc(100vw - 32px)); pointer-events: none !important; }
.note { background: var(--glass-strong); border: 1px solid var(--line); border-radius: 12px; padding: 7px 14px; font-size: 13.5px; text-align: center; animation: noteIn 0.35s ease-out; transition: opacity 0.6s; }
.note.bottle { background: rgba(255, 244, 228, 0.95); color: var(--ink); font: italic 500 15px/1.4 ui-serif, Georgia, serif; padding: 10px 16px; }
.note.out { opacity: 0; }
@keyframes noteIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.panel { position: absolute; top: calc(52px + var(--safe-t)); right: 12px; width: min(300px, calc(100vw - 24px)); max-height: calc(100dvh - 130px); overflow-y: auto;
  background: var(--glass-strong); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.panel h2 { font: 600 17px/1.2 ui-serif, Georgia, serif; margin: 0 0 8px; color: #ffe2c4; }
.panel.tray { top: auto; right: auto; left: 12px; bottom: calc(100px + var(--safe-b)); width: auto; display: flex; gap: 6px; flex-wrap: wrap; padding: 8px; }
#lantern-panel { top: auto; bottom: calc(110px + var(--safe-b)); left: 50%; right: auto; transform: translateX(-50%); width: min(360px, calc(100vw - 24px)); }
#lantern-panel input { width: 100%; margin-top: 10px; }
.stack { display: grid; gap: 6px; margin-top: 10px; }
.stack button { text-align: left; border-radius: 12px; }
.stack button[aria-pressed="true"] { border-color: var(--accent); background: rgba(240, 163, 94, 0.18); }
#who-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
#who-list li { display: flex; align-items: center; gap: 8px; padding: 5px 2px; border-bottom: 1px solid rgba(255, 236, 214, 0.06); }
#who-list .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#who-list .ar { color: var(--muted); font-size: 12.5px; }
#who-list button { padding: 3px 10px; font-size: 12.5px; }
.slider { display: grid; gap: 2px; font-size: 13px; color: var(--muted); margin: 6px 0; }
.slider input { padding: 0; accent-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 8px 0; }
.lakebox { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px 0; margin: 10px 0; display: grid; gap: 8px; }
.keys { margin-bottom: 10px; }
.tip { position: absolute; max-width: 240px; background: rgba(255, 244, 228, 0.95); color: var(--ink); border-radius: 12px; padding: 7px 12px; font: italic 500 14px/1.35 ui-serif, Georgia, serif;
  transform: translate(-50%, calc(-100% - 14px)); pointer-events: none !important; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3); }
.tip small { display: block; font: 500 11.5px ui-sans-serif, system-ui, sans-serif; color: #6a5464; margin-top: 2px; }

/* the telescope */
.scope { position: fixed; inset: 0; z-index: 6; background: #000; }
#scope-cv { width: 100%; height: 100%; display: block; }
#scope-close { position: absolute; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); }
.scope-note { position: absolute; top: calc(20px + var(--safe-t)); left: 0; right: 0; text-align: center; color: var(--muted); font: italic 15px ui-serif, Georgia, serif; margin: 0; padding: 0 16px; }

/* phones held upright: the chat tucks behind a button until it is wanted */
@media (max-width: 560px) {
  #station-name { display: none; }
  .where .dot, .where #sky-name { display: none; }
  .chatrow { width: 100%; }
  .chatrow input:not(:focus) { max-width: 140px; }
  .actions button { font-size: 13.5px; padding: 8px 12px; }
}
/* phones held sideways: less height, so smaller chrome */
@media (max-height: 460px) {
  .top { top: calc(6px + var(--safe-t)); }
  .bottom { bottom: calc(6px + var(--safe-b)); flex-direction: row; align-items: flex-end; justify-content: space-between; }
  .actions { max-width: 60%; }
  .chatrow { width: min(320px, 40%); }
  .panel { max-height: calc(100dvh - 70px); top: calc(44px + var(--safe-t)); }
  .card { padding: 14px 18px 10px; }
  .join .lead { display: none; }
  #step { margin: 10px 0 6px; padding: 8px; }
}
@media (prefers-reduced-motion: reduce) { .note { animation: none; } }
