:root {
  --bg-1: #03121f;
  --bg-2: #132c48;
  --card: rgba(8, 20, 34, 0.84);
  --line: rgba(148, 195, 255, 0.28);
  --text: #ecf4ff;
  --muted: #97b7d6;
  --accent: #57c5ff;
  --accent-2: #ffd54f;
  --danger: #ff7a7a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Outfit', sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 10%, #1e4e7f 0%, transparent 40%),
    radial-gradient(circle at 80% 90%, #0a5771 0%, transparent 45%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2));
}

html.login-screen-active,
body.login-screen-active {
  overflow-y: hidden;
}

.aurora {
  position: fixed;
  inset: -25%;
  background: conic-gradient(from 120deg, rgba(87, 197, 255, 0.22), rgba(255, 213, 79, 0.2), rgba(87, 197, 255, 0.05));
  filter: blur(70px);
  animation: drift 12s ease-in-out infinite alternate;
  z-index: 0;
}

@keyframes drift {
  from {
    transform: translate(-5%, -3%) scale(1);
  }
  to {
    transform: translate(4%, 5%) scale(1.1);
  }
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1280px, calc(100% - 16px));
  margin: 0 auto;
}

.card {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.25);
}

.login-card {
  width: min(720px, 100%);
  margin: clamp(4px, 1vh, 16px) auto;
  padding: 26px 30px 16px;
  text-align: center;
}

.login-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
}

.login-title__line {
  display: block;
}

.login-title__line--meta {
  font-size: 0.5em;
  letter-spacing: 0.14em;
}

.brand-logo {
  display: block;
  height: auto;
  object-fit: contain;
}

.brand-logo--hero {
  width: min(180px, 42vw);
  margin: 0 auto 10px;
  filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.32));
}

.version-note {
  margin: 10px 0 0;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.78;
}

.login-footer {
  margin: 12px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.65;
}

.login-footer a {
  color: var(--accent);
  text-decoration: none;
}

.login-footer a:hover {
  text-decoration: underline;
}

h1,
h2 {
  margin: 0 0 10px;
  font-family: 'Chakra Petch', sans-serif;
  letter-spacing: 0.04em;
}

p {
  color: var(--muted);
}

.login-card > p {
  margin: 0 0 10px;
}

.login-card form {
  margin: 8px auto 0;
  max-width: 560px;
}

.login-status-line {
  min-height: 1.4em;
  margin: 10px auto 0;
  max-width: 560px;
  color: var(--muted);
}

/* ─── Auth form layout ───────────────────────────────────────────────── */
.auth-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px auto 0;
  max-width: 420px;
}
.auth-panel--guest { gap: 8px; margin-top: 4px; }
.guest-btn { background: rgba(255, 255, 255, 0.08); color: var(--text, #edf5ff); }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px auto 6px;
  max-width: 420px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1 1 0;
  height: 1px;
  background: var(--line, rgba(154, 201, 255, 0.24));
}
.auth-sub__sep { margin: 0 6px; opacity: 0.5; }
.auth-panel.hidden { display: none; }
.auth-panel input {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  border-radius: 10px;
}
.auth-panel button[type="submit"],
.auth-panel > button {
  padding: 10px 16px;
}
.auth-sub {
  margin: 2px 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}
.auth-sub a { color: var(--accent, #58c7ff); text-decoration: none; }
.auth-sub a:hover { text-decoration: underline; }

/* Guest-row styling in the lobby player list. JS adds .player-row--guest. */
.player-row--guest .player-name,
.player-row--guest {
  opacity: 0.75;
}
.player-row--guest .player-name::after {
  content: ' (guest)';
  font-size: 0.78em;
  color: var(--muted);
  opacity: 0.9;
}

form {
  display: flex;
  gap: 8px;
}

input,
select,
button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
}

input,
select {
  flex: 1;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  padding: 11px 12px;
}

select {
  color-scheme: dark;
}

option {
  background: #0b1f34;
  color: var(--text);
}

button {
  background: linear-gradient(140deg, var(--accent), #31a9eb);
  color: #001321;
  border: 0;
  padding: 11px 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.06);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.danger-btn {
  background: linear-gradient(145deg, #ff8484, #ff6464);
  color: #240606;
}

.hidden {
  display: none !important;
}

.lobby-layout {
  display: grid;
  grid-template-columns: 1.15fr 1.65fr 0.9fr;
  gap: 12px;
  min-height: calc(100vh - 24px);
}

.room-layout {
  display: grid;
  grid-template-columns: 1.2fr 0.95fr;
  gap: 12px;
  min-height: calc(100vh - 24px);
}

.lobby-brand {
  grid-column: 1 / -1;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo--lobby {
  width: 72px;
  flex: 0 0 auto;
}

.lobby-brand__copy {
  min-width: 0;
}

.lobby-brand h2 {
  margin-bottom: 4px;
}

.lobby-brand p {
  margin: 0;
  color: var(--muted);
}

.room-brand {
  align-items: center;
}

.room-brand__actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
/* Admin/Map-Editor hyperlinks in the lobby header look like pill buttons. */
.room-brand__actions a {
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--line, rgba(154, 201, 255, 0.26));
  color: var(--text, #edf5ff);
  text-decoration: none;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.04);
}
.room-brand__actions a:hover {
  background: rgba(255, 255, 255, 0.1);
}

.column {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.chat-log,
.games-list,
.players-list,
.room-players {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.17);
  padding: 10px;
  overflow-y: auto;
}

.chat-log {
  flex: 1;
  min-height: 280px;
  max-height: calc(100vh - 210px);
}

.games-list,
.players-list,
.room-players {
  min-height: 220px;
}

.games-list {
  flex: 1;
  min-height: 420px;
}

.chat-form,
.create-form {
  margin-top: auto;
}

.create-form {
  margin-top: 0;
  flex-wrap: wrap;
}

.create-form__label {
  width: 100%;
  color: var(--muted);
  font-size: 0.92rem;
}

.create-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}

.create-actions button {
  flex: 1;
}

.chat-item {
  margin-bottom: 8px;
  line-height: 1.3;
}

.chat-item.player {
  color: var(--accent-2);
}

.chat-player-name {
  font-weight: 700;
}

.chat-item.system {
  color: var(--accent);
}

.game-row,
.player-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.game-row strong {
  margin-right: 8px;
}

.game-badge {
  display: inline-block;
  border: 1px solid rgba(255, 213, 79, 0.35);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.78rem;
  color: var(--accent-2);
  background: rgba(255, 213, 79, 0.08);
}

.player-row.in-game {
  border-color: rgba(255, 213, 79, 0.45);
}

.game-meta {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 5px 0 8px;
}

.status-line {
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.room-players-card {
  min-height: 0;
}

.room-settings {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

.room-settings__label {
  color: var(--muted);
  font-size: 0.92rem;
}

.room-settings__buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.room-settings__buttons button.active {
  border-color: rgba(255, 208, 111, 0.75);
  background: rgba(255, 208, 111, 0.16);
  color: #fff0c9;
}

/* Z&Z room map selector */
.room-settings__selector {
  min-width: 0;
}

.room-settings:has(.room-settings__selector) {
  display: grid;
  grid-template-columns: minmax(200px, 280px) minmax(240px, 1fr);
  gap: 14px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
  padding: 12px;
}

.room-map-list {
  display: grid;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}

.room-map-list__item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

.room-map-list__item.active {
  border-color: rgba(255, 208, 111, 0.78);
  background: rgba(255, 208, 111, 0.14);
}

.room-map-list__item:disabled {
  opacity: 1;
  cursor: default;
}

.room-map-preview {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
  min-height: 204px;
}

.room-map-preview__image {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.room-map-preview__copy {
  display: grid;
  gap: 6px;
}

.room-map-preview__copy span {
  color: var(--muted);
  font-size: 0.9rem;
}

.room-players {
  flex: 1;
}

.room-player-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) auto auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.room-player-main {
  min-width: 0;
}

.room-player-main strong,
.room-player-main span {
  display: block;
}

.room-player-main span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.92rem;
}

.room-team-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.room-team-actions button {
  padding: 8px 10px;
}

.team-chip {
  min-width: 98px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  text-align: center;
  color: var(--muted);
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.team-chip.team-1 {
  color: #ffd1c8;
  border-color: rgba(255, 126, 99, 0.55);
  background: rgba(255, 126, 99, 0.14);
}

.team-chip.team-2 {
  color: #d7e5ff;
  border-color: rgba(87, 197, 255, 0.55);
  background: rgba(87, 197, 255, 0.14);
}

.game-card {
  padding: 14px;
}

.game-card--local-nibbles-touch {
  padding: 10px;
}

.game-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#game-status {
  margin: 0;
  flex: 1;
}

#game-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  margin-top: 12px;
  margin-left: auto;
  margin-right: auto;
  background: linear-gradient(#80d8ff, #9de4ff 65%, #f7be63 65%, #e89e39);
}

.game-stage {
  position: relative;
  margin-top: 12px;
}

.game-stage #game-canvas {
  margin-top: 0;
}

.controls {
  margin: 8px 0 0;
  font-size: 0.92rem;
}

.znz-panel {
  position: absolute;
  inset: 16px;
  display: grid;
  grid-template-columns: minmax(220px, 290px) 1fr;
  grid-template-rows: auto auto 1fr;
  gap: 10px 12px;
  pointer-events: none;
}

.znz-selection-bar {
  grid-column: 1 / -1;
  justify-self: center;
  max-width: min(100%, 520px);
  padding: 8px 14px;
  border: 1px solid rgba(149, 203, 255, 0.32);
  border-radius: 999px;
  background: rgba(7, 19, 31, 0.78);
  color: #dcecff;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  text-align: center;
}

.znz-resource-bar {
  align-self: start;
  justify-self: start;
  width: max(200px, 15vw);
  padding: 6px 10px;
  border: 1px solid rgba(137, 209, 255, 0.24);
  border-radius: 10px;
  background: rgba(6, 19, 31, 0.6);
  color: #f1f8ff;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  pointer-events: auto;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  display: grid;
  gap: 3px;
}

.znz-actions {
  align-self: end;
  justify-self: start;
  width: min(100%, 250px);
  display: grid;
  gap: 8px;
  pointer-events: auto;
}

.znz-action-group,
.znz-queue-bar,
.znz-info-bar {
  border: 1px solid rgba(125, 188, 255, 0.24);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(6, 19, 31, 0.9), rgba(7, 13, 24, 0.92));
  box-shadow: 0 20px 34px rgba(0, 0, 0, 0.24);
}

.znz-action-group {
  padding: 8px 8px 10px;
  overflow: visible;
}

.znz-action-group__title {
  margin: 0 0 8px;
  color: #f1f7ff;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.znz-action-group__buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, 42px);
  gap: 6px;
}

.znz-action-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(155, 209, 255, 0.18);
  background: linear-gradient(140deg, rgba(23, 45, 68, 0.98), rgba(9, 20, 34, 0.98));
  color: #ebf5ff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
  text-align: center;
  overflow: visible;
}

.znz-action-btn__icon {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.znz-action-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  width: 190px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(146, 210, 255, 0.3);
  background: rgba(8, 18, 30, 0.96);
  color: #e8f6ff;
  font-size: 0.72rem;
  line-height: 1.3;
  text-align: left;
  white-space: pre-line;
  transform: translateY(6px);
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.28);
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 5;
}

