/* ========================================================================== */
/* Tokens                                                                      */
/* ========================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0b0b0d;
  --bg-2: #131316;
  --bg-3: #1c1c20;
  --ink: #efe6d4;
  --ink-soft: #b8b1a3;
  --ink-dim: #6d6859;
  --line: #1f1f23;
  --line-strong: #2c2c30;
  --accent: #d4a93a;        /* antique gold */
  --accent-hot: #f0c050;    /* hover — brighter gold */
  --tape: #b08c4a;          /* tan masking-tape, distinct from accent */
  --hud-bg: rgba(11, 11, 13, 0.85);
  --shadow-stamp: 5px 5px 0 #000;
  --display: 'Anton', 'Impact', sans-serif;
  --tag: 'Special Elite', ui-monospace, monospace;
  --body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Fixed grain layer behind everything. SVG-noise data URI keeps it small
   and crisp at any zoom. Subtle but it's what kills the "flat dark gradient"
   AI-template feeling. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='280' height='280'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.18 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
}

canvas { display: block; }

/* ========================================================================== */
/* Loading screen                                                              */
/* ========================================================================== */

#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
#loading-screen.hidden { display: none; }
.loading-card {
  background: var(--ink);
  color: var(--bg);
  border: 2.5px solid #000;
  padding: 28px 36px;
  width: min(380px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 6px 6px 0 #000;
  transform: rotate(-0.6deg);
}
.loading-mark {
  align-self: flex-start;
  padding: 4px 10px;
  background: var(--accent);
  color: var(--ink);
  border: 2px solid #000;
  font-family: var(--tag);
  font-size: 11px;
  letter-spacing: 0.32em;
  font-weight: 700;
  transform: rotate(-2deg);
}
.loading-card h2 {
  font-family: var(--display);
  font-size: 36px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bg);
  line-height: 1;
}
.loading-bar {
  height: 8px;
  background: #fff;
  border: 1.5px solid #000;
  overflow: hidden;
}
.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.18s ease-out;
}
.loading-status {
  font-family: var(--tag);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  word-break: break-all;
  min-height: 1em;
}

/* ========================================================================== */
/* Admin modal                                                                 */
/* ========================================================================== */

#admin-modal {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
}
#admin-modal.hidden { display: none; }
.admin-card {
  background: var(--ink);
  color: var(--bg);
  border: 2.5px solid #000;
  padding: 24px 28px;
  width: min(360px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 6px 6px 0 #000;
  transform: rotate(0.6deg);
}
.admin-card h2 {
  font-family: var(--display);
  font-size: 28px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1;
}
.admin-tag {
  font-family: var(--tag);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 6px;
}
.admin-announce {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.admin-announce-text {
  width: 100%;
  background: #fff;
  border: 1.5px solid #000;
  color: var(--bg);
  padding: 8px 10px;
  font-family: var(--body);
  font-size: 13px;
  font-weight: 500;
  resize: vertical;
  outline: none;
}
.admin-announce-text:focus { border-color: var(--accent); }
.admin-action {
  padding: 12px 14px;
  font-family: var(--display);
  font-size: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 2px solid #000;
  background: transparent;
  color: var(--bg);
  cursor: pointer;
  text-align: left;
}
.admin-action:hover { background: rgba(0, 0, 0, 0.06); }
.admin-action.danger { background: var(--accent); color: var(--ink); box-shadow: 3px 3px 0 #000; }
.admin-action.danger:hover { background: var(--accent-hot); }
.admin-output-wrap {
  position: relative;
  margin: 4px 0;
}
.admin-output-wrap.hidden { display: none; }
.admin-output {
  font-family: ui-monospace, "Cascadia Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 1.4;
  background: rgba(0, 0, 0, 0.35);
  color: var(--bg);
  border: 2px solid #000;
  padding: 8px 10px;
  margin: 0;
  max-height: 240px;
  overflow: auto;
  white-space: pre;
}
.admin-output-close {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: 1.5px solid #000;
  background: var(--ink);
  color: var(--bg);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.admin-output-close:hover { background: var(--accent); color: var(--ink); }

/* --- admin announcement banner ------------------------------------------ */
/* Top-centre sticker banner. main.js toggles `.show` to fade it in/out;
   actual auto-dismiss is driven by a setTimeout so the duration is in JS. */
#announce-banner {
  position: fixed;
  top: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(-18px) rotate(-1deg);
  z-index: 65;
  background: var(--accent);
  color: var(--ink);
  border: 2.5px solid #000;
  padding: 12px 22px;
  max-width: min(80vw, 720px);
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 0.04em;
  line-height: 1.25;
  text-transform: none;
  box-shadow: 6px 6px 0 #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
  text-align: center;
  word-wrap: break-word;
}
#announce-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) rotate(-1deg);
}
#announce-banner.hidden { display: none; }
#announce-banner .announce-by {
  display: block;
  font-family: var(--tag);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.85;
  margin-bottom: 4px;
}

/* Hide-self toggle visuals — same idea as the music mute button. */
.tool-toggle.muted .icon-on,
.tool-toggle .icon-off { display: none; }
.tool-toggle.muted .icon-off { display: block; }
.tool-toggle.muted span::after { content: ' off'; opacity: 0.7; }
.tool-admin.hidden { display: none; }

/* ========================================================================== */
/* Auth screen                                                                 */
/* ========================================================================== */

#auth-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
#auth-screen.hidden { display: none; }
.auth-card {
  background: var(--ink);
  color: var(--bg);
  border: 2.5px solid #000;
  padding: 32px 36px;
  width: min(400px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 6px 6px 0 #000;
  transform: rotate(-0.8deg);
}
.auth-mark {
  display: inline-block;
  align-self: flex-start;
  padding: 4px 10px;
  background: var(--accent);
  color: var(--ink);
  border: 2px solid #000;
  font-family: var(--tag);
  font-size: 12px;
  letter-spacing: 0.32em;
  font-weight: 700;
  margin-bottom: 6px;
  transform: rotate(-2deg);
  box-shadow: 3px 3px 0 #000;
}
.auth-card h2 {
  font-family: var(--display);
  font-size: 44px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--bg);
}
.auth-tag {
  font-size: 14px;
  font-weight: 500;
  color: var(--bg);
  margin-bottom: 6px;
  line-height: 1.4;
}
#auth-google,
#auth-guest {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 16px;
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 2px solid #000;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
#auth-google {
  background: #fff;
  color: #1a1a1a;
  box-shadow: 3px 3px 0 #000;
}
#auth-google:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #000;
}
#auth-guest {
  background: transparent;
  color: var(--bg);
}
#auth-guest:hover { background: rgba(0, 0, 0, 0.05); }
.auth-hint {
  font-family: var(--tag);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-top: 4px;
}

