:root {
  --bg: #0b0c0e; --panel: rgba(14, 16, 20, 0.78); --line: rgba(255, 255, 255, 0.1);
  --text: #f2f4f7; --dim: #9aa3af; --red: #e5383b; --gold: #ffc145; --green: #3fb984;
  --radius: 14px; --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); }
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.hidden { display: none !important; }
button { font-family: inherit; color: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* start screen */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(11, 12, 14, 0.35), rgba(11, 12, 14, 0.82)); z-index: 30; }
.start-card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 22px;
  padding: 28px; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); text-align: center; }
.start-logo { width: 84px; height: 84px; border-radius: 50%; }
.start-card h1 { margin: 10px 0 6px; font-size: 34px; letter-spacing: -0.02em; }
.start-card h1 span { color: var(--red); }
.tag { color: var(--dim); margin: 0 0 20px; line-height: 1.45; }
.start-card label { display: block; text-align: left; font-size: 12px; color: var(--dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.08em; }
.start-card input, .field input, .field select { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06); color: var(--text); font-size: 16px; outline: none; }
.start-card input:focus, .field input:focus { border-color: var(--red); }
.btn { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.07); border-radius: 12px; padding: 11px 16px; font-size: 15px; font-weight: 600; }
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.13); }
.btn.primary { background: var(--red); border-color: transparent; color: #fff; }
.btn.primary:hover:not(:disabled) { background: #f04a4d; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 7px 11px; font-size: 13px; }
#enterBtn { width: 100%; margin-top: 14px; padding: 14px; font-size: 17px; }
.start-keys { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 18px; }
.start-keys span { font-size: 12px; color: var(--dim); background: rgba(255, 255, 255, 0.05); border-radius: 8px; padding: 5px 8px; }
.start-keys b { color: var(--text); margin-right: 4px; }
.fine { font-size: 12px; color: var(--dim); margin: 16px 0 0; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
#toasts { pointer-events: none; }
#topleft { position: absolute; top: 14px; left: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; max-width: calc(100vw - 250px); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 6px 12px 6px 6px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.brand img { width: 28px; height: 28px; border-radius: 50%; }
.pill { display: flex; align-items: center; gap: 7px; padding: 8px 13px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; font-size: 14px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); white-space: nowrap; }
.pill small { color: var(--dim); }
.pill.btnlike:hover { border-color: var(--red); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); display: inline-block; }
.dot.gold { background: var(--gold); } .dot.red { background: var(--red); } .dot.green { background: var(--green); }
#topright { position: absolute; top: 14px; right: 14px; text-align: right; }
#minimap { width: 200px; height: 200px; border-radius: 50%; border: 2px solid var(--line); background: #14171c; display: block; }
#place { margin-top: 8px; font-weight: 600; font-size: 14px; text-shadow: 0 1px 4px #000; text-align: center; }
#clock { font-size: 12px; color: var(--dim); text-align: center; text-shadow: 0 1px 4px #000; }
#eventBar { position: absolute; top: 112px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--red);
  border-radius: 999px; padding: 9px 18px; font-size: 14px; font-weight: 600; backdrop-filter: blur(12px); max-width: min(560px, 70vw); text-align: center; }
#prompt { position: absolute; bottom: 168px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 16px; font-size: 15px; backdrop-filter: blur(12px); text-align: center; max-width: 80vw; }
#prompt kbd { background: var(--red); color: #fff; border-radius: 6px; padding: 2px 8px; font-family: inherit; font-weight: 700; margin-right: 8px; }
#prompt small { display: block; color: var(--dim); margin-top: 3px; }
#speedo { position: absolute; bottom: 96px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 8px 18px; text-align: center; }
#speedo b { font-size: 28px; font-variant-numeric: tabular-nums; } #speedo small { color: var(--dim); margin-left: 6px; }
#buffs { position: absolute; left: 14px; top: 64px; display: flex; flex-direction: column; gap: 6px; }
#buffs div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 5px 10px; font-size: 12px; }
#chat { position: absolute; left: 14px; bottom: 14px; width: min(360px, 60vw); }
#chatLog { max-height: 170px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; margin-bottom: 8px;
  font-size: 13.5px; text-shadow: 0 1px 3px #000, 0 0 2px #000; }