.znz-action-btn:hover::after,
.znz-action-btn:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.znz-action-btn--build {
  border-color: rgba(255, 214, 103, 0.22);
}

.znz-action-btn--stop {
  border-color: rgba(127, 197, 255, 0.26);
}

.znz-action-btn.active {
  outline: 2px solid rgba(255, 213, 79, 0.82);
  outline-offset: 1px;
  background: linear-gradient(140deg, rgba(58, 42, 9, 0.98), rgba(22, 16, 6, 0.98));
}

.znz-right-rail {
  grid-column: 2;
  align-self: end;
  justify-self: end;
  width: min(100%, 280px);
  display: grid;
  gap: 10px;
  pointer-events: auto;
}

.znz-queue-bar {
  padding: 12px;
}

.znz-info-bar {
  padding: 12px;
}

.znz-queue-bar__title {
  margin: 0 0 10px;
  color: #f1f7ff;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.znz-queue-list {
  display: grid;
  gap: 8px;
}

.znz-queue-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: #d9ecff;
  font-size: 0.84rem;
}

.znz-queue-empty {
  color: #9fc6ea;
  font-size: 0.82rem;
}

.znz-info-bar__title {
  margin: 0 0 8px;
  color: #f1f7ff;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.znz-info-bar__status {
  margin-bottom: 10px;
  color: #9fe6ba;
  font-size: 0.8rem;
}

.znz-info-bar__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: #d9ecff;
  font-size: 0.82rem;
}

.znz-info-bar__row:first-of-type {
  border-top: 0;
}

.touch-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  width: min(100%, 336px);
  gap: 6px;
  margin: 10px auto 0;
  align-items: stretch;
}

.nibbles-touch-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 10px;
  margin-top: 10px;
  align-items: stretch;
}

.local-nibbles-touch {
  margin-top: 10px;
}

.local-nibbles-touch__label {
  margin-bottom: 6px;
  color: var(--muted);
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
}

.local-nibbles-touch__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
  align-items: stretch;
}

.swipe-pad,
.shoot-btn {
  border-radius: 14px;
  border: 1px solid var(--line);
}

.swipe-pad {
  min-height: 120px;
  background:
    radial-gradient(circle at center, rgba(87, 197, 255, 0.22), rgba(87, 197, 255, 0.02) 70%),
    rgba(255, 255, 255, 0.04);
  position: relative;
  touch-action: none;
  user-select: none;
  overflow: hidden;
}

.swipe-pad--blobby {
  background:
    linear-gradient(90deg, rgba(87, 197, 255, 0.18), rgba(255, 255, 255, 0.02) 24%, rgba(255, 255, 255, 0.02) 76%, rgba(87, 197, 255, 0.18)),
    rgba(255, 255, 255, 0.04);
}

.swipe-pad--blobby .swipe-pad__hint--blobby {
  font-size: 0.84rem;
}

.swipe-pad--blobby .swipe-pad__hint--blobby::before,
.swipe-pad--blobby .swipe-pad__hint--blobby::after {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.48);
  font-size: 1rem;
  line-height: 1;
}

.swipe-pad::before,
.swipe-pad::after {
  content: '';
  position: absolute;
  inset: 50%;
  background: rgba(255, 255, 255, 0.08);
  transform: translate(-50%, -50%);
}

.swipe-pad::before {
  width: 1px;
  height: 78%;
}

.swipe-pad::after {
  width: 78%;
  height: 1px;
}

.swipe-pad.swipe-pad--blobby::before {
  width: 1px;
  height: 74%;
}

.swipe-pad.swipe-pad--blobby::after {
  width: 80%;
  height: 1px;
  opacity: 0.35;
}

.swipe-pad--blobby .swipe-pad__hint--blobby::before {
  content: '<';
  left: 14px;
}

.swipe-pad--blobby .swipe-pad__hint--blobby::after {
  content: '>';
  right: 14px;
}

.swipe-pad__hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text);
  font-family: 'Chakra Petch', sans-serif;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.shoot-btn {
  min-height: 120px;
  background: linear-gradient(145deg, #ffb24f, #ff7d42);
  color: #1f0b03;
}

.jump-btn {
  min-height: 120px;
  border-radius: 18px;
  border: 1px solid rgba(255, 205, 107, 0.36);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.26), transparent 52%),
    linear-gradient(160deg, #ffe07f, #ff9347);
  color: #2a1205;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  touch-action: manipulation;
  user-select: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.jump-btn:active {
  transform: translateY(1px) scale(0.985);
}

.swipe-pad--compact {
  min-height: 92px;
}

.shoot-btn--compact {
  min-height: 92px;
}

.game-card--local-nibbles-touch .controls {
  margin-top: 6px;
  font-size: 0.82rem;
  text-align: center;
}

.game-card--local-nibbles-touch .local-nibbles-touch {
  margin-top: 8px;
}

.game-card--local-nibbles-touch .local-nibbles-touch__label {
  margin-bottom: 4px;
}

@media (max-width: 1120px) {
  .lobby-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .room-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .chat-log,
  .games-list,
  .players-list {
    min-height: 180px;
  }

  .app-shell {
    width: calc(100% - 8px);
    margin: 0 auto;
  }

  .column {
    padding: 10px;
  }

  .lobby-brand {
    gap: 12px;
  }

  .room-brand__actions {
    margin-left: 0;
    width: 100%;
  }

  .room-brand__actions button {
    flex: 1;
  }

  .brand-logo--lobby {
    width: 60px;
  }

  .game-card {
    padding: 10px;
  }

  #game-canvas {
    border-radius: 10px;
  }

  .controls {
    font-size: 0.86rem;
  }

  .nibbles-touch-controls {
    grid-template-columns: 1fr 92px;
  }

  .touch-controls {
    grid-template-columns: minmax(0, 1fr) 92px;
    width: min(100%, 312px);
  }

  .local-nibbles-touch__grid {
    grid-template-columns: 1fr 84px;
  }

  .room-player-row {
    grid-template-columns: 1fr;
  }

  .room-team-actions {
    justify-content: flex-start;
  }

  .room-settings:has(.room-settings__selector) {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  .room-map-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: none;
  }

  .room-map-list__item {
    width: auto;
    flex: 0 0 auto;
    padding: 5px 10px;
    font-size: 0.84rem;
  }

  .room-map-preview {
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
    min-height: auto;
  }

  .room-map-preview__image {
    border-radius: 8px;
  }

  .room-map-preview__copy {
    gap: 3px;
    font-size: 0.85rem;
  }
}