#username-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
#username-screen.hidden { display: none; }
#username-input {
  background: #fff;
  border: 2px solid #000;
  color: var(--bg);
  padding: 12px 14px;
  font-family: var(--display);
  font-size: 24px;
  letter-spacing: 0.04em;
  outline: none;
  text-transform: lowercase;
}
#username-input:focus { border-color: var(--accent); }
.username-status {
  font-family: var(--tag);
  font-size: 12px;
  letter-spacing: 0.06em;
  min-height: 1em;
  margin-top: -4px;
}
.username-status.ok { color: #2e8b3a; }
.username-status.bad { color: var(--accent); }
#username-claim {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 2px solid #000;
  background: var(--accent);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
  box-shadow: 3px 3px 0 #000;
}
#username-claim:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #000;
}
#username-claim:disabled {
  background: var(--bg-3);
  color: var(--ink-dim);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ========================================================================== */
/* Lobby                                                                       */
/* ========================================================================== */

#lobby {
  position: fixed;
  inset: 0;
  z-index: 10;
  background:
    radial-gradient(900px 700px at 80% -20%, rgba(212, 169, 58, 0.07), transparent 60%),
    radial-gradient(700px 500px at 5% 110%, rgba(176, 140, 74, 0.04), transparent 60%),
    var(--bg);
}
#lobby.hidden { display: none; }

/* Top-left profile pill — sticker style: rotated, hard shadow, marker font. */
.lobby-profile {
  position: absolute;
  top: 28px;
  left: 28px;
  z-index: 5;
}
.profile-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 10px;
  background: var(--ink);
  color: var(--bg);
  border: 2px solid #000;
  font-family: var(--tag);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transform: rotate(-1.6deg);
  box-shadow: 4px 4px 0 #000;
  transition: transform 0.1s, box-shadow 0.1s;
}
.profile-pill:hover {
  transform: rotate(-1.6deg) translate(-1px, -1px);
  box-shadow: 5px 5px 0 #000;
}
.profile-pill.open {
  transform: rotate(-1.6deg) translate(2px, 2px);
  box-shadow: 2px 2px 0 #000;
  background: var(--accent);
  color: var(--ink);
}
.profile-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid #000;
  flex-shrink: 0;
}

/* Sits to the right of the profile pill in the same sticker style.
   Slightly different rotation so it doesn't visually overlap. */