#chatLog div { line-height: 1.35; overflow-wrap: anywhere; } #chatLog b { color: var(--gold); font-weight: 600; } #chatLog .sys { color: var(--dim); font-style: italic; }
#chatInput { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 14px; outline: none; }
#chatInput:focus { border-color: var(--red); }
.chat-row { display: flex; gap: 6px; } .chat-row #chatInput { flex: 1; min-width: 0; }
.chat-toggle { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 0 11px; font-size: 12.5px; color: var(--dim); white-space: nowrap; }
.chat-toggle:hover { color: var(--text); } .chat-toggle.new { border-color: var(--gold); color: var(--gold); }
#chat.min { width: auto; } #chat.min #chatLog, #chat.min #chatInput { display: none; } #chat.min .chat-toggle { padding: 9px 13px; font-size: 13.5px; }
#dock { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 8px; }
.dockbtn { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; font-size: 20px; display: flex;
  flex-direction: column; align-items: center; min-width: 62px; backdrop-filter: blur(12px); }
.dockbtn small { font-size: 10.5px; color: var(--dim); margin-top: 2px; } .dockbtn.on { border-color: var(--green); } .dockbtn.talk { box-shadow: 0 0 0 3px rgba(63, 185, 132, 0.5); }
#toasts { position: fixed; z-index: 45; top: 164px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(520px, 90vw); pointer-events: none; }
.toast { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; font-size: 14px; backdrop-filter: blur(12px);
  animation: pop 0.25s ease-out; text-align: center; }
.toast.good { border-color: var(--green); } .toast.bad { border-color: var(--red); } .toast.event { border-color: var(--gold); }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* phone */
#phone { position: fixed; right: 14px; bottom: 96px; width: min(400px, calc(100vw - 28px)); height: min(600px, calc(100vh - 130px)); z-index: 20;
  background: rgba(14, 16, 20, 0.94); border: 1px solid var(--line); border-radius: 22px; display: flex; flex-direction: column; overflow: hidden;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.phone-head { display: flex; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); gap: 6px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: transparent; padding: 7px 10px; border-radius: 9px; font-size: 13px; color: var(--dim); white-space: nowrap; font-weight: 600; }
.tabs button.on { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.x { border: 0; background: transparent; font-size: 16px; padding: 6px 9px; border-radius: 8px; } .x:hover { background: rgba(255, 255, 255, 0.1); }
.phone-body { flex: 1; overflow-y: auto; padding: 14px; }
.phone-body h3 { margin: 14px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); }
.phone-body h3:first-child { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.card { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: 13px; text-align: center; }
button.card:hover { border-color: var(--red); } .card.on { border-color: var(--green); background: rgba(63, 185, 132, 0.12); }
.card .sw { width: 30px; height: 30px; border-radius: 50%; margin: 0 auto 6px; border: 2px solid rgba(255, 255, 255, 0.25); display: grid; place-items: center; font-size: 15px; }
.card small { display: block; color: var(--dim); margin-top: 2px; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; font-size: 14px; }
.row .grow { flex: 1; min-width: 0; } .row small { display: block; color: var(--dim); }
.muted { color: var(--dim); font-size: 13px; line-height: 1.5; }
.field { margin-bottom: 12px; text-align: left; } .field label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 5px; }
.field input[type="color"] { padding: 4px; height: 42px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* modal */
#modalWrap { position: fixed; inset: 0; background: rgba(5, 6, 8, 0.6); display: grid; place-items: center; z-index: 40; padding: 16px; }
#modal { width: min(480px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: rgba(16, 18, 23, 0.97); border: 1px solid var(--line);
  border-radius: 20px; padding: 22px; }
