:root {
  --bg: #14121f; --panel: #221f33; --line: #3a3556; --text: #f3f0ff; --dim: #a39fbd; --accent: #ffd23f;
  --p0: #f5c518; --p1: #e5484d; --p2: #34c759; --p3: #4c8dff;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.4 ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }

.screen {
  height: 100%; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: safe center;
  gap: 12px; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.screen > * { width: min(100%, 360px); }
h1 { margin: 0; line-height: 0; }
h1 img { width: 100%; height: auto; image-rendering: pixelated; border-radius: 10px; }
h2 { margin: 0; text-align: center; }
.msg { margin: 0; min-height: 1.4em; text-align: center; color: #ff8a8a; }
.room { margin: 0; text-align: center; color: var(--accent); font-size: 20px; font-weight: 700; letter-spacing: 2px; }
.room:empty { display: none; }

button, select, input {
  font: inherit; color: var(--text); background: var(--panel); border: 2px solid var(--line); border-radius: 10px;
  padding: 10px 14px; min-height: 44px;
}
button { cursor: pointer; font-weight: 700; }
button.big { background: var(--accent); border-color: #b3560a; color: #2a1a00; }
button:active { transform: translateY(1px); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
#online { display: flex; flex-direction: column; gap: 12px; }
#joinForm, .row { display: flex; gap: 8px; }
.version { margin: 0; text-align: center; color: var(--dim); font-size: 12px; }
#joinForm input { flex: 1; min-width: 0; text-align: center; text-transform: uppercase; letter-spacing: 4px; font-weight: 700; }
.row button { flex: 1; }

.slot { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.slot i, .pl i { width: 14px; height: 14px; border-radius: 50%; flex: none; background: var(--c); }
.slot span { width: 56px; font-weight: 700; }
.slot select, .slot em { flex: 1; min-width: 0; }
.slot em { font-style: normal; color: var(--dim); padding: 10px 0; }
.c0 { --c: var(--p0); } .c1 { --c: var(--p1); } .c2 { --c: var(--p2); } .c3 { --c: var(--p3); }
.opts { display: flex; gap: 8px; }
.opts label { flex: 1; display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 14px; }

#game { position: fixed; inset: 0; display: flex; flex-direction: column; touch-action: none; }
#hud {
  height: 34px; flex: none; display: flex; align-items: center; gap: 10px;
  padding: 0 max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left)); margin-top: env(safe-area-inset-top);
  font-size: 14px; font-weight: 700;
}
#hudPlayers { flex: 1; display: flex; gap: 12px; overflow: hidden; white-space: nowrap; }
.pl { display: flex; align-items: center; gap: 5px; }
.pl.dead { opacity: 0.35; }
.pl b { color: var(--accent); letter-spacing: 1px; }
.pl small { color: var(--dim); font-weight: 400; }
#clock { font-variant-numeric: tabular-nums; }
#clock.hurry { color: #ff6b6b; }
#btnQuit { min-height: 28px; padding: 0 9px; border-radius: 8px; }

#stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; }
canvas { display: block; image-rendering: pixelated; }
#banner {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  pointer-events: none; text-align: center;
}
#banner p { margin: 0; padding: 10px 22px; border-radius: 14px; background: rgba(20, 18, 31, 0.86); font-size: clamp(22px, 5vw, 40px); font-weight: 800; }
#banner button { pointer-events: auto; }

/* Touch controls: only shown when someone plays by touch. */
#stick, #bombHint { display: none; position: fixed; pointer-events: none; }
#game.touch #stick.on { display: block; width: 96px; height: 96px; margin: -48px 0 0 -48px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35); }
#stick i { position: absolute; left: 24px; top: 24px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, 0.45); }
#game.touch #bombHint {
  display: flex; align-items: center; justify-content: center; width: 84px; height: 84px; border-radius: 50%;
  right: max(18px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom));
  border: 2px solid rgba(255, 255, 255, 0.35); color: rgba(255, 255, 255, 0.6); font-weight: 800;
}