.auth-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--bg);
  border: 2px solid #000;
  font-family: var(--tag);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transform: rotate(1.4deg);
  box-shadow: 4px 4px 0 #000;
  transition: transform 0.1s, box-shadow 0.1s, background 0.1s;
  vertical-align: top;
}
.auth-pill.hidden { display: none; }
.auth-pill:hover {
  transform: rotate(1.4deg) translate(-1px, -1px);
  box-shadow: 5px 5px 0 #000;
}
.auth-pill:disabled {
  cursor: wait;
  opacity: 0.7;
}
.auth-pill svg { display: block; flex-shrink: 0; }
.profile-caret { font-size: 10px; opacity: 0.65; }
.profile-pill.open .profile-caret { transform: rotate(180deg); }

.profile-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 4px;
  width: 320px;
  background: var(--ink);
  color: var(--bg);
  border: 2px solid #000;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 5px 5px 0 #000;
  transform: rotate(-0.6deg);
}
.profile-panel.hidden { display: none; }
.profile-panel h3 {
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1;
}
.profile-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.profile-field label {
  font-family: var(--tag);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.profile-field input {
  background: #fff;
  border: 1.5px solid #000;
  color: var(--bg);
  padding: 9px 12px;
  font: inherit;
  font-family: var(--body);
  font-size: 14px;
  font-weight: 600;
  outline: none;
}
.profile-field input:focus { border-color: var(--accent); }
.profile-skins,
.profile-beanies {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.profile-skin,
.profile-beanie {
  aspect-ratio: 1;
  border: 1.5px solid #000;
  cursor: pointer;
  transition: transform 0.08s;
}
.profile-skin:hover,
.profile-beanie:hover { transform: scale(1.12); }
.profile-skin.active,
.profile-beanie.active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.profile-colors {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.profile-color {
  aspect-ratio: 1;
  border: 1.5px solid #000;
  cursor: pointer;
  border-radius: 50%;
  transition: transform 0.08s;
}
.profile-color:hover { transform: scale(1.12); }
.profile-color.active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.profile-save {
  padding: 12px;
  background: var(--accent);
  color: var(--ink);
  border: 2px solid #000;
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
  box-shadow: 3px 3px 0 #000;
}
.profile-save:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #000;
}

/* --- friends widget (top-right) ------------------------------------------ */
.lobby-friends {
  position: absolute;
  top: 28px;
  right: 28px;
  z-index: 5;
}
.lobby-friends.hidden { display: none; }
.friends-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--bg);
  border: 2px solid #000;
  font-family: var(--tag);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transform: rotate(1.4deg);
  box-shadow: 4px 4px 0 #000;
  transition: transform 0.1s, box-shadow 0.1s;
  position: relative;
}
.friends-pill:hover {
  transform: rotate(1.4deg) translate(-1px, -1px);
  box-shadow: 5px 5px 0 #000;
}
.friends-pill.open {
  transform: rotate(1.4deg) translate(2px, 2px);
  box-shadow: 2px 2px 0 #000;
  background: var(--accent);
  color: var(--ink);
}
.friends-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink);
  font-family: var(--tag);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  border: 1.5px solid #000;
}
.friends-badge.hidden { display: none; }
.friends-pill.open .friends-badge {
  background: var(--ink);
  color: var(--bg);
}

.friends-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 4px;
  width: 340px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--ink);
  color: var(--bg);
  border: 2px solid #000;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 5px 5px 0 #000;
  transform: rotate(0.6deg);
}
.friends-panel.hidden { display: none; }
.friends-panel h3 {
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1;
}