@media (max-width: 700px) and (orientation: portrait) {
  .brand-logo--hero {
    width: min(148px, 42vw);
    margin-bottom: 8px;
  }

  .lobby-brand {
    padding: 12px;
    align-items: flex-start;
  }

  .brand-logo--lobby {
    width: 48px;
  }

  .game-card--local-nibbles-touch {
    padding: 8px;
  }

  .game-card--local-nibbles-touch .game-head {
    gap: 8px;
  }

  .game-card--local-nibbles-touch .controls {
    font-size: 0.76rem;
  }

  .game-card--local-nibbles-touch .local-nibbles-touch__grid {
    grid-template-columns: 1fr 76px;
    gap: 8px;
  }

  .game-card--local-nibbles-touch .swipe-pad--compact,
  .game-card--local-nibbles-touch .shoot-btn--compact {
    min-height: 76px;
  }

  .touch-controls {
    gap: 6px;
  }

  .touch-controls .swipe-pad--blobby,
  .touch-controls .jump-btn {
    min-height: 92px;
  }

  .touch-controls .swipe-pad__hint--blobby {
    font-size: 0.78rem;
  }

  /* Z&Z / Bomberman room — compact for portrait phones */
  .room-brand {
    padding: 10px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .room-brand .brand-logo--lobby {
    width: 36px;
  }

  .room-brand h2 {
    font-size: 1rem;
    margin-bottom: 1px;
  }

  .room-brand p {
    font-size: 0.78rem;
    line-height: 1.3;
  }

  .room-brand__actions {
    gap: 5px;
  }

  .room-brand__actions button {
    font-size: 0.8rem;
    padding: 6px 10px;
  }

  /* Map selector: compact single-column, horizontal pills */
  .room-settings:has(.room-settings__selector) {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border-radius: 10px;
    margin-top: 6px;
  }

  .room-settings__selector {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }

  .room-settings__label {
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .room-map-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: none;
  }

  .room-map-list__item {
    width: auto;
    flex: 0 0 auto;
    padding: 4px 10px;
    font-size: 0.78rem;
    border-radius: 6px;
  }

  /* Map preview: hide image, show only name */
  .room-map-preview {
    display: flex;
    gap: 8px;
    padding: 8px;
    min-height: auto;
    border-radius: 8px;
    align-items: center;
  }

  .room-map-preview__image {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    flex: 0 0 auto;
  }

  .room-map-preview__copy {
    gap: 2px;
  }

  .room-map-preview__copy strong {
    font-size: 0.84rem;
  }

  .room-map-preview__copy span {
    font-size: 0.72rem;
  }

  /* Room players + chat compact */
  .room-layout .column {
    padding: 10px;
    gap: 6px;
  }

  .room-layout .column > h2 {
    font-size: 1rem;
    margin: 0;
  }

  .room-players {
    min-height: 80px;
    padding: 8px;
  }

  .chat-log {
    min-height: 100px;
    padding: 8px;
  }

  .room-player-row {
    padding: 8px;
    gap: 6px;
  }

  .room-player-main span {
    font-size: 0.8rem;
  }

  .team-chip {
    min-width: 64px;
    padding: 4px 8px;
    font-size: 0.76rem;
  }
}

/* === Z&Z Overlay Controls (ported from znz) === */

.znz-res-row {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 14px;
  position: relative;
}

.znz-res-row::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(8, 18, 30, 0.95);
  border: 1px solid rgba(146, 210, 255, 0.3);
  color: #e8f6ff;
  font-size: 0.7rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
  z-index: 5;
}

.znz-res-row:hover::after {
  opacity: 1;
}

.znz-res-label {
  font-size: 0.75rem;
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.znz-res-track {
  flex: 1;
  height: 6px;
  background: #7a2525;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.znz-res-fill {
  height: 100%;
  background: linear-gradient(90deg, #3d8a2e, #5cb340);
  border-radius: 3px;
  transition: width 0.3s;
}

.znz-res-value {
  font-size: 0.68rem;
  min-width: 68px;
  text-align: right;
  white-space: nowrap;
  color: #d0e8ff;
}

.znz-status-overlay {
  grid-column: 1 / -1;
  justify-self: center;
  max-width: min(100%, 480px);
  padding: 0;
  text-align: center;
  pointer-events: none;
}

.znz-status-msg {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(7, 19, 31, 0.75);
  border: 1px solid rgba(149, 203, 255, 0.25);
  color: #dcecff;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  animation: znzStatusFade 3s ease forwards;
}

.znz-status-msg--error {
  border-color: rgba(255, 120, 120, 0.4);
  color: #ffb8b8;
}

@keyframes znzStatusFade {
  0%, 60% { opacity: 1; }
  100% { opacity: 0; }
}

.znz-game-controls {
  position: absolute;
  top: 18px;
  right: 182px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: auto;
  transition: right 0.2s ease;
}

.znz-game-controls.znz-no-minimap {
  right: 10px;
}

.znz-game-controls button {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid rgba(125, 188, 255, 0.18);
  background: rgba(6, 19, 31, 0.6);
  color: #d0e8ff;
  font-size: 0.78rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.znz-game-controls button:hover {
  background: rgba(20, 50, 80, 0.7);
}

.znz-retreat-dialog {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  z-index: 10;
}

.znz-retreat-dialog.hidden {
  display: none;
}

.znz-retreat-dialog__box {
  padding: 20px 28px;
  border-radius: 14px;
  border: 1px solid rgba(149, 203, 255, 0.3);
  background: rgba(8, 18, 32, 0.95);
  color: #e0f0ff;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.9rem;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.znz-retreat-dialog__box p {
  margin: 0 0 16px;
}

.znz-retreat-dialog__buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.znz-retreat-dialog__buttons button {
  padding: 6px 20px;
  border-radius: 8px;
  border: 1px solid rgba(149, 203, 255, 0.3);
  background: rgba(20, 40, 60, 0.8);
  color: #e0f0ff;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
}

.znz-retreat-dialog__buttons button:hover {
  background: rgba(40, 70, 100, 0.8);
}

/* Z&Z in-game: fill viewport, hide header */
body.znz-in-game {
  overflow: hidden;
  height: 100vh;
}

body.znz-in-game .aurora,
body.znz-in-game .lobby-brand--game {
  display: none;
}

body.znz-in-game .app-shell {
  max-width: none;
  width: 100%;
  height: 100vh;
  padding: 0;
  margin: 0;
}

body.znz-in-game .game-card {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
  background: #0a0e14;
}

body.znz-in-game .game-head {
  display: none;
}

body.znz-in-game .game-stage {
  flex: 1;
  min-height: 0;
}

body.znz-in-game #game-canvas {
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
  touch-action: none;
}

body.znz-in-game .controls,
body.znz-in-game .touch-controls,
body.znz-in-game .local-nibbles-touch {
  display: none !important;
}

/* HyperSpace full-viewport mode */
body.hs-in-game {
  overflow: hidden;
  height: 100vh;
}
body.hs-in-game .aurora,
body.hs-in-game .lobby-brand--game {
  display: none;
}
body.hs-in-game .app-shell {
  max-width: none;
  width: 100%;
  height: 100vh;
  padding: 0;
  margin: 0;
}
body.hs-in-game .game-card {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
  background: #050510;
}
body.hs-in-game .game-head {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(5,5,16,0.7);
  padding: 4px 14px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  backdrop-filter: blur(4px);
}
body.hs-in-game .game-head h2,
body.hs-in-game .game-head p {
  display: none;
}
body.hs-in-game .game-head #leave-game-btn {
  font-size: 12px;
  padding: 4px 12px;
}
.hs-info-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #ccc;
  background: rgba(255,255,255,0.04);
  padding: 4px 10px;
  border-radius: 6px;
}
.hs-info-panel__title {
  color: #888;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 2px;
}
.hs-info-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}
.hs-info-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  transform: rotate(45deg);
}
.hs-info-key {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: monospace;
  font-size: 10px;
  color: #fff;
  min-width: 14px;
  text-align: center;
}
@media (max-width: 700px) {
  .hs-info-panel { display: none; }
}
body.hs-in-game .game-stage {
  flex: 1;
  min-height: 0;
}
body.hs-in-game #game-canvas {
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
  touch-action: none;
}
body.hs-in-game .controls,
body.hs-in-game .touch-controls,
body.hs-in-game .local-nibbles-touch {
  display: none !important;
}

/* TransportCity full-viewport mode — mirrors Z&Z/HyperSpace layout. */
body.tc-in-game {
  overflow: hidden;
  height: 100vh;
}
body.tc-in-game .aurora,
body.tc-in-game .lobby-brand--game {
  display: none;
}
body.tc-in-game .app-shell {
  max-width: none;
  width: 100%;
  height: 100vh;
  padding: 0;
  margin: 0;
}
body.tc-in-game .game-card {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
  background: #0a0e14;
}
body.tc-in-game .game-head {
  display: none;
}
body.tc-in-game .game-stage {
  flex: 1;
  min-height: 0;
}
body.tc-in-game #game-canvas {
  display: none;
}
.tc-3d-canvas {
  display: none;
}
body.tc-in-game .tc-3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
  touch-action: none;
  cursor: grab;
}
body.tc-in-game .tc-3d-canvas:active {
  cursor: grabbing;
}
body.tc-in-game .controls,
body.tc-in-game .touch-controls,
body.tc-in-game .local-nibbles-touch {
  display: none !important;
}