#modal h2 { margin: 0 0 6px; font-size: 21px; } #modal p { color: var(--dim); line-height: 1.5; margin: 6px 0 14px; }
#modal .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.paymethod { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; margin-bottom: 8px; padding: 12px 14px; }
.paymethod b { display: block; } .paymethod small { color: var(--dim); font-weight: 400; } .paymethod .ico { font-size: 22px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; overflow-wrap: anywhere; }
#landMap { width: 100%; aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--line); background: #14171c; cursor: crosshair; display: block; }
#modal.wide { width: min(860px, 100%); }
#frameWrap { position: fixed; inset: 0; z-index: 38; background: #0b0c0e; display: flex; flex-direction: column; }
.fw-head { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: rgba(14, 16, 20, 0.98); }
.fw-head .grow { flex: 1; min-width: 0; } .fw-head b { font-size: 15px; margin-right: 10px; } .fw-head small { color: var(--dim); font-size: 12.5px; }
#fwFrame { flex: 1; width: 100%; border: 0; background: #12151d; }
#bigmap { position: fixed; inset: 14px; z-index: 35; background: rgba(12, 14, 18, 0.97); border: 1px solid var(--line); border-radius: 22px; display: flex;
  flex-direction: column; overflow: hidden; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.bm-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bm-head > b { font-size: 17px; }
.bm-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--dim); flex: 1; }
.bm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.bm-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bm-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 0; }
.bm-canvas { position: relative; min-height: 0; min-width: 0; }
#bmCanvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.bm-side { border-left: 1px solid var(--line); }
.bm-side h2 { margin: 0 0 4px; font-size: 20px; }
.bm-side .tag2 { color: var(--dim); font-size: 13px; line-height: 1.5; margin-bottom: 12px; }
.bm-side .about { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.45; margin: 10px 0;
  white-space: pre-wrap; overflow-wrap: anywhere; }
.bm-side .btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.bm-side a.btn { text-decoration: none; color: var(--text); }
.field textarea { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); color: var(--text);
  font: inherit; font-size: 15px; outline: none; resize: vertical; }