.friends-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}
#friends-add-input {
  background: #fff;
  border: 1.5px solid #000;
  color: var(--bg);
  padding: 8px 10px;
  font: inherit;
  font-family: var(--body);
  font-size: 13px;
  font-weight: 600;
  outline: none;
  text-transform: lowercase;
}
#friends-add-input:focus { border-color: var(--accent); }
#friends-add-btn {
  padding: 8px 14px;
  background: var(--accent);
  color: var(--ink);
  border: 1.5px solid #000;
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.1s;
}
#friends-add-btn:hover { background: var(--accent-hot); }
#friends-add-btn:disabled {
  background: var(--bg-3);
  color: var(--ink-dim);
  cursor: not-allowed;
}
.friends-status {
  font-family: var(--tag);
  font-size: 11px;
  letter-spacing: 0.06em;
  min-height: 1em;
}
.friends-status.ok { color: #2e8b3a; }
.friends-status.bad { color: var(--accent); }

.friends-section { display: flex; flex-direction: column; gap: 6px; }
.friends-section-h {
  font-family: var(--tag);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.friends-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}
.friends-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1.5px solid var(--bg-3);
  background: rgba(0, 0, 0, 0.04);
}
.friend-name {
  font-family: var(--body);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.friend-actions { display: flex; gap: 4px; }
.friend-action {
  padding: 4px 9px;
  font-family: var(--tag);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  border: 1px solid #000;
  background: transparent;
  color: var(--bg);
  cursor: pointer;
  transition: background 0.1s;
}
.friend-action.accept { background: var(--accent); color: var(--ink); }
.friend-action.accept:hover { background: var(--accent-hot); }
.friend-action.danger:hover { background: rgba(230, 57, 70, 0.15); color: var(--accent); }
.friends-empty {
  font-family: var(--tag);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  padding: 4px 0;
}

@media (max-width: 960px) {
  .lobby-friends { top: 16px; right: 16px; }
}

/* --- mute button (bottom-right of lobby) --------------------------------- */
.music-toggle {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 5;
  width: 42px;
  height: 42px;
  background: var(--ink);
  color: var(--bg);
  border: 2px solid #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 3px 3px 0 #000;
  transform: rotate(-2.5deg);
  transition: transform 0.1s, box-shadow 0.1s, background 0.1s;
}
.music-toggle:hover {
  transform: rotate(-2.5deg) translate(-1px, -1px);
  box-shadow: 4px 4px 0 #000;
}
.music-toggle:active {
  transform: rotate(-2.5deg) translate(2px, 2px);
  box-shadow: 1px 1px 0 #000;
}
.music-toggle.muted {
  background: var(--accent);
  color: var(--ink);
}
.music-toggle .icon-off { display: none; }
.music-toggle.muted .icon-on { display: none; }
.music-toggle.muted .icon-off { display: block; }

/* --- main lobby grid ------------------------------------------------------ */
.lobby-grid {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(380px, 0.95fr) minmax(440px, 1.05fr);
  max-width: 1280px;
  margin: 0 auto;
  padding: 90px 64px 56px;
  gap: 56px;
  position: relative;
  z-index: 1;
}
.lobby-stage {
  position: relative;
  overflow: hidden;
}
#char-preview {
  width: 100%;
  height: 100%;
  display: block;
}
.lobby-username-tag {
  position: absolute;
  bottom: 18px;
  left: 0;
  font-family: var(--tag);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--bg);
  padding: 4px 10px;
  border: 1.5px solid var(--accent);
  transform: rotate(-1deg);
}
.lobby-username-tag::before {
  content: '@ ';
  color: var(--accent);
  font-weight: 700;
}

.lobby-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 32px;
  position: relative;
}

.brand { display: flex; flex-direction: column; gap: 14px; position: relative; }
.brand-mark {
  display: inline-block;
  align-self: flex-start;
  padding: 4px 10px;
  background: var(--accent);
  color: var(--ink);
  border: 2px solid #000;
  font-family: var(--tag);
  font-size: 12px;
  letter-spacing: 0.32em;
  font-weight: 700;
  transform: rotate(-2deg);
  box-shadow: 3px 3px 0 #000;
}
.brand h1 {
  font-family: var(--display);
  font-size: clamp(64px, 9.5vw, 132px);
  line-height: 0.84;
  letter-spacing: -0.005em;
  text-transform: uppercase;
  color: var(--ink);
  font-weight: 400; /* Anton ships at 400 — already heavy */
  /* Hard chiseled shadow gives it a stenciled poster feel without
     looking neon. */
  text-shadow: 4px 4px 0 #000;
}
.brand h1 em {
  color: var(--accent);
  font-style: normal;
  display: inline-block;
  transform: skew(-5deg);
}

/* Online row — mono tag font + a big Anton number. */
.online-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-family: var(--tag);
}
.online-row .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  align-self: center;
}
.online-num {
  font-family: var(--display);
  font-size: 36px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1;
}
.online-label {
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.section-h {
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 16px;
  position: relative;
}
.section-h::after {
  /* short red underline like a hand stroke */
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: var(--accent);
  margin-top: 4px;
}

/* Map cards — taped-up posters. Each rotates a different direction so
   they read as paste-up rather than a uniform grid. */
.map-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}
.map-card {
  background: var(--bg-2);
  border: 2px solid #000;
  padding: 0;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  position: relative;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 4px 4px 0 #000;
  transform: rotate(-1.4deg);
}
.map-card:nth-child(2) { transform: rotate(1.2deg); }
.map-card:nth-child(3) { transform: rotate(-0.6deg); }
.map-card:hover {
  transform: rotate(0deg) translate(-1px, -2px);
  box-shadow: 6px 6px 0 #000;
}
.map-card.selected {
  background: var(--ink);
  color: var(--bg);
}
/* Tape strip at the top of every card */
.map-card::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 14px;
  width: 56px;
  height: 18px;
  background: rgba(214, 178, 96, 0.82);
  border: 1px dashed rgba(0, 0, 0, 0.18);
  transform: rotate(-4deg);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.map-card:nth-child(2)::before {
  left: auto;
  right: 14px;
  transform: rotate(5deg);
}
.map-card:nth-child(3)::before { left: 30%; transform: rotate(-2deg); }