/* v260: TransportCity time-control speed bar — top-centre, hidden by
   default, shown only in TC mode. */
.tc-speedbar { display: none; }
body.tc-in-game .tc-speedbar {
  display: flex;
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 51;
  gap: 4px;
  padding: 4px 6px;
  background: rgba(7, 19, 33, 0.85);
  border: 1px solid rgba(154, 201, 255, 0.36);
  border-radius: 8px;
  font-family: Arial, sans-serif;
  user-select: none;
}
body.tc-in-game .tc-speedbar button {
  min-width: 36px;
  padding: 6px 8px;
  background: #182230;
  color: #edf5ff;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}
body.tc-in-game .tc-speedbar button:hover { background: #1f2c3d; }
body.tc-in-game .tc-speedbar button.active {
  border-color: #ffd54f;
  background: #2a3142;
  color: #ffd54f;
}

/* TransportCity HUD + minimap — DOM overlays on top of the 3D canvas.
   v227: HUD lives on the right side, BELOW the (now smaller) minimap. */
.tc-hud, .tc-minimap { display: none; }
body.tc-in-game .tc-hud {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: fixed;
  top: 158px; /* minimap top (12) + minimap height (140) + gap (6) */
  right: 8px;
  z-index: 50;
  /* v306: shrink the right-side summary so it fits on smaller / mid-
     size screens. Was 8/12 padding + 13px font + 160px min-width. */
  padding: 6px 8px;
  background: rgba(7, 19, 33, 0.82);
  border: 1px solid rgba(154, 201, 255, 0.32);
  border-radius: 5px;
  color: #eaf5ff;
  font-family: Arial, sans-serif;
  font-size: 11px;
  line-height: 1.3;
  min-width: 130px;
  max-width: 180px;
  pointer-events: none;
  user-select: none;
}
body.tc-in-game .tc-hud__row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
body.tc-in-game .tc-hud__label {
  color: rgba(255, 255, 255, 0.55);
}
body.tc-in-game .tc-hud__val {
  color: #ffd54f;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
body.tc-in-game .tc-hud__val--bad {
  color: #ff6b6b;
}
/* v264: bus fleet panel inside the HUD. The HUD itself is
   pointer-events:none so clicks fall through to the canvas; the
   bus rows turn that back on so the buttons actually click. */
body.tc-in-game .tc-hud__bus { pointer-events: auto; }
body.tc-in-game .tc-hud__bus--btns {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  justify-content: stretch;
}
body.tc-in-game .tc-hud__bus--btns button {
  flex: 1;
  padding: 3px 4px;
  background: #182230;
  color: #ffd54f;
  border: 1px solid #2d3a4d;
  border-radius: 3px;
  font: inherit;
  font-size: 10px;
  line-height: 1.2;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
}
body.tc-in-game .tc-hud__bus--btns button:hover { background: #1f2c3d; }
body.tc-in-game .tc-hud__bus--btns button:active { background: #243349; }
body.tc-in-game .tc-hud__bus--hint {
  font-size: 9.5px;
  color: #aac3e0;
  font-style: italic;
}

/* v307 / v308: tile inspector — floating tooltip pinned just above
   the mouse cursor, visible only in the Happy view. The render loop
   sets `left` / `top` and a `--tc-arrow-x` custom property so the
   bottom arrow lines up with the cursor even when the panel is
   nudged sideways to stay on-screen. */
.tc-inspector { display: none; }
body.tc-in-game .tc-inspector {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 80;
  padding: 7px 10px;
  background: rgba(7, 19, 33, 0.94);
  border: 1px solid rgba(154, 201, 255, 0.42);
  border-radius: 6px;
  color: #eaf5ff;
  font-family: Arial, sans-serif;
  font-size: 11px;
  line-height: 1.35;
  min-width: 180px;
  max-width: 260px;
  pointer-events: none;
  user-select: none;
  display: none;
  --tc-arrow-x: 50%;
}
/* Arrow pointing DOWN from the bottom of the panel toward the tile
   the cursor is over. Two stacked triangles: outer (border) + inner
   (fill) so the arrow has the same border colour as the panel. */
body.tc-in-game .tc-inspector::before,
body.tc-in-game .tc-inspector::after {
  content: '';
  position: absolute;
  left: var(--tc-arrow-x);
  transform: translateX(-50%);
  width: 0;
  height: 0;
  pointer-events: none;
}
body.tc-in-game .tc-inspector::before {
  bottom: -8px;
  border: 8px solid transparent;
  border-top-color: rgba(154, 201, 255, 0.42);
  border-bottom: 0;
}
body.tc-in-game .tc-inspector::after {
  bottom: -7px;
  border: 7px solid transparent;
  border-top-color: rgba(7, 19, 33, 0.94);
  border-bottom: 0;
}
/* When the panel had to flip BELOW the cursor (no room above), the
   arrow points up instead. */
body.tc-in-game .tc-inspector.tc-inspector--below::before {
  top: -8px;
  bottom: auto;
  border-top: 0;
  border-bottom-color: rgba(154, 201, 255, 0.42);
}
body.tc-in-game .tc-inspector.tc-inspector--below::after {
  top: -7px;
  bottom: auto;
  border-top: 0;
  border-bottom-color: rgba(7, 19, 33, 0.94);
}
body.tc-in-game .tc-inspector.tc-inspector--visible { display: block; }
body.tc-in-game .tc-inspector__title {
  font-weight: 700;
  color: #ffd54f;
  margin-bottom: 3px;
}
body.tc-in-game .tc-inspector__row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
body.tc-in-game .tc-inspector__label { color: rgba(255,255,255,0.6); }
body.tc-in-game .tc-inspector__val   { color: #eaf5ff; }
body.tc-in-game .tc-inspector__ok    { color: #6ce06c; }
body.tc-in-game .tc-inspector__bad   { color: #ff7070; }
body.tc-in-game .tc-inspector__hint {
  margin-top: 4px;
  color: #ffd54f;
  font-size: 10.5px;
}
/* v308: italic flavour quote — what the resident / shopkeeper /
   factory boss is "saying" about the tile's situation. */
body.tc-in-game .tc-inspector__quote {
  margin-top: 4px;
  padding: 4px 6px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 2px solid rgba(255, 213, 79, 0.6);
  color: #d8e8ff;
  font-style: italic;
  font-size: 10.5px;
  line-height: 1.35;
}
/* v308: thin separator between the flavour summary and the debug-only
   per-axis rows (when ?debug=true). */
body.tc-in-game .tc-inspector__debug-sep {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

/* v317: persistent bottom-left details panel — same per-axis rows
   as the cursor-anchored inspector's debug section, but always
   visible in the Happy view (and in debug mode in any view). The
   user wanted to be able to read the numbers without keeping the
   cursor over a tile. */
.tc-tile-details { display: none; }
body.tc-in-game .tc-tile-details {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 50;
  padding: 7px 9px;
  background: rgba(7, 19, 33, 0.86);
  border: 1px solid rgba(154, 201, 255, 0.32);
  border-radius: 5px;
  color: #eaf5ff;
  font-family: Arial, sans-serif;
  font-size: 11px;
  line-height: 1.35;
  min-width: 180px;
  max-width: 240px;
  pointer-events: none;
  user-select: none;
  display: none;
}
body.tc-in-game .tc-tile-details.tc-tile-details--visible { display: block; }
body.tc-in-game .tc-tile-details__title {
  font-weight: 700;
  color: #ffd54f;
  margin-bottom: 4px;
}
body.tc-in-game .tc-tile-details__row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
body.tc-in-game .tc-tile-details__label { color: rgba(255,255,255,0.6); }
body.tc-in-game .tc-tile-details__ok    { color: #6ce06c; }
body.tc-in-game .tc-tile-details__bad   { color: #ff7070; }
body.tc-in-game .tc-tile-details__sep {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.16);
}
body.tc-in-game .tc-tile-details__hint {
  margin-top: 4px;
  font-style: italic;
  color: #aac3e0;
}

/* v267: trade panel — bottom-right floating list of other players. */
.tc-trade { display: none; }
body.tc-in-game .tc-trade {
  display: block;
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 50;
  padding: 8px 10px;
  background: rgba(7, 19, 33, 0.85);
  border: 1px solid rgba(154, 201, 255, 0.36);
  border-radius: 6px;
  color: #eaf5ff;
  font-family: Arial, sans-serif;
  font-size: 12px;
  min-width: 220px;
  max-width: 280px;
  pointer-events: auto;
  user-select: none;
}
body.tc-in-game .tc-trade__title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 6px;
}
body.tc-in-game .tc-trade__row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}
body.tc-in-game .tc-trade__chip {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}
body.tc-in-game .tc-trade__name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.tc-in-game .tc-trade__cnt {
  color: #aac3e0;
  font-size: 11px;
}
body.tc-in-game .tc-trade__row button {
  padding: 3px 7px;
  background: #182230;
  color: #ffd54f;
  border: 1px solid #2d3a4d;
  border-radius: 4px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  touch-action: manipulation;
}
body.tc-in-game .tc-trade__row button:hover { background: #1f2c3d; }
body.tc-in-game .tc-trade__btn--active {
  background: #c06030 !important;
  color: #fff !important;
  border-color: #ff8030 !important;
}
body.tc-in-game .tc-trade__hint {
  margin-top: 6px;
  font-size: 11px;
  color: #ffd54f;
  font-style: italic;
}
@media (max-width: 600px) {
  body.tc-in-game .tc-trade {
    bottom: 8px;
    right: 8px;
    padding: 6px 8px;
    font-size: 11px;
    min-width: 0;
    max-width: calc(100vw - 16px);
  }
}

/* v269 research panel — replaced in v286 by a toolbar flyout.
   The floating bottom-left pill / panel is no longer used; the
   toolbar's #tc-research-flyout div hosts the perk list now. */
.tc-research { display: none !important; }
body.tc-in-game .tc-research {
  display: none !important;
}
/* v286 + v353: hide the Debug toolbar group unless body has tc-debug-on
   (set by render.js when snap.debug === true). v353 adds the dual-
   class qualifier so the specificity beats the generic
   `body.tc-in-game .tc-toolbar__group { display: flex; }` rule
   below, which used to win on cascade order and made the Debug
   menu visible to every admin regardless of the lobby checkbox. */
body.tc-in-game .tc-toolbar__group.tc-toolbar__group--debug { display: none; }
body.tc-in-game.tc-debug-on .tc-toolbar__group.tc-toolbar__group--debug { display: flex; flex-direction: column; }

/* v286: Research flyout — perk list inside the toolbar's "Research"
   group. The flyout itself uses .tc-toolbar__row--wide which the
   toolbar already styles; these rules style the perk rows we render
   into it. */
body.tc-in-game #tc-research-flyout {
  flex-direction: column;
  width: 240px;
  padding: 6px 4px;
  font-size: 12px;
  color: #eaf5ff;
}
body.tc-in-game #tc-research-flyout .tc-research__rp {
  margin-bottom: 6px;
  color: #ffd54f;
  font-size: 13px;
}
body.tc-in-game #tc-research-flyout .tc-research__row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 6px;
  padding: 5px 0;
  border-top: 1px solid rgba(154, 201, 255, 0.15);
}
body.tc-in-game #tc-research-flyout .tc-research__name {
  font-weight: 600;
  color: #edf5ff;
}
body.tc-in-game #tc-research-flyout .tc-research__desc {
  grid-column: 1 / -1;
  font-size: 11px;
  color: #aac3e0;
}
body.tc-in-game #tc-research-flyout .tc-research__owned {
  color: #6ec96e;
  font-size: 11px;
  align-self: center;
}
body.tc-in-game #tc-research-flyout .tc-research__row button {
  padding: 3px 8px;
  background: #182230;
  color: #ffd54f;
  border: 1px solid #2d3a4d;
  border-radius: 4px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  align-self: center;
  touch-action: manipulation;
}
body.tc-in-game #tc-research-flyout .tc-research__row button:hover:not(:disabled) { background: #1f2c3d; }
body.tc-in-game #tc-research-flyout .tc-research__row button:disabled { opacity: 0.45; cursor: not-allowed; }
body.tc-in-game #tc-research-flyout .tc-research__row--owned { opacity: 0.65; }
/* Collapsed pill (default) */
body.tc-in-game .tc-research__pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: rgba(7, 19, 33, 0.92);
  border: 1px solid rgba(154, 201, 255, 0.36);
  border-radius: 18px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
body.tc-in-game .tc-research__pill:hover { background: rgba(15, 30, 50, 0.95); }
body.tc-in-game .tc-research__pill-label { color: #ffd54f; font-weight: 600; }
body.tc-in-game .tc-research__pill-rp { color: #eaf5ff; font-variant-numeric: tabular-nums; }
body.tc-in-game .tc-research__pill-perks {
  color: #aac3e0;
  font-size: 11px;
  padding-left: 6px;
  border-left: 1px solid rgba(154, 201, 255, 0.25);
}
/* Expanded panel */
body.tc-in-game .tc-research--expanded {
  padding: 8px 10px;
  background: rgba(7, 19, 33, 0.85);
  border: 1px solid rgba(154, 201, 255, 0.36);
  border-radius: 6px;
  width: 240px;
}
body.tc-in-game .tc-research__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
body.tc-in-game .tc-research__close {
  background: transparent;
  border: 1px solid rgba(154, 201, 255, 0.3);
  color: #aac3e0;
  width: 22px;
  height: 22px;
  line-height: 1;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  touch-action: manipulation;
}
body.tc-in-game .tc-research__close:hover { background: rgba(255,255,255,0.08); }
body.tc-in-game .tc-research__title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
}
body.tc-in-game .tc-research__rp {
  margin-bottom: 6px;
  color: #ffd54f;
  font-size: 13px;
}
body.tc-in-game .tc-research__row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 6px;
  padding: 5px 0;
  border-top: 1px solid rgba(154, 201, 255, 0.15);
}
body.tc-in-game .tc-research__name {
  font-weight: 600;
  color: #edf5ff;
}
body.tc-in-game .tc-research__desc {
  grid-column: 1 / -1;
  font-size: 11px;
  color: #aac3e0;
}
body.tc-in-game .tc-research__owned {
  color: #6ec96e;
  font-size: 11px;
  align-self: center;
}
body.tc-in-game .tc-research__row button {
  padding: 3px 8px;
  background: #182230;
  color: #ffd54f;
  border: 1px solid #2d3a4d;
  border-radius: 4px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  touch-action: manipulation;
  align-self: center;
}
body.tc-in-game .tc-research__row button:hover:not(:disabled) { background: #1f2c3d; }
body.tc-in-game .tc-research__row button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
body.tc-in-game .tc-research__row--owned {
  opacity: 0.65;
}
@media (max-width: 600px) {
  body.tc-in-game .tc-research {
    bottom: 8px;
    left: 8px;
    font-size: 11px;
  }
  body.tc-in-game .tc-research--expanded {
    width: 200px;
    padding: 6px 8px;
  }
  body.tc-in-game .tc-research__pill {
    padding: 6px 10px;
    font-size: 11px;
  }
}

/* v270: achievement toasts (top-right) + modal listing. */
.tc-toasts { display: none; }
body.tc-in-game .tc-toasts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  pointer-events: none;
}
body.tc-in-game .tc-toast {
  padding: 8px 14px;
  background: rgba(40, 30, 8, 0.92);
  border: 1px solid #ffd54f;
  border-radius: 6px;
  color: #ffd54f;
  font-family: Arial, sans-serif;
  font-size: 13px;
  min-width: 220px;
  max-width: 360px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  transition: opacity 0.3s;
}
body.tc-in-game .tc-toast__title { font-weight: 700; }
body.tc-in-game .tc-toast__desc { font-size: 11.5px; color: #fde9a8; margin-top: 2px; }

.tc-ach-modal { display: none; }
body.tc-in-game .tc-ach-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
body.tc-in-game .tc-ach-modal[style*="display: block"] {
  display: flex !important;
}
body.tc-in-game .tc-ach-modal__inner {
  background: #121a26;
  border: 1px solid #2d3a4d;
  border-radius: 10px;
  padding: 22px 24px;
  max-width: 460px;
  width: 92%;
  max-height: 80vh;
  overflow-y: auto;
  color: #edf5ff;
  font-family: Arial, sans-serif;
}
body.tc-in-game .tc-ach-modal__title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #ffd54f;
}
body.tc-in-game .tc-ach-modal__row {
  padding: 6px 0;
  border-top: 1px solid rgba(154, 201, 255, 0.15);
}
body.tc-in-game .tc-ach-modal__row--owned { color: #6ec96e; }
body.tc-in-game .tc-ach-modal__name { font-weight: 600; }
body.tc-in-game .tc-ach-modal__desc { font-size: 12px; color: #aac3e0; margin-top: 2px; }
body.tc-in-game .tc-ach-modal__close {
  margin-top: 12px;
  padding: 8px 16px;
  background: #1c2a3c;
  color: #fff;
  border: 1px solid #444;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
body.tc-in-game .tc-ach-modal__close:hover { background: #243349; }

/* v272: tutorial overlay — semi-modal panel that appears in front
   of the canvas the first time a player joins a TC game. Once they
   click "Got it" or "Skip tutorial", the server sets stats.tutorialDone
   and the overlay never appears again for this account. */
.tc-tutorial { display: none; }
body.tc-in-game .tc-tutorial {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  width: 460px;
  max-width: calc(100vw - 24px);
  padding: 14px 18px;
  background: rgba(15, 26, 42, 0.96);
  border: 1px solid #4a8a4a;
  border-radius: 8px;
  color: #edf5ff;
  font-family: Arial, sans-serif;
  font-size: 13px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
}
body.tc-in-game .tc-tutorial__inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
body.tc-in-game .tc-tutorial__step {
  font-size: 11px;
  color: #aac3e0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
body.tc-in-game .tc-tutorial__title {
  font-size: 15px;
  font-weight: 700;
  color: #ffd54f;
}
body.tc-in-game .tc-tutorial__body {
  line-height: 1.4;
  color: #eaf5ff;
}
body.tc-in-game .tc-tutorial__btns {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  justify-content: flex-end;
}
body.tc-in-game .tc-tutorial__btns button {
  padding: 6px 14px;
  background: #1c2a3c;
  color: #fff;
  border: 1px solid #2d3a4d;
  border-radius: 5px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  touch-action: manipulation;
}
body.tc-in-game .tc-tutorial__btns button:hover { background: #243349; }
body.tc-in-game .tc-tutorial__primary {
  background: #2d6a3a !important;
  border-color: #4a8a4a !important;
}
body.tc-in-game .tc-tutorial__primary:hover { background: #357a45 !important; }
@media (max-width: 600px) {
  body.tc-in-game .tc-tutorial {
    bottom: 8px;
    width: calc(100vw - 16px);
    padding: 10px 12px;
    font-size: 12px;
  }
}

/* v293: in-game chat panel — bottom-middle. Auto-hides via the
   .tc-chat--visible class. Composing pins the input field on. */
.tc-chat { display: none; }
body.tc-in-game .tc-chat {
  display: flex;
  flex-direction: column;
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  width: 540px;
  max-width: calc(100vw - 24px);
  /* v294: 80% transparent (20% opaque) so the city stays visible
     under the panel. Text gets a subtle shadow below for legibility
     against bright tile colours. */
  background: rgba(7, 19, 33, 0.20);
  border: 1px solid rgba(154, 201, 255, 0.30);
  border-radius: 8px;
  font-family: Arial, sans-serif;
  font-size: 13px;
  color: #eaf5ff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.7);
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.25s ease;
  user-select: text;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
body.tc-in-game .tc-chat--visible,
body.tc-in-game .tc-chat--composing { opacity: 1; }
/* When neither visible nor composing, ignore clicks so the canvas
   stays interactive while the panel fades. */
body.tc-in-game .tc-chat:not(.tc-chat--visible):not(.tc-chat--composing) {
  pointer-events: none;
}
body.tc-in-game .tc-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 4px;
  border-bottom: 1px solid rgba(154, 201, 255, 0.22);
}
body.tc-in-game .tc-chat__title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
}
body.tc-in-game .tc-chat__toggle {
  font-size: 11px;
  color: #aac3e0;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}
body.tc-in-game .tc-chat__toggle input { margin: 0; cursor: pointer; }
body.tc-in-game .tc-chat__messages {
  max-height: 160px;
  overflow-y: auto;
  padding: 6px 10px;
  scrollbar-width: thin;
}
body.tc-in-game .tc-chat__msg {
  margin: 2px 0;
  line-height: 1.35;
  word-wrap: break-word;
}
body.tc-in-game .tc-chat__msg--player .tc-chat__from { font-weight: 700; }
body.tc-in-game .tc-chat__ts {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin-right: 4px;
}
body.tc-in-game .tc-chat__msg--evt   { color: #c5d2e2; font-style: italic; }
body.tc-in-game .tc-chat__msg--good  { color: #6ec96e; font-style: italic; }
body.tc-in-game .tc-chat__msg--bad   { color: #ff8c8c; font-style: italic; }
body.tc-in-game .tc-chat__input-row {
  border-top: 1px solid rgba(154, 201, 255, 0.22);
  padding: 4px 8px;
  display: none;
}
body.tc-in-game .tc-chat--composing .tc-chat__input-row { display: block; }
body.tc-in-game .tc-chat__input-row input {
  width: 100%;
  background: #182230;
  color: #edf5ff;
  border: 1px solid #2d3a4d;
  border-radius: 4px;
  padding: 5px 8px;
  font: inherit;
  font-size: 13px;
  box-sizing: border-box;
}
body.tc-in-game .tc-chat__input-row input:focus { outline: 1px solid #ffd54f; outline-offset: 1px; }
@media (max-width: 600px) {
  body.tc-in-game .tc-chat {
    bottom: 6px;
    width: calc(100vw - 16px);
    font-size: 12px;
  }
  body.tc-in-game .tc-chat__messages { max-height: 110px; }
}
body.tc-in-game .tc-minimap {
  display: block;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 50;
  /* v227: 30% smaller than the v195-era 200×200. */
  width: 140px;
  height: 140px;
  background: #072033;
  border: 1px solid rgba(154, 201, 255, 0.36);
  border-radius: 6px;
  /* pointer-events: auto (default) so clicks are blocked on the minimap
     instead of falling through to the 3D canvas behind (which would
     paint at a far-away world point). */
}

/* TransportCity zone toolbar — vertical rail on the LEFT (v227).
   Each category collapses to a single icon-and-label button; clicking
   it pops a flyout to the right with the actual paint / view buttons.
   Saves vertical space on small screens (the old horizontal bottom
   toolbar wrapped to 2-3 rows once Utilities + extra View buttons
   landed in v224-v226). */
.tc-toolbar { display: none; }
body.tc-in-game .tc-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: fixed;
  /* v248: pinned to the top-left so the flyout (which anchors to the
     toolbar's top) always has full viewport height to expand into.
     Was top: 50% with translateY(-50%) — the View flyout (13 buttons)
     could spill below the viewport when the rail was centered. */
  left: 8px;
  top: 12px;
  z-index: 50;
  gap: 4px;
  padding: 6px;
  background: rgba(7, 19, 33, 0.85);
  border: 1px solid rgba(154, 201, 255, 0.36);
  border-radius: 8px;
  font-family: Arial, sans-serif;
  user-select: none;
  /* IMPORTANT: keep overflow visible — flyouts position absolutely
     out of the rail's box. */
  overflow: visible;
}
body.tc-in-game .tc-toolbar__group {
  /* v248: NO position: relative here. The flyout (`.tc-toolbar__row`)
     uses position: absolute and we want it to anchor to the
     `.tc-toolbar` (which is `position: fixed` → acts as the offset
     parent for descendants without their own positioned ancestor),
     not to the individual category group. That way every flyout
     opens at the same Y (toolbar top) regardless of which category
     was clicked, so deeper categories like View don't fall off the
     bottom of the screen. */
  display: flex;
  flex-direction: column;
}
/* Always-visible category header. Tight width — fits "Utilities" with
   a bit of breathing room and not much more. */
body.tc-in-game .tc-toolbar__cat {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 88px;
  padding: 6px 8px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: #182230;
  color: #edf5ff;
  cursor: pointer;
  font-size: 13px;
}
body.tc-in-game .tc-toolbar__cat-ic {
  font-size: 16px;
  font-weight: bold;
  width: 18px;
  text-align: center;
}
body.tc-in-game .tc-toolbar__cat-lbl {
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #cfdcef;
}
body.tc-in-game .tc-toolbar__cat:hover { background: #1f2c3d; }
body.tc-in-game .tc-toolbar__group--open > .tc-toolbar__cat {
  background: #2a3142;
  border-color: #ffd54f;
}
/* Flyout panel: hidden by default, shown to the right of the rail
   when its group has the --open class. */
body.tc-in-game .tc-toolbar__row { display: none; }
body.tc-in-game .tc-toolbar__group--open > .tc-toolbar__row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  position: absolute;
  /* v248: anchor to the toolbar (its only positioned ancestor since
     v248 dropped `position: relative` on the group). 100% is the
     toolbar's right edge. */
  left: calc(100% + 8px);
  top: 0;
  padding: 6px;
  background: rgba(7, 19, 33, 0.95);
  border: 1px solid rgba(154, 201, 255, 0.36);
  border-radius: 6px;
  min-width: 220px;
  max-width: 360px;
  /* v248: never overflow the viewport. If the View flyout (13
     buttons) is taller than `100vh - 24px`, scroll within the panel
     instead of falling below the screen. */
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  z-index: 51;
}
/* v234: View flyout has the most buttons (13). Let it wrap to 4 per
   row by giving it a slightly larger max-width override. */
body.tc-in-game .tc-toolbar__group[data-cat="view"].tc-toolbar__group--open > .tc-toolbar__row {
  max-width: 280px;
}
body.tc-in-game .tc-toolbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 2px solid transparent;
  background: #182230;
  color: #edf5ff;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  line-height: 1;
}
/* Category-header buttons override the action-button reset above so the
   icon + label sit side by side. */
body.tc-in-game .tc-toolbar__cat {
  flex-direction: row;
  min-width: 0;
  font-weight: normal;
}
body.tc-in-game .tc-toolbar button span {
  margin-top: 4px;
  font-size: 10px;
  font-weight: normal;
  color: #aac3e0;
  letter-spacing: 0.04em;
}
body.tc-in-game .tc-toolbar__cat span { margin-top: 0; }
body.tc-in-game .tc-toolbar button:hover { background: #1f2c3d; }
body.tc-in-game .tc-toolbar button.active {
  border-color: #ffd54f;
  background: #2a3142;
}
body.tc-in-game .tc-toolbar button[data-zone="1"] { color: #3fb04a; }
body.tc-in-game .tc-toolbar button[data-zone="2"] { color: #6ba6e0; }
body.tc-in-game .tc-toolbar button[data-zone="3"] { color: #e5d255; }
body.tc-in-game .tc-toolbar button[data-zone="4"] { color: #f5e656; }
body.tc-in-game .tc-toolbar button[data-zone="5"] { color: #ff8044; }
body.tc-in-game .tc-toolbar button[data-zone="0"] { color: #ff8c8c; }
body.tc-in-game .tc-toolbar button[data-zone="16"] { color: #a0a8b8; }
body.tc-in-game .tc-toolbar button[data-zone="17"] { color: #f0a020; }
body.tc-in-game .tc-toolbar button[data-zone="18"] { color: #c06030; }
body.tc-in-game .tc-toolbar button[data-zone="19"] { color: #7a4232; }
body.tc-in-game .tc-toolbar__off { color: #aac3e0; }
body.tc-in-game .tc-toolbar button[data-view="default"] { color: #aac3e0; }
body.tc-in-game .tc-toolbar button[data-view="power"]   { color: #f5e656; }
/* Crosshair cursor while a zone is active. */
body.tc-in-game.tc-painting #game-canvas { cursor: crosshair; }
body.tc-in-game.tc-painting #game-canvas:active { cursor: crosshair; }

/* v261: mobile / touch UX. Prevent the browser's default swipe / pinch /
   double-tap-zoom gestures from fighting our pointer-events handlers,
   and remove the iOS / Android 300ms tap delay on toolbar buttons. */
body.tc-in-game #tc-3d-canvas { touch-action: none; }
body.tc-in-game .tc-toolbar button,
body.tc-in-game .tc-speedbar button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* v261: phone viewport (≤ 600px wide) tightens HUD + minimap + toolbar
   so they don't dominate the screen. Speedbar shrinks; minimap halves
   in size; HUD font drops to 11px and rows tighten. */
@media (max-width: 600px) {
  body.tc-in-game .tc-speedbar {
    top: 6px;
    padding: 2px 4px;
    gap: 2px;
  }
  body.tc-in-game .tc-speedbar button {
    min-width: 28px;
    padding: 4px 6px;
    font-size: 12px;
  }
  body.tc-in-game .tc-minimap {
    top: 6px;
    right: 6px;
    width: 90px;
    height: 90px;
  }
  body.tc-in-game .tc-hud {
    top: 102px; /* minimap top (6) + minimap height (90) + gap (6) */
    right: 6px;
    padding: 6px 8px;
    font-size: 11px;
    min-width: 120px;
  }
  body.tc-in-game .tc-toolbar {
    left: 4px;
    top: 6px;
    padding: 3px;
    gap: 2px;
  }
  body.tc-in-game .tc-toolbar button {
    min-width: 44px;
    padding: 4px 6px;
    font-size: 16px;
  }
  body.tc-in-game .tc-toolbar button span {
    font-size: 9px;
    margin-top: 2px;
  }
  body.tc-in-game .tc-toolbar__row {
    /* Flyouts can wrap onto multiple lines on narrow screens. */
    flex-wrap: wrap;
    max-width: calc(100vw - 80px);
  }
}

/* HyperSpace room: full-width settings card replaces the brand card layout */
.hs-room-wrapper {
  grid-column: 1 / -1;
}
.hs-room-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.hs-room-header__copy { flex: 1; min-width: 0; }
.hs-room-header__copy h2 { margin: 0 0 2px 0; }
.hs-room-header__copy p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.hs-room-header__actions { display: flex; gap: 8px; flex-shrink: 0; }
.hs-room-body { padding: 16px 18px; }

/* Map section */
.hs-section-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 8px;
  font-weight: 600;
}
.hs-map-section {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.hs-map-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.hs-map-preview {
  display: flex;
  gap: 14px;
  align-items: start;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  padding: 12px;
}
.hs-map-thumb {
  width: 200px;
  height: auto;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
  image-rendering: pixelated;
  flex-shrink: 0;
}
.hs-map-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.hs-map-info strong { font-size: 1rem; }
.hs-map-info span { color: var(--muted); font-size: 0.85rem; line-height: 1.4; }

/* Ship section */
.hs-ship-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.hs-ship-card {
  padding: 10px 10px 8px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  border: 2px solid #2a2a3a;
  background: #0d0d18;
  color: #fff;
}
.hs-ship-card.active { border-color: #ffcc44; background: #141428; }
.hs-ship-card__name { font-weight: bold; font-size: 13px; margin-bottom: 2px; }
.hs-ship-card__desc { font-size: 11px; color: #888; line-height: 1.3; margin-bottom: 6px; min-height: 28px; }
.hs-stat-row { display: flex; align-items: center; gap: 5px; margin-bottom: 3px; }
.hs-stat-label { font-size: 9px; color: #666; width: 52px; text-transform: capitalize; }
.hs-stat-bar { flex: 1; height: 6px; background: #1a1a2a; border-radius: 3px; overflow: hidden; }
.hs-stat-fill { height: 100%; border-radius: 3px; }

@media (max-width: 700px) {
  .hs-map-section { grid-template-columns: 1fr; }
  .hs-map-list { flex-direction: row; flex-wrap: wrap; max-height: none; }
  .hs-map-preview { flex-direction: column; }
  .hs-map-thumb { width: 100%; max-width: 280px; }
  .hs-ship-grid { grid-template-columns: 1fr 1fr; }
  .hs-room-header { flex-wrap: wrap; }
  .hs-room-header__actions { width: 100%; justify-content: flex-end; }
}

/* Off Road full-viewport mobile mode */
body.or-in-game {
  overflow: hidden;
  height: 100vh;
}
body.or-in-game .aurora,
body.or-in-game .lobby-brand--game {
  display: none;
}
body.or-in-game .app-shell {
  max-width: none;
  width: 100%;
  height: 100vh;
  padding: 0;
  margin: 0;
}
body.or-in-game .game-card {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
  background: #2a1f14;
}
body.or-in-game .game-head {
  position: fixed;
  top: 4px;
  left: 4px;
  right: 4px;
  z-index: 20;
  background: rgba(0,0,0,0.5);
  padding: 2px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
body.or-in-game .game-head h2,
body.or-in-game .game-head p {
  display: none;
}
body.or-in-game .game-head #leave-game-btn {
  font-size: 11px;
  padding: 3px 8px;
}
body.or-in-game .game-stage {
  flex: 1;
  min-height: 0;
  padding: 0;
}
body.or-in-game #game-canvas {
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
  touch-action: none;
}
body.or-in-game .controls,
body.or-in-game .touch-controls,
body.or-in-game .local-nibbles-touch {
  display: none !important;
}

/* Game summary overlay (Z&Z) */
.game-summary-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.game-summary-container {
  background: linear-gradient(135deg, #1a2a3a 0%, #0d1821 100%);
  border: 2px solid rgba(87, 197, 255, 0.4);
  border-radius: 12px;
  padding: 30px;
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.game-summary-table {
  width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 14px;
}
.game-summary-table th {
  background: rgba(87, 197, 255, 0.2); color: #57c5ff; padding: 12px 8px;
  text-align: center; border-bottom: 2px solid rgba(87, 197, 255, 0.3);
  white-space: pre-line; line-height: 1.3;
}
.game-summary-table td {
  padding: 10px 8px; text-align: center; border-bottom: 1px solid rgba(148, 195, 255, 0.15);
}
.game-summary-table tr:nth-child(even) { background: rgba(87, 197, 255, 0.05); }
.game-summary-table tr:hover { background: rgba(87, 197, 255, 0.1); }
.game-summary-table tr.winner { background: rgba(255, 215, 0, 0.15); border-left: 3px solid #ffd700; }
.game-summary-close-btn {
  display: block; margin: 20px auto 0; padding: 15px 30px; font-size: 16px; font-weight: 600;
  background: linear-gradient(135deg, #4CAF50, #45a049); color: white; border: none;
  border-radius: 8px; cursor: pointer;
}
.game-summary-close-btn:hover { background: linear-gradient(135deg, #45a049, #3d8b40); }

/* Rotation overlay — shown in portrait on narrow screens while in-game */
.rotate-overlay {
  position: fixed; inset: 0; z-index: 99999;
  background: rgba(3, 18, 31, 0.97);
  display: none; place-items: center;
  color: #d0e8ff; font-family: 'Chakra Petch', sans-serif;
  font-size: 1.2rem; text-align: center;
}
.rotate-overlay__icon { font-size: 3rem; margin-bottom: 16px; }
@media (orientation: portrait) and (max-width: 900px) {
  body.znz-in-game .rotate-overlay { display: grid; }
}
@media (orientation: landscape), (min-width: 901px) {
  .rotate-overlay { display: none !important; }
}

/* Fullscreen prompt */
.znz-fullscreen-prompt {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 20; pointer-events: auto;
  background: rgba(6, 19, 31, 0.92); border: 1px solid rgba(83, 196, 255, 0.4);
  border-radius: 14px; padding: 18px 32px; color: #53c4ff;
  font-family: 'Chakra Petch', sans-serif; font-size: 1.1rem; cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: znz-pulse 2s ease-in-out infinite;
}
.znz-fullscreen-prompt.hidden { display: none; }
@keyframes znz-pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; box-shadow: 0 10px 40px rgba(83, 196, 255, 0.3); }
}

/* Touch mode buttons (bottom-center) */
.znz-touch-controls {
  position: absolute; bottom: max(12px, env(safe-area-inset-bottom, 12px));
  left: 50%; transform: translateX(-50%);
  display: none; gap: 8px; pointer-events: auto; z-index: 5;
}
.znz-touch-btn {
  height: 44px; min-width: 80px; padding: 0 16px; border-radius: 22px;
  border: 1px solid rgba(125, 188, 255, 0.25);
  background: rgba(6, 19, 31, 0.75); color: #d0e8ff;
  font-family: 'Chakra Petch', sans-serif; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.znz-touch-btn.hidden { display: none; }
.znz-touch-btn--active {
  border-color: rgba(83, 196, 255, 0.6);
  background: rgba(20, 60, 100, 0.7); color: #53c4ff;
}

/* Long-press tooltip (touch devices) */
.znz-touch-tooltip {
  position: fixed; z-index: 9999; max-width: 220px; padding: 8px 12px;
  border-radius: 10px; border: 1px solid rgba(146, 210, 255, 0.35);
  background: rgba(8, 18, 30, 0.96); color: #e8f6ff;
  font-family: 'Chakra Petch', sans-serif; font-size: 0.78rem;
  line-height: 1.35; white-space: pre-line;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4); pointer-events: none;
  animation: znz-tt-in 0.12s ease-out;
}
@keyframes znz-tt-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Touch device overrides */
@media (pointer: coarse) {
  .znz-touch-controls { display: flex; }
  .znz-game-controls button { width: 44px; height: 44px; font-size: 1.1rem; border-radius: 10px; }
  .znz-game-controls { gap: 5px; right: 140px; }
  .znz-game-controls.znz-no-minimap { right: 10px; }
  .znz-action-btn { width: 48px; height: 48px; }
  .znz-action-btn__icon { font-size: 1.2rem; }
  .znz-action-group__buttons { grid-template-columns: repeat(auto-fit, 48px); gap: 5px; }
  .znz-retreat-dialog__buttons button { min-height: 44px; padding: 10px 24px; font-size: 0.95rem; }
  .znz-panel {
    inset: max(10px, env(safe-area-inset-top, 10px))
          max(10px, env(safe-area-inset-right, 10px))
          max(10px, env(safe-area-inset-bottom, 10px))
          max(10px, env(safe-area-inset-left, 10px));
  }
  .znz-action-btn::after, .znz-res-row::after { display: none !important; }
  .lobby-layout button, .lobby-layout input,
  .room-layout button, .room-layout input { min-height: 44px; }
  .znz-info-bar__queue-minus, .znz-info-bar__queue-cancel { width: 28px; height: 28px; font-size: 18px; }
  .lobby-layout, .room-layout { touch-action: manipulation; }
}

/* Small landscape phones — room layout */
@media (max-height: 500px) and (orientation: landscape) {
  .room-layout {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    min-height: auto;
  }

  .room-brand {
    grid-column: 1 / -1;
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
  }

  .room-brand .brand-logo--lobby {
    display: none;
  }

  .room-brand h2 {
    font-size: 0.95rem;
    margin-bottom: 0;
  }

  .room-brand p {
    font-size: 0.74rem;
    line-height: 1.25;
    margin: 0;
  }

  .room-brand .lobby-brand__copy {
    flex: 1;
    min-width: 0;
  }

  .room-brand__actions {
    margin-left: auto;
    width: auto;
    gap: 5px;
    flex-wrap: nowrap;
  }

  .room-brand__actions button {
    flex: 0 0 auto;
    min-height: 34px;
    font-size: 0.78rem;
    padding: 4px 10px;
  }

  /* Z&Z map selector — compact inline */
  .room-settings {
    margin-top: 4px;
  }

  .room-settings:has(.room-settings__selector) {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding: 6px 8px;
    border-radius: 10px;
  }

  .room-settings__selector {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
  }

  .room-settings__label {
    font-size: 0.74rem;
    white-space: nowrap;
    margin-bottom: 0;
  }

  .room-map-list {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    max-height: none;
  }

  .room-map-list__item {
    padding: 3px 8px;
    font-size: 0.74rem;
    border-radius: 5px;
  }

  /* Hide the full preview card, show just the thumbnail inline */
  .room-map-preview {
    display: none;
  }

  /* Players + chat columns */
  .room-layout .column {
    padding: 6px;
    gap: 4px;
    min-height: 0;
  }

  .room-layout .column > h2 {
    font-size: 0.82rem;
    margin: 0;
  }

  .room-players {
    min-height: 60px;
    padding: 4px;
    border-radius: 8px;
  }

  .room-player-row {
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    padding: 5px 8px;
    margin-bottom: 3px;
    border-radius: 6px;
    gap: 6px;
  }

  .room-player-main strong {
    font-size: 0.82rem;
  }

  .room-player-main span {
    font-size: 0.74rem;
  }

  .team-chip {
    min-width: 60px;
    padding: 3px 8px;
    font-size: 0.72rem;
  }

  .chat-log {
    min-height: 60px;
    max-height: none;
    padding: 6px;
    border-radius: 8px;
    font-size: 0.82rem;
  }

  .chat-form {
    gap: 4px;
  }

  .chat-form input {
    min-height: 34px;
    font-size: 0.82rem;
  }

  .chat-form button {
    min-height: 34px;
    font-size: 0.78rem;
    padding: 4px 10px;
  }

  /* Bomberman board size selector compact */
  .room-settings__buttons {
    gap: 4px;
  }

  .room-settings__buttons button {
    padding: 3px 8px;
    font-size: 0.78rem;
    min-height: 30px;
  }

  /* Override pointer:coarse 44px min-height for compact layout */
  .room-layout button,
  .room-layout input {
    min-height: 34px;
  }

  .room-map-list__item {
    min-height: 28px;
  }
}

@media (pointer: coarse) and (max-height: 500px) {
  .znz-panel { grid-template-columns: minmax(130px, 170px) 1fr; gap: 4px 6px; }
  .znz-resource-bar { width: 100%; font-size: 0.68rem; padding: 4px 6px; }
  .znz-actions { max-height: 45vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .znz-right-rail { max-height: 40vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .znz-action-group__title { font-size: 0.58rem; padding: 2px 4px; }
  .znz-game-controls { gap: 3px; }
  .znz-game-controls button { width: 38px; height: 38px; font-size: 0.95rem; }
}

/* Production queue items (Z&Z) */
.znz-info-bar__queue {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(148, 195, 255, 0.2);
}
.znz-info-bar__queue-title {
  font-size: 11px; font-weight: 600; color: #57c5ff;
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px;
}
.znz-info-bar__queue-item {
  display: flex; align-items: center; padding: 6px 8px; margin: 4px 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px; cursor: context-menu; transition: background 0.2s;
}
.znz-info-bar__queue-item:hover { background: rgba(255, 255, 255, 0.1); }
.znz-info-bar__queue-item:first-child {
  background: rgba(87, 197, 255, 0.15);
  border-color: rgba(87, 197, 255, 0.4);
}
.znz-info-bar__queue-icon {
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: bold; color: #57c5ff;
  background: rgba(87, 197, 255, 0.2); border-radius: 3px; margin-right: 8px; flex-shrink: 0;
}
.znz-info-bar__queue-label { flex: 1; font-size: 12px; color: #ecf4ff; }
.znz-info-bar__queue-progress {
  width: 50px; height: 4px; background: rgba(0, 0, 0, 0.3);
  border-radius: 2px; overflow: hidden; margin-left: 8px; flex-shrink: 0;
}
.znz-info-bar__queue-progress > div {
  height: 100%; background: linear-gradient(90deg, #4CAF50, #66BB6A);
  transition: width 0.15s ease-out;
}
.znz-info-bar__queue-minus {
  width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
  margin-left: auto; color: #ffa94d; font-size: 14px; font-weight: bold;
  cursor: pointer; border-radius: 3px; transition: all 0.2s;
}
.znz-info-bar__queue-minus:hover { background: rgba(255, 169, 77, 0.2); color: #ff922b; }
.znz-info-bar__queue-cancel {
  width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
  margin-left: 4px; color: #ff6b6b; font-size: 14px; font-weight: bold;
  cursor: pointer; border-radius: 3px; transition: all 0.2s;
}
.znz-info-bar__queue-cancel:hover { background: rgba(255, 107, 107, 0.2); color: #ff4757; }