@media (max-width: 760px) { .bm-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; } .bm-side { border-left: 0; border-top: 1px solid var(--line); max-height: 44vh; } .bm-legend { display: none; } }
.studio { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.studio-view canvas { width: 100%; aspect-ratio: 640 / 520; display: block; border-radius: 14px; border: 1px solid var(--line);
  background: radial-gradient(ellipse at 50% 35%, #2a3140, #101216 75%); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips button { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; }
.chips button.on { background: var(--red); border-color: transparent; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 0 0 12px; cursor: pointer; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.field select { appearance: none; }
@media (max-width: 720px) { .studio { grid-template-columns: 1fr; } }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.22s; z-index: 25; }
#fade.on { opacity: 1; }

@media (max-width: 720px) {
  #minimap { width: 120px; height: 120px; } #topleft { max-width: calc(100vw - 160px); } .brand span { display: none; }
  #chat { width: 56vw; left: 8px; bottom: 76px; }
  #dock { left: 8px; right: 8px; bottom: 8px; gap: 4px; } .dockbtn { flex: 1; min-width: 0; padding: 6px 2px; font-size: 18px; }
  .dockbtn small { font-size: 9px; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
}

/* tower rooms, crew sheets, light shows */
#flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 12; mix-blend-mode: screen; }
#modal .mh { margin: 14px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); } #modal .mh:first-child { margin-top: 0; }
#modal .btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.floors { display: flex; flex-direction: column; gap: 6px; }
.floor { display: grid; grid-template-columns: 34px 1fr 1fr; gap: 6px; align-items: stretch; }
.floor .fl { display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--dim); background: rgba(255, 255, 255, 0.04); border-radius: 9px; }
.unit { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255, 255, 255, 0.04); font-size: 13.5px; min-width: 0; }
.unit > div { min-width: 0; } .unit b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .unit small { display: block; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit > span { display: flex; gap: 6px; flex-shrink: 0; }
.unit.free { border-color: rgba(63, 185, 132, 0.35); } .unit.mine { border-color: var(--gold); background: rgba(255, 193, 69, 0.08); } .unit.taken { border-color: rgba(76, 141, 246, 0.4); }
select.mini { background: rgba(255, 255, 255, 0.06); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; font-size: 13px; }
.board { margin-bottom: 10px; } .board .row { padding: 7px 10px; margin-bottom: 4px; } .board .rank { width: 22px; color: var(--dim); font-weight: 700; }
@media (max-width: 720px) { .floor { grid-template-columns: 28px 1fr; } .floor .unit:last-child { grid-column: 2; } #modal .two { grid-template-columns: 1fr; } }

/* controllers, trackpads and touch screens */
canvas#view { touch-action: none; }
#prompt { cursor: pointer; }
body[data-input="pad"] .padfocus { outline: 3px solid var(--gold) !important; outline-offset: 2px; box-shadow: 0 0 0 7px rgba(255, 193, 69, 0.2); }
#hud > #touchUI { pointer-events: none; display: none; } body[data-input="touch"] #hud > #touchUI { display: block; }
#tStick { position: fixed; left: 92px; top: calc(100% - 196px); width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.05); opacity: 0.55; }
#tStick.live { opacity: 1; background: rgba(255, 255, 255, 0.09); }
#tStick i { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(255, 255, 255, 0.42); }
#tBtns { position: absolute; right: 12px; bottom: 86px; display: grid; grid-template-columns: repeat(3, 60px); grid-template-areas: "t b e" ". f u" ". d j"; gap: 8px; justify-items: center; align-items: center; }
.tb[data-t="KeyT"] { grid-area: t; } .tb[data-t="KeyB"] { grid-area: b; } .tb[data-t="emote"] { grid-area: e; } .tb[data-t="KeyF"] { grid-area: f; } .tb[data-t="KeyE"] { grid-area: u; } .tb[data-t="down"] { grid-area: d; } .tb[data-t="jump"] { grid-area: j; }
#tEmotes { position: absolute; right: 12px; bottom: 282px; display: flex; gap: 8px; }
.tb { pointer-events: auto; width: 58px; height: 58px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); font-size: 24px; line-height: 1; padding: 0;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); touch-action: none; user-select: none; -webkit-user-select: none; }
.tb.sm { width: 46px; height: 46px; font-size: 20px; } .tb.big { width: 64px; height: 64px; font-size: 28px; }
.tb.held { background: rgba(229, 56, 59, 0.65); } .tb.off { visibility: hidden; pointer-events: none; }
body[data-input="touch"] #prompt { bottom: 296px; }
/* a phone held sideways: everything shrinks to leave the view clear */
@media (orientation: landscape) and (max-height: 520px) {
  #minimap { width: 104px; height: 104px; } #clock { display: none; } #topleft { max-width: calc(100vw - 150px); }
  #dock { gap: 6px; bottom: 8px; right: 8px; } .dockbtn { min-width: 46px; padding: 7px 8px; font-size: 18px; } .dockbtn small { display: none; }
  #chat { bottom: 8px; left: 8px; } #prompt { bottom: 62px; }
  #phone { bottom: 58px; height: calc(100vh - 68px); }
  #tBtns { bottom: 60px; grid-template-columns: repeat(4, 60px); grid-template-areas: "t b e u" ". f d j"; }
  #tEmotes { bottom: 138px; right: 290px; } #tStick { top: calc(100% - 128px); }
  body[data-input="touch"] #prompt { bottom: 62px; max-width: 34vw; font-size: 13.5px; padding: 8px 12px; }
}

/* buttons-and-keys sheet, and the on-screen keyboard for controllers */
.row.tight { padding: 6px 10px; margin-bottom: 4px; font-size: 13.5px; } .row.tight .btn { min-width: 86px; }
#osk { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 60; width: min(660px, calc(100vw - 16px)); background: rgba(16, 18, 23, 0.97); border: 1px solid var(--line);
  border-radius: 18px; padding: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55); }
.osk-text { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; }
.osk-text small { display: block; color: var(--dim); font-size: 11.5px; margin-bottom: 2px; } .osk-text div { font-size: 17px; min-height: 24px; white-space: pre-wrap; overflow-wrap: anywhere; }
.osk-text i { display: inline-block; width: 2px; height: 18px; background: var(--gold); vertical-align: text-bottom; margin-left: 1px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.osk-row { display: flex; gap: 5px; margin-bottom: 5px; }
.osk-key { flex: 1; min-width: 0; height: 42px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.07); font-size: 16px; font-weight: 600; padding: 0; }
.osk-key.wide { font-size: 12.5px; } .osk-key.on { outline: 3px solid var(--gold); background: rgba(255, 193, 69, 0.2); } .osk-key.lit { background: var(--red); }
.osk-hint { color: var(--dim); font-size: 12px; text-align: center; margin-top: 6px; }