.map-art {
  height: 110px;
  width: 100%;
  display: block;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  border-bottom: 2px solid #000;
}
.alley-art::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(78deg, #1c1417 0%, transparent 36%),
    linear-gradient(-78deg, #1c1417 0%, transparent 36%),
    linear-gradient(180deg, #2a1a1a 0%, #0a0608 100%);
}
.rooftop-art::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, #1a1424 0%, #050714 100%);
}
.rooftop-art::after {
  /* skyline silhouette + neon stripe */
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 26%;
  height: 36%;
  background:
    linear-gradient(90deg,
      #050610 0%, #050610 10%, #0e0e16 10%, #0e0e16 22%,
      #050610 22%, #050610 36%, #0e0e16 36%, #0e0e16 52%,
      #050610 52%, #050610 64%, #0e0e16 64%, #0e0e16 78%,
      #050610 78%, #050610 90%, #0e0e16 90%);
}
.custom-art::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    #1a1a1c 0 8px,
    #0c0c0e 8px 16px
  );
}
.custom-art::after {
  content: '?';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-size: 56px;
  color: var(--accent);
  text-shadow: 3px 3px 0 #000;
}

.map-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-top: 0;
}
.map-name {
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
}
.map-pop {
  font-family: var(--tag);
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.map-card.selected .map-pop { color: var(--ink-dim); }
.map-pop::after {
  content: ' here';
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Drop in button — heavy stamped CTA. */
#play {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 16px 30px;
  font-family: var(--display);
  font-size: 26px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: var(--accent);
  color: var(--ink);
  border: 2.5px solid #000;
  cursor: pointer;
  transform: rotate(-1deg);
  box-shadow: var(--shadow-stamp);
  transition: transform 0.08s, box-shadow 0.08s, gap 0.15s, outline-offset 0.12s;
}
/* Single-map game now — Join button always wears the white halo so it
   reads as the focal CTA in the lobby. */
#play {
  outline: 2px solid #fff;
  outline-offset: 4px;
}
#play:hover {
  transform: rotate(-1deg) translate(-2px, -2px);
  box-shadow: 7px 7px 0 #000;
  gap: 22px;
}
#play:active {
  transform: rotate(-1deg) translate(2px, 2px);
  box-shadow: 3px 3px 0 #000;
}
.play-arrow { font-size: 22px; line-height: 1; }

@media (max-width: 960px) {
  .lobby-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 280px 1fr;
    padding: 68px 24px 24px;
    gap: 24px;
  }
  .map-grid { grid-template-columns: 1fr 1fr; }
  .lobby-profile { top: 16px; left: 16px; }
}

/* ========================================================================== */
/* In-game UI                                                                  */
/* ========================================================================== */

/* --- left palette rail ---------------------------------------------------- */
#tool-rail {
  position: fixed;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
}
#palette {
  display: grid;
  grid-template-columns: repeat(7, 18px);
  gap: 4px;
  background: var(--ink);
  border: 2px solid #000;
  padding: 10px 8px;
  box-shadow: 4px 4px 0 #000;
  transform: rotate(-1.5deg);
  max-height: 70vh;
  overflow-y: auto;
  /* Slim, themed scrollbar so the rotated rail still looks intentional. */
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
#palette::-webkit-scrollbar { width: 6px; }
#palette::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }
.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid #000;
  cursor: pointer;
  position: relative;
  transition: transform 0.08s;
}
.swatch:hover { transform: scale(1.15); z-index: 1; }
.swatch.active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  z-index: 1;
}

/* --- bottom tool dock ----------------------------------------------------- */
#hud {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) rotate(-0.4deg);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--ink);
  border: 2px solid #000;
  padding: 4px;
  box-shadow: 4px 4px 0 #000;
}
#toolbar { display: flex; gap: 0; }
.tool {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: transparent;
  border: 0;
  color: var(--bg);
  font-family: var(--display);
  font-size: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.tool svg { width: 22px; height: 22px; display: block; }
.tool:hover { background: rgba(0, 0, 0, 0.05); }
.tool.active {
  background: var(--accent);
  color: var(--ink);
}
.tool.active svg { color: var(--ink); }

#username {
  padding: 0 12px 0 14px;
  font-family: var(--tag);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  border-left: 1.5px solid var(--bg);
  align-self: stretch;
  display: flex;
  align-items: center;
}

