:root {
  --gold: #ffd23f; --navy: #1b2a4d; --red: #e0392b; --cyan: #3ee6ff; --green: #4ade80; --magenta: #ff4fa3;
  --bg: #07090f; --panel: rgba(10, 14, 26, 0.94); --line: #2b3a5c; --text: #eef2fb; --muted: #98a3bf;
  --font: 'Press Start 2P', 'Courier New', Courier, monospace;
  --sat: env(safe-area-inset-top, 0px); --sar: env(safe-area-inset-right, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; }
html { height: 100%; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
html, body {
  margin: 0; padding: 0; width: 100%; background: var(--bg); color: var(--text); font-family: var(--font);
  overflow: hidden; touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
body { position: fixed; inset: 0; height: 100%; height: 100dvh; }
button, input { -webkit-touch-callout: none; font-family: inherit; }
input { -webkit-user-select: text; user-select: text; }
.hidden { display: none !important; }
#safeProbe { position: fixed; left: 0; top: 0; width: 0; height: 0; visibility: hidden; pointer-events: none; padding: var(--sat) var(--sar) var(--sab) var(--sal); }
.kbd-only, .touch-only { display: none; }
body.is-desktop .kbd-only { display: block; }
body.is-touch .touch-only { display: block; }
body.is-desktop small.kbd-only { display: inline-block; }

#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; background: #05070f; }
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 3; background: #fff; opacity: 0; transition: opacity .12s; }
#flash.on { opacity: .4; }
#flash.red { background: var(--red); }

/* ---- HUD */
#hud { position: fixed; inset: 0; z-index: 4; pointer-events: none; font-size: clamp(8px, 2vmin, 11px); }
#taskPanel { position: absolute; left: calc(8px + var(--sal)); top: calc(48px + var(--sat)); width: 230px; max-width: 42vw; pointer-events: none; }
#taskBarWrap { position: relative; height: 16px; background: rgba(0,0,0,.6); border: 2px solid var(--line); border-radius: 3px; overflow: hidden; }
#taskBar { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--cyan)); transition: width .25s; }
#taskBarTxt { position: absolute; left: 0; right: 0; top: 0; line-height: 12px; text-align: center; font-size: 7px; color: #fff; text-shadow: 1px 1px 0 #000; letter-spacing: 1px; }
#taskList { margin-top: 6px; background: rgba(5,8,16,.74); border: 2px solid var(--line); border-radius: 4px; padding: 6px 8px; line-height: 1.8; font-size: .85em; max-height: calc(100dvh - 240px); overflow: hidden; }
#taskList div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
#taskList div.done { color: var(--green); text-decoration: line-through; }
#taskList div.fake { color: #ff9a8f; }
#taskList div.cur { color: var(--gold); }
#taskList .hdr { color: var(--muted); font-size: .8em; letter-spacing: 1px; }
#taskToggle { display: none; pointer-events: auto; font: inherit; font-size: 8px; margin-top: 4px; background: rgba(5,8,16,.8); border: 2px solid var(--line); color: var(--text); border-radius: 4px; padding: 6px 8px; }
body.compact #taskPanel { width: 170px; }
body.is-touch #taskPanel { top: calc(58px + var(--sat)); }
body.compact #taskList { display: none; max-height: 150px; font-size: .8em; }
body.compact #taskPanel.open #taskList { display: block; }
body.compact #taskToggle { display: inline-block; }
#roomTag { position: absolute; left: 50%; transform: translateX(-50%); top: calc(10px + var(--sat)); color: var(--cyan); letter-spacing: 2px; text-shadow: 2px 2px 0 #000; white-space: nowrap; font-size: 1.1em; }
body.compact #roomTag { top: calc(60px + var(--sat)); font-size: 1em; }
#sabBanner { position: absolute; left: 50%; transform: translateX(-50%); top: calc(50px + var(--sat)); background: rgba(40,5,5,.85); border: 2px solid var(--red); color: #ff6b5e; border-radius: 4px; padding: 7px 12px; letter-spacing: 1px; white-space: nowrap; animation: blink 1s steps(2) infinite; font-size: 1.1em; text-align: center; }
body.compact #sabBanner { top: calc(84px + var(--sat)); }
@keyframes blink { 50% { opacity: .55; } }
#tip { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--sab)); background: rgba(5,8,16,.8); border: 2px solid var(--gold); color: var(--gold); border-radius: 4px; padding: 7px 12px; letter-spacing: 1px; white-space: nowrap; max-width: calc(100% - 220px); overflow: hidden; text-overflow: ellipsis; }
body.is-touch #tip { bottom: auto; top: calc(112px + var(--sat)); max-width: calc(100% - 40px); }
#specBar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(12px + var(--sab)); display: flex; gap: 6px; align-items: center; pointer-events: auto; background: rgba(5,8,16,.8); border: 2px solid var(--line); border-radius: 4px; padding: 4px; }
#specBar button { font: inherit; font-size: 10px; min-width: 36px; min-height: 36px; background: #121a2c; color: var(--text); border: 2px solid var(--line); border-radius: 4px; cursor: pointer; }
#specBar span { padding: 0 6px; color: var(--gold); white-space: nowrap; }
#ventRow { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(110px + var(--sab)); display: flex; gap: 6px; pointer-events: auto; }
#ventRow button { font: inherit; font-size: 9px; min-height: 40px; padding: 0 10px; background: rgba(20,30,50,.95); color: var(--cyan); border: 2px solid var(--cyan); border-radius: 4px; cursor: pointer; letter-spacing: 1px; }

/* ---- controls */
#controls { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#joyZone { position: absolute; left: 0; bottom: 0; width: 45%; height: 70%; pointer-events: auto; touch-action: none; display: none; }
body.is-touch #joyZone { display: block; }
#joyBase { position: absolute; width: 110px; height: 110px; border-radius: 50%; border: 3px solid rgba(255,255,255,.35); background: rgba(5,8,16,.35); display: none; transform: translate(-50%, -50%); }
#joyBase.on { display: block; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; border-radius: 50%; background: rgba(255,210,63,.85); transform: translate(-50%, -50%); }
#abtns { position: absolute; right: calc(10px + var(--sar)); bottom: calc(10px + var(--sab)); display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; width: 190px; pointer-events: none; }
.abtn { pointer-events: auto; position: relative; font: inherit; font-size: 10px; letter-spacing: 1px; min-height: 56px; border-radius: 6px; border: 3px solid var(--line); background: rgba(5,8,16,.82); color: var(--text); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; overflow: hidden; }
.abtn small { font-size: 7px; color: var(--muted); }
.abtn.use { grid-column: 2; border-color: var(--gold); color: var(--gold); min-height: 84px; }
.abtn.report { border-color: var(--cyan); color: var(--cyan); }
.abtn.kill { border-color: var(--red); color: #ff6b5e; }
.abtn.vent { border-color: var(--muted); color: var(--muted); }
.abtn.sab { border-color: var(--magenta); color: var(--magenta); }
.abtn.sprint { border-color: var(--green); color: var(--green); }
#modeBar { position: absolute; left: 50%; transform: translateX(-50%); top: calc(34px + var(--sat)); background: rgba(5,8,16,.74); border: 2px solid var(--line); border-radius: 4px; padding: 5px 10px; letter-spacing: 1px; white-space: nowrap; color: var(--text); font-size: .95em; }
body.compact #modeBar { top: calc(80px + var(--sat)); font-size: .85em; }
body.compact #sabBanner { top: calc(108px + var(--sat)); }
.modehelp { margin: 6px 0 2px; padding: 8px; border: 2px solid var(--line); border-radius: 4px; color: var(--muted); font-size: .7em; line-height: 1.7; text-align: left; }
.modehelp b { color: var(--gold); font-weight: normal; }
.abtn[disabled] { opacity: .35; cursor: default; }
.abtn.ready:not([disabled]) { box-shadow: 0 0 0 3px rgba(255,255,255,.12), 0 0 18px rgba(255,210,63,.25); }
.abtn:not([disabled]):active { transform: translateY(2px); }
#useRing { position: absolute; left: 0; bottom: 0; height: 5px; width: 0; background: var(--green); }
body.compact #abtns { width: 160px; gap: 6px; }
body.compact .abtn { min-height: 48px; font-size: 9px; }
body.compact .abtn.use { min-height: 70px; }
body.is-touch .abtn { min-height: 56px; }

/* ---- task modal / sabotage menu */
#taskModal, #sabMenu { position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; background: rgba(4,7,14,.6); padding: calc(50px + var(--sat)) 12px calc(10px + var(--sab)); }
.tbox { background: var(--panel); border: 3px solid var(--gold); border-radius: 6px; padding: 8px; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 20px 50px rgba(0,0,0,.6); overflow: auto; pointer-events: auto; }
.thead { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11px; color: var(--gold); letter-spacing: 1px; }
.thead button { font: inherit; font-size: 11px; width: 36px; height: 36px; background: #121a2c; color: var(--text); border: 2px solid var(--line); border-radius: 4px; cursor: pointer; }
#taskHelp { font-size: 8px; color: var(--muted); line-height: 1.6; max-width: 400px; }
#taskCanvas { display: block; width: min(400px, calc(100vw - 50px), calc((100dvh - 150px) * 400 / 280)); aspect-ratio: 400 / 280; touch-action: none; border: 2px solid var(--line); background: #0d1322; cursor: pointer; image-rendering: auto; }
#sabBtns, #doorBtns { display: flex; flex-wrap: wrap; gap: 6px; max-width: 520px; }
#sabBtns button, #doorBtns button { font: inherit; font-size: 9px; min-height: 44px; padding: 0 10px; background: #121a2c; color: var(--text); border: 2px solid var(--line); border-radius: 4px; cursor: pointer; letter-spacing: 1px; flex: 1 1 140px; }
#sabBtns button { border-color: var(--magenta); color: var(--magenta); }
#sabBtns button[disabled], #doorBtns button[disabled] { opacity: .4; cursor: default; }
.sabsub { font-size: 8px; color: var(--muted); letter-spacing: 1px; margin-top: 4px; }

/* ---- chrome */
#chrome { position: fixed; left: 0; right: 0; top: 0; z-index: 9; display: flex; align-items: flex-start; gap: 8px; padding: calc(6px + var(--sat)) calc(8px + var(--sar)) 0 calc(8px + var(--sal)); pointer-events: none; }
#chrome .spacer { flex: 1; }
.cornerbtn { pointer-events: auto; height: 36px; min-width: 36px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: rgba(5,8,16,.8); border: 2px solid var(--line); border-radius: 4px; color: var(--text); text-decoration: none; font: inherit; font-size: 10px; letter-spacing: 1px; cursor: pointer; text-transform: uppercase; white-space: nowrap; }
.cornerbtn:hover { border-color: var(--gold); color: var(--gold); }
body.is-touch .cornerbtn { height: 44px; }
body.compact .cornerbtn { padding: 0 8px; font-size: 9px; }
body.compact #backBtn { width: 44px; padding: 0; font-size: 13px; }

/* ---- menus */
#overlay { position: fixed; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center; padding: calc(54px + var(--sat)) calc(12px + var(--sar)) calc(12px + var(--sab)) calc(12px + var(--sal)); background: rgba(4,7,14,.55); font-size: clamp(9px, 2.2vmin, 13px); pointer-events: auto; }
#overlay.hidden { display: none; }
#overlay.clear { background: transparent; pointer-events: none; }
.card { background: var(--panel); border: 2px solid var(--line); border-radius: 6px; padding: 1.2em 1.4em; max-width: 760px; width: 100%; max-height: 100%; overflow-y: auto; touch-action: pan-y; pointer-events: auto; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.6); }
.card.wide { max-width: 960px; }
.logo { font-size: 2.6em; line-height: 1.1; color: var(--gold); text-shadow: 3px 3px 0 #7a1a12, 6px 6px 0 #000; letter-spacing: 2px; }
.logo span { color: var(--red); }
.sub { color: var(--cyan); letter-spacing: 2px; font-size: .75em; margin: 10px 0 14px; }
.sub2 { color: var(--muted); font-size: .8em; margin: 6px 0 12px; letter-spacing: 1px; line-height: 1.7; }
.h2 { font-size: 1.5em; color: var(--gold); letter-spacing: 2px; margin-bottom: 6px; line-height: 1.4; }
.h3 { font-size: .8em; color: var(--muted); letter-spacing: 2px; margin: 10px 0 6px; text-align: left; }
.lobbyGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; text-align: left; }
.lcol { min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.row .lbl { color: var(--muted); font-size: .75em; letter-spacing: 1px; width: 70px; flex: 0 0 auto; }
#nameInput, #chatInput, #edName { font: inherit; font-size: .9em; background: #0b101c; color: var(--text); border: 2px solid var(--line); border-radius: 4px; padding: 8px; min-width: 0; flex: 1; text-transform: uppercase; }
#nameInput:focus, #chatInput:focus, #edName:focus { outline: none; border-color: var(--gold); }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; }
.swatches button { width: 26px; height: 26px; border: 2px solid #000; border-radius: 4px; cursor: pointer; padding: 0; }
.swatches button.on { outline: 3px solid var(--gold); }
.swatches button[disabled] { opacity: .25; cursor: default; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.seg button { font: inherit; font-size: .7em; min-height: 30px; padding: 4px 8px; background: #121a2c; color: var(--muted); border: 2px solid var(--line); border-radius: 4px; cursor: pointer; letter-spacing: 1px; }
.seg button.on { color: var(--gold); border-color: var(--gold); }
#previewCanvas { width: 96px; height: 96px; image-rendering: pixelated; display: block; margin: 6px auto; background: #0b101c; border: 2px solid var(--line); border-radius: 4px; }
.maplist { display: flex; flex-direction: column; gap: 4px; max-height: 150px; overflow-y: auto; touch-action: pan-y; }
.maplist button { font: inherit; font-size: .75em; text-align: left; min-height: 36px; padding: 6px 10px; background: #121a2c; color: var(--text); border: 2px solid var(--line); border-radius: 4px; cursor: pointer; letter-spacing: 1px; display: flex; justify-content: space-between; gap: 8px; }
.maplist button.on { border-color: var(--gold); color: var(--gold); }
.maplist button small { color: var(--muted); font-size: .8em; }
.srow { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 4px 0; font-size: .75em; }
.srow .lbl { color: var(--muted); letter-spacing: 1px; flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srow .ctl { display: flex; align-items: center; gap: 4px; }
.srow .ctl button { font: inherit; font-size: 1em; width: 30px; height: 30px; background: #121a2c; color: var(--text); border: 2px solid var(--line); border-radius: 4px; cursor: pointer; }
.srow .ctl .val { min-width: 74px; text-align: center; color: var(--gold); }
.srow .ctl button.tog { width: auto; min-width: 74px; padding: 0 8px; color: var(--gold); font-size: .9em; }
.modes { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 12px 0; }
.modes.small { margin: 6px 0; }
.mbtn { flex: 1 1 150px; min-height: 52px; background: #121a2c; color: var(--text); border: 2px solid var(--line); border-radius: 4px; cursor: pointer; font-size: .95em; letter-spacing: 1px; padding: 10px 8px; line-height: 1.5; }
.modes.small .mbtn { min-height: 40px; font-size: .75em; flex: 0 1 auto; }
.mbtn small { display: block; font-size: .7em; color: var(--muted); margin-top: 4px; }
.mbtn:hover { border-color: var(--gold); color: var(--gold); }
.mbtn.primary { background: var(--gold); color: #1a1200; border-color: var(--gold); }
.mbtn.primary small { color: #5a4300; }
.howto { text-align: left; font-size: .75em; line-height: 1.8; color: var(--text); border-top: 2px solid var(--line); padding-top: 10px; }
.howto .h { color: var(--gold); letter-spacing: 2px; margin-bottom: 4px; }
.howto b { color: var(--cyan); font-weight: normal; }
.howto .muted { color: var(--muted); }
body.is-touch .mbtn, body.is-touch .seg button, body.is-touch .srow .ctl button { min-height: 44px; }
body.is-touch .srow .ctl button { height: 44px; width: 44px; }
body.compact .card { padding: .9em 1em; }
body.compact .logo { font-size: 1.8em; }
body.compact .howto { font-size: .7em; line-height: 1.7; }
body.compact .lobbyGrid { gap: 10px; }
@media (max-width: 640px) { .lobbyGrid { grid-template-columns: 1fr; } }

/* reveal */
#revealCard { background: rgba(5,8,16,.9); }
#revealCard.imp .h2 { color: var(--red); text-shadow: 0 0 20px rgba(224,57,43,.6); }
#revealCard.crew .h2 { color: var(--cyan); text-shadow: 0 0 20px rgba(62,230,255,.5); }
#revealBody { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; font-size: .75em; color: var(--muted); line-height: 1.8; }
#revealBody canvas { image-rendering: pixelated; width: 48px; height: 48px; }
.rev { display: flex; flex-direction: column; align-items: center; gap: 2px; }

/* meeting */
#meetingCard { padding: .8em 1em; text-align: left; display: flex; flex-direction: column; gap: 8px; max-height: 100%; }
.mhead { display: flex; justify-content: space-between; align-items: center; color: var(--gold); letter-spacing: 2px; font-size: .95em; }
#meetTimer { color: var(--text); font-size: 1.3em; }
#meetTimer.warn { color: #ff5a4a; animation: blink 1s steps(2) infinite; }
.mbody { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; min-height: 0; flex: 1; }
#voteGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-content: start; overflow-y: auto; touch-action: pan-y; }
.vp { position: relative; display: flex; align-items: center; gap: 6px; padding: 6px; border: 2px solid var(--line); border-radius: 4px; background: #0e1526; min-height: 48px; font-size: .75em; cursor: pointer; }
.vp canvas { width: 32px; height: 32px; image-rendering: pixelated; flex: 0 0 auto; }
.vp .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vp .tag { font-size: .7em; color: var(--muted); display: block; margin-top: 3px; }
.vp.dead { opacity: .45; cursor: default; }
.vp.dead .nm { text-decoration: line-through; }
.vp.me { border-color: var(--gold); }
.vp.caller::after { content: 'CALLED'; position: absolute; right: 4px; top: 3px; font-size: 6px; background: var(--cyan); color: #04202a; padding: 2px 4px; border-radius: 3px; }
.vp.picked { border-color: var(--red); background: #2a0e0e; }
.vp .voted { position: absolute; right: 6px; bottom: 4px; color: var(--green); font-size: .9em; }
.vp .dots { display: flex; gap: 3px; flex-wrap: wrap; max-width: 90px; justify-content: flex-end; }
.vp .dots i { width: 10px; height: 10px; border: 1px solid #000; display: inline-block; border-radius: 2px; }
.vp.confirm { outline: 3px solid var(--red); }
.chatcol { display: flex; flex-direction: column; min-height: 0; border: 2px solid var(--line); border-radius: 4px; background: #0b101c; }
#chatLog { flex: 1; overflow-y: auto; touch-action: pan-y; padding: 6px; font-size: .7em; line-height: 1.7; min-height: 120px; max-height: 40dvh; }
#chatLog div { word-break: break-word; }
#chatLog b { font-weight: normal; }
#chatLog .sys { color: var(--muted); font-style: italic; }
#chatLog .ghost { opacity: .6; }
.chatin { display: flex; gap: 4px; padding: 4px; border-top: 2px solid var(--line); }
.chatin button { font: inherit; font-size: .75em; min-width: 50px; background: var(--gold); color: #1a1200; border: 2px solid var(--gold); border-radius: 4px; cursor: pointer; }
.mfoot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mfoot .mbtn { flex: 0 0 auto; min-height: 40px; font-size: .8em; }
#voteStatus { color: var(--muted); font-size: .75em; letter-spacing: 1px; }
@media (max-width: 760px) { .mbody { grid-template-columns: 1fr; } #chatLog { min-height: 70px; max-height: 24dvh; } }
body.compact #meetingCard { padding: .5em .7em; }
body.compact .vp { min-height: 40px; padding: 4px; }
body.compact .vp canvas { width: 24px; height: 24px; }

/* eject / end */
#ejectCard { background: rgba(2,3,8,.92); border-color: #000; }
#ejectCanvas { width: 100%; max-width: 600px; aspect-ratio: 3 / 1; display: block; margin: 0 auto 10px; image-rendering: pixelated; }
#endCard.crew .h2 { color: var(--cyan); }
#endCard.imp .h2 { color: var(--red); }
#endRoles { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0; }
#endRoles .rp { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .65em; color: var(--muted); width: 72px; }
#endRoles .rp canvas { width: 40px; height: 40px; image-rendering: pixelated; }
#endRoles .rp.imp { color: #ff6b5e; }
#endRoles .rp .n { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 72px; }

/* ---- editor */
#editor { position: fixed; inset: 0; z-index: 7; background: #07090f; display: flex; flex-direction: column; padding-top: calc(var(--sat)); font-size: 9px; }
#edTop { display: flex; gap: 6px; align-items: center; padding: 6px calc(130px + var(--sar)) 6px calc(100px + var(--sal)); flex-wrap: wrap; border-bottom: 2px solid var(--line); background: #0b101c; }
body.is-touch #edTop { padding-right: calc(150px + var(--sar)); }
#edName { flex: 1 1 120px; max-width: 220px; font-size: 9px; padding: 8px; }
.ebtn { font: inherit; font-size: 9px; min-height: 36px; padding: 0 10px; background: #121a2c; color: var(--text); border: 2px solid var(--line); border-radius: 4px; cursor: pointer; letter-spacing: 1px; }
.ebtn.gold { background: var(--gold); color: #1a1200; border-color: var(--gold); }
.ebtn.on { border-color: var(--gold); color: var(--gold); }
#edMain { flex: 1; display: flex; min-height: 0; }
#edTools { display: flex; flex-direction: column; gap: 4px; padding: 6px calc(4px) 6px calc(6px + var(--sal)); width: 96px; overflow-y: auto; touch-action: pan-y; border-right: 2px solid var(--line); background: #0b101c; }
#edTools button { font: inherit; font-size: 8px; min-height: 34px; padding: 4px; background: #121a2c; color: var(--text); border: 2px solid var(--line); border-radius: 4px; cursor: pointer; letter-spacing: 1px; line-height: 1.3; }
#edTools button.on { border-color: var(--gold); color: var(--gold); }
#edCanvas { flex: 1; min-width: 0; display: block; touch-action: none; background: #05070f; cursor: crosshair; }
#edSide { width: 200px; padding: 8px calc(8px + var(--sar)) 8px 8px; border-left: 2px solid var(--line); background: #0b101c; overflow-y: auto; touch-action: pan-y; display: flex; flex-direction: column; gap: 8px; }
#edToolHelp { color: var(--muted); line-height: 1.7; font-size: 8px; }
#edOpts { display: flex; flex-direction: column; gap: 4px; }
#edOpts button, #edOpts select, #edOpts input { font: inherit; font-size: 8px; min-height: 32px; padding: 4px 6px; background: #121a2c; color: var(--text); border: 2px solid var(--line); border-radius: 4px; cursor: pointer; text-align: left; }
#edOpts button.on { border-color: var(--gold); color: var(--gold); }
#edOpts .lbl { color: var(--muted); font-size: 7px; letter-spacing: 1px; margin-top: 4px; line-height: 1.6; }
#edStatus { font-size: 8px; line-height: 1.7; }
#edStatus .err { color: #ff6b5e; }
#edStatus .warn { color: var(--gold); }
#edStatus .ok { color: var(--green); }
#edZoom { position: absolute; right: calc(214px + var(--sar)); bottom: calc(10px + var(--sab)); display: flex; gap: 4px; }
#edZoom button { font: inherit; font-size: 11px; width: 36px; height: 36px; background: rgba(5,8,16,.9); color: var(--text); border: 2px solid var(--line); border-radius: 4px; cursor: pointer; }
#edDialog { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; background: rgba(4,7,14,.7); padding: calc(50px + var(--sat)) 12px 12px; }
#edDlgBody { display: flex; flex-direction: column; gap: 6px; max-width: 560px; width: min(560px, calc(100vw - 60px)); font-size: 9px; }
#edDlgBody textarea { font: inherit; font-size: 8px; width: 100%; height: 150px; background: #0b101c; color: var(--text); border: 2px solid var(--line); border-radius: 4px; padding: 6px; -webkit-user-select: text; user-select: text; }
#edDlgBody .drow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#edDlgBody .drow .nm { flex: 1; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#edDlgBody .note { color: var(--muted); line-height: 1.6; }
body.compact #edSide { width: 150px; }
body.compact #edTools { width: 80px; }
body.compact #edZoom { right: calc(160px + var(--sar)); }
body.compact #edTop { padding-left: calc(56px + var(--sal)); gap: 4px; }
body.compact .ebtn { font-size: 7px; padding: 0 6px; min-height: 30px; }
body.compact #edName { flex: 1 1 70px; max-width: 120px; font-size: 8px; padding: 6px; }
body.is-touch.compact #edTop { padding-right: calc(126px + var(--sar)); }

/* ---- rotate hint */
#rotateHint { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 18px; background: #07090f; color: var(--gold); text-align: center; font-size: clamp(12px, 3.6vw, 16px); line-height: 1.9; padding: 24px; }
#rotateHint small { display: block; color: var(--muted); font-size: .7em; margin-top: 6px; }
#rotateHint .phone { width: 38px; height: 66px; border: 3px solid var(--gold); border-radius: 7px; animation: rot 1.6s ease-in-out infinite; }
@keyframes rot { 0%, 20% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }
body.is-touch.portrait #rotateHint { display: flex; }

/* phones: show where the left thumb moves you (David on his iPhone: "i cannot move" - the joystick was invisible
   until you touched the right spot). Ghost stick in the move zone; hidden while the real stick is in use. */
#joyZone::after {
  content: 'MOVE'; position: absolute; left: 24px; bottom: 24px; width: 104px; height: 104px; border-radius: 50%;
  border: 2px dashed rgba(255,255,255,.7); background: rgba(5,8,16,.5); color: #fff;
  display: flex; align-items: center; justify-content: center; font-family: inherit; font-size: 12px; letter-spacing: 1px;
  pointer-events: none; animation: joyGhost 1.6s ease-in-out infinite;
}
#joyZone:has(#joyBase.on)::after { display: none; }
@keyframes joyGhost { 50% { opacity: .45; } }