/* --- brush panel (right) -------------------------------------------------- */
#brush-panel {
  position: fixed;
  right: 18px;
  top: 50%;
  transform: translateY(-50%) rotate(1deg);
  z-index: 5;
  background: var(--ink);
  border: 2px solid #000;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 240px;
  box-shadow: 4px 4px 0 #000;
}
.brush-row {
  display: grid;
  grid-template-columns: 64px 1fr 44px;
  gap: 10px;
  align-items: center;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.brush-label {
  font-family: var(--display);
  color: var(--bg);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.08em;
}
.brush-value {
  text-align: right;
  font-family: var(--tag);
  font-size: 12px;
  color: var(--bg);
  font-variant-numeric: tabular-nums;
}
#brush-panel input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  background: var(--bg);
  outline: none;
  cursor: pointer;
}
#brush-panel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 1.5px solid #000;
}
#brush-panel input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 1.5px solid #000;
}
#brush-panel input[type="range"]:disabled {
  opacity: 0.35;
  cursor: default;
}
.brush-toggle {
  background: transparent;
  border: 1.5px solid var(--bg);
  color: var(--bg);
  padding: 4px 0;
  cursor: pointer;
  font: inherit;
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brush-toggle.active {
  background: var(--accent);
  color: var(--ink);
  border-color: #000;
}
.brush-sub-label {
  font-size: 12px;
  opacity: 0.75;
  padding-left: 8px;
}

/* --- train timer chip ---------------------------------------------------- */
#train-timer {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) rotate(-1.5deg);
  z-index: 5;
  background: var(--ink);
  color: var(--bg);
  border: 2px solid #000;
  padding: 10px 16px;
  box-shadow: 4px 4px 0 #000;
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 140px;
  font-family: var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
#train-timer.hidden { display: none; }
#train-timer .train-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  opacity: 0.65;
}
#train-timer .train-value {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
#train-timer.outbound .train-value,
#train-timer.inbound .train-value {
  font-size: 16px;
}

/* --- crosshair ------------------------------------------------------------ */
#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  color: var(--accent);
  pointer-events: none;
  z-index: 1;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.9);
  display: none;
  font-family: var(--tag);
  font-weight: 700;
}
body.pointer-locked #crosshair { display: block; }

/* ========================================================================== */
/* Hamburger / menu button                                                     */
/* ========================================================================== */

#menu-button {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 6;
  width: 44px;
  height: 44px;
  background: var(--ink);
  border: 2px solid #000;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  box-shadow: 3px 3px 0 #000;
  transform: rotate(-3deg);
  transition: transform 0.08s, box-shadow 0.08s;
}
#menu-button.hidden { display: none; }
#menu-button:hover {
  transform: rotate(-3deg) translate(-1px, -1px);
  box-shadow: 4px 4px 0 #000;
}
#menu-button:active {
  transform: rotate(-3deg) translate(2px, 2px);
  box-shadow: 1px 1px 0 #000;
}
#menu-button span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--bg);
}
#menu-button:hover span { background: var(--accent); }

/* ========================================================================== */
/* Leaderboard                                                                 */
/* ========================================================================== */

#leaderboard {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 5;
  background: var(--ink);
  color: var(--bg);
  border: 2px solid #000;
  padding: 12px 16px;
  min-width: 220px;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 4px 4px 0 #000;
  transform: rotate(1.2deg);
}
#leaderboard.hidden { display: none; }
.leaderboard-header {
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid var(--bg);
  line-height: 1;
}
.leaderboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--tag);
  font-size: 14px;
}
.leaderboard-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid #000;
}
.leaderboard-name {
  color: var(--bg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.02em;
  flex: 1;
}
/* Device-kind icon sits at the row's right edge. Empty when the player's
   device is unknown so the row simply shrinks. */
.leaderboard-device {
  display: inline-flex;
  align-items: center;
  color: var(--ink-dim);
  flex-shrink: 0;
}
.leaderboard-device:empty { display: none; }
.leaderboard-row.self .leaderboard-name {
  font-weight: 700;
}
.leaderboard-row.self .leaderboard-name::after {
  content: ' · YOU';
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.1em;
  font-size: 11px;
}

/* ========================================================================== */
/* Pause menu                                                                  */
/* ========================================================================== */

#pause-menu {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.78);
}
#pause-menu.hidden { display: none; }
.pause-card {
  background: var(--ink);
  color: var(--bg);
  border: 2.5px solid #000;
  padding: 28px 32px;
  width: min(340px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 6px 6px 0 #000;
  transform: rotate(-0.8deg);
}
.pause-card h2 {
  font-family: var(--display);
  font-size: 32px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 14px;
  color: var(--accent);
  line-height: 1;
}
.pause-card button {
  padding: 12px 14px;
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 2px solid #000;
  background: transparent;
  color: var(--bg);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}
.pause-card button:hover { background: rgba(0, 0, 0, 0.06); }
.pause-card #resume {
  background: var(--accent);
  color: var(--ink);
  box-shadow: 3px 3px 0 #000;
}
.pause-card #resume:hover { background: var(--accent-hot); }
.pause-hint {
  margin-top: 10px;
  font-family: var(--tag);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* ========================================================================== */
/* Chat                                                                        */
/* ========================================================================== */

#chat {
  position: fixed;
  bottom: 88px;
  left: 18px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(380px, 60vw);
  pointer-events: none;
}
#chat-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat-msg {
  background: var(--ink);
  color: var(--bg);
  border: 1.5px solid #000;
  padding: 6px 10px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  word-break: break-word;
  box-shadow: 2px 2px 0 #000;
  animation: chat-in 0.2s ease-out;
  align-self: flex-start;
}
.chat-msg-out { animation: chat-out 0.4s ease-in forwards; }
.chat-author {
  font-family: var(--tag);
  font-weight: 700;
  margin-right: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chat-text { color: var(--bg); }
@keyframes chat-in {
  from { opacity: 0; transform: translateX(-8px) rotate(-1deg); }
  to { opacity: 1; transform: translateX(0) rotate(-0.5deg); }
}
@keyframes chat-out { to { opacity: 0; } }
#chat-input {
  pointer-events: auto;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--bg);
  border: 2px solid var(--accent);
  font-family: var(--body);
  font-weight: 600;
  font-size: 14px;
  outline: none;
  width: 100%;
  box-shadow: 3px 3px 0 #000;
}
#chat-input::placeholder {
  color: var(--ink-dim);
  font-style: italic;
}
#chat-input.hidden { display: none; }

/* Tiny "press T to chat" hint near the chat log. Hidden when the user
   already knows (chat-open) or when there's no T to press (.mobile). */
.chat-hint {
  position: fixed;
  bottom: 18px;
  left: 18px;
  z-index: 4;
  pointer-events: none;
  font-family: var(--tag);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  background: rgba(11, 11, 13, 0.55);
  padding: 5px 9px;
  border: 1.5px solid var(--line-strong);
  box-shadow: 2px 2px 0 #000;
  transform: rotate(-1.2deg);
}
.chat-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  margin: 0 2px;
  background: var(--ink);
  color: var(--bg);
  border: 1px solid #000;
  font-family: ui-monospace, "Cascadia Mono", Menlo, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}
body.chat-open .chat-hint,
body.mobile .chat-hint { display: none; }

/* ========================================================================== */
/* Hover tooltip on tags                                                       */
/* ========================================================================== */

#hover-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 6;
  background: var(--ink);
  color: var(--bg);
  border: 1.5px solid #000;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.35;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transform: translate(14px, 14px) rotate(-1deg);
  white-space: nowrap;
  box-shadow: 2px 2px 0 #000;
}
#hover-tooltip.hidden { display: none; }
.hover-name {
  font-family: var(--tag);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.hover-time {
  font-family: var(--tag);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* ========================================================================== */
/* Touch control overlay (mobile)                                              */
/* ========================================================================== */
/* Hidden by default; controls.js adds .mobile to <body> when touch input is
   detected, which reveals these. The joystick "thumb" and "base" follow the
   active touch via inline transform, set by the same code. */

#touch-overlay {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}
body.mobile #touch-overlay { display: block; }
body:not(.mobile) #touch-overlay { display: none; }

.touch-joystick {
  position: absolute;
  left: 0; top: 0;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(20, 20, 24, 0.35);
  border: 2px solid rgba(239, 230, 212, 0.55);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.touch-joystick.show { opacity: 1; }
.touch-joystick-thumb {
  position: absolute;
  left: 50%; top: 50%;
  width: 56px;
  height: 56px;
  margin-left: -28px;
  margin-top: -28px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #000;
  box-shadow: 2px 2px 0 #000;
}
.touch-paint-btn {
  position: absolute;
  right: 24px;
  bottom: 100px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid #000;
  color: var(--ink);
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  pointer-events: auto;
  box-shadow: 4px 4px 0 #000;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.touch-paint-btn:active,
.touch-paint-btn.pressed {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #000;
  background: var(--accent-hot);
}

/* Center reticle is shown for mobile users (they aim at screen centre when
   the paint button is held). On desktop, the existing pointer-locked rule
   in #crosshair already handles this. */
body.mobile #crosshair { display: block; }

/* ========================================================================== */
/* Mobile responsive (narrow screens)                                          */
/* ========================================================================== */
/* 768px is a reasonable mobile-or-tablet cutoff. Anything below adjusts HUD
   spacing, tap targets, and stacking. Most rules apply regardless of touch
   input — tablets in landscape benefit too. */

@media (max-width: 768px) {
  /* --- Lobby --------------------------------------------------------- */
  /* Keep the head model + Join button side-by-side at narrow widths so
     the player never has to scroll to find the CTA. Head canvas takes
     the left column; brand / online / Join stack tight on the right. */
  #lobby { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .lobby-grid {
    height: 100%;
    grid-template-columns: 1fr 1.1fr;
    grid-template-rows: 1fr;
    padding: 56px 12px 16px;
    gap: 12px;
  }
  .lobby-stage { min-width: 0; }
  .lobby-info {
    justify-content: center;
    gap: 14px;
    min-width: 0;
  }
  .brand h1 { font-size: clamp(32px, 9vw, 56px); text-shadow: 3px 3px 0 #000; }
  .brand-mark { font-size: 10px; padding: 3px 8px; }
  #play {
    padding: 10px 18px;
    font-size: 17px;
    gap: 10px;
    /* Don't let the focal CTA shrink off-screen in flex layouts. */
    flex-shrink: 0;
  }
  .online-num { font-size: 24px; }
  .online-label { font-size: 11px; }

  .profile-panel {
    width: min(280px, calc(100vw - 32px));
    padding: 14px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }
  .auth-pill {
    font-size: 11px;
    padding: 6px 10px;
  }

  .friends-panel { width: min(300px, calc(100vw - 32px)); }
  .lobby-friends { top: 16px; right: 16px; }

  /* --- In-game HUD -------------------------------------------------- */
  /* Palette becomes a short scroll strip in the bottom-left so it
     doesn't eat half the vertical screen on phones. */
  #tool-rail {
    left: 10px;
    top: auto;
    bottom: 130px;
    transform: none;
  }
  #palette {
    grid-template-columns: repeat(6, 16px);
    gap: 3px;
    padding: 6px 5px;
    max-height: 40vh;
    transform: rotate(-1deg);
  }
  .swatch { width: 16px; height: 16px; }

  /* Brush panel docks directly under the leaderboard on the right edge
     so the two right-side stickers stack instead of fighting for room.
     Top offset = leaderboard top (12 px) + its max-height (28 vh) + a
     small gap. */
  #brush-panel {
    right: 12px;
    top: calc(12px + 28vh + 8px);
    bottom: auto;
    transform: translateY(0) rotate(0.5deg);
    width: 180px;
    padding: 10px 12px;
    gap: 10px;
  }
  .brush-row {
    grid-template-columns: 52px 1fr 36px;
    gap: 6px;
  }

  /* Bottom toolbar tightens: smaller buttons, no labels (icon-only). */
  #hud {
    bottom: 12px;
    padding: 2px;
    transform: translateX(-50%) rotate(-0.4deg);
    max-width: calc(100vw - 24px);
    overflow-x: auto;
  }
  .tool {
    padding: 8px 10px;
    font-size: 12px;
    gap: 4px;
  }
  .tool span { display: none; }   /* icons only on mobile */
  #username { display: none; }    /* shown on the leaderboard instead */

  .lobby-profile { top: 16px; left: 16px; }
  .profile-pill { font-size: 12px; padding: 6px 12px 6px 8px; }
  .profile-dot { width: 14px; height: 14px; }

  #menu-button { top: 12px; left: 12px; width: 38px; height: 38px; }

  /* Leaderboard slim & capped so the brush panel can dock beneath it. */
  #leaderboard {
    top: 12px;
    right: 12px;
    min-width: 140px;
    max-width: 45vw;
    max-height: 28vh;
    padding: 8px 10px;
    font-size: 12px;
  }
  .leaderboard-header { font-size: 14px; }
  .leaderboard-row { font-size: 12px; }

  /* Chat panel narrower & sat above the bottom toolbar. */
  #chat {
    bottom: 80px;
    left: 12px;
    width: calc(100vw - 24px);
  }

  /* Announcement banner won't overlap the menu button. */
  #announce-banner {
    top: 60px;
    font-size: 15px;
    padding: 10px 16px;
    max-width: calc(100vw - 24px);
  }

  /* Train timer chip out of the way. */
  #train-timer { bottom: 80px; }
}

/* Touch-specific shifts: when controls.js confirms an actual touch device
   (not just a narrow window), tweak a couple of layout offsets to leave
   room for the joystick + paint button. The brush panel is now docked
   below the leaderboard via the @media block above, so it doesn't need
   a touch-mode override. */
body.mobile #hud { bottom: 12px; }
body.mobile #tool-rail { bottom: 200px; }
body.mobile #chat { bottom: 140px; }
