:root {
  --md-surface: #ffffff;
  --md-surface-container: #f8fafd;
  --md-surface-container-high: #f1f3f4;
  --md-on-surface: #1f1f1f;
  --md-on-surface-variant: #5f6368;
  --md-outline: #dadce0;
  --md-outline-strong: #bdc1c6;
  --md-primary: #1a73e8;
  --md-primary-hover: #1558b0;
  --md-primary-container: #e8f0fe;
  --md-on-primary: #ffffff;
  --md-secondary: #006a6a;
  --md-secondary-container: #e0f2f1;
  --md-error: #b3261e;
  --md-error-container: #fce8e6;
  --md-success: #0b8043;
  --md-success-container: #e6f4ea;
  --md-shadow-1: 0 1px 2px rgba(60, 64, 67, 0.18), 0 1px 3px rgba(60, 64, 67, 0.12);
  --md-shadow-2: 0 2px 6px rgba(60, 64, 67, 0.16), 0 6px 12px rgba(60, 64, 67, 0.10);
}

body.admin-page {
  min-height: 100vh;
  margin: 0;
  padding: 24px 0 48px;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--md-surface-container);
  color: var(--md-on-surface);
  font-family: Roboto, Arial, Helvetica, sans-serif;
}

body.admin-page [hidden] {
  display: none !important;
}

body.admin-page:not([data-admin-access='granted']) [data-admin-private] {
  display: none !important;
}

.admin-shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

body.admin-page:not([data-admin-access='granted']) .admin-shell {
  width: min(760px, calc(100vw - 32px));
  min-height: calc(100vh - 72px);
  align-content: center;
}

.admin-header {
  position: sticky;
  top: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid var(--md-outline);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--md-shadow-1);
  backdrop-filter: blur(10px);
}

body.admin-page:not([data-admin-access='granted']) .admin-header {
  position: static;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
}

.admin-brand__mark {
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--md-primary-container);
  border: 1px solid var(--md-outline);
  display: block;
  object-fit: contain;
  padding: 6px;
}

.admin-brand__text {
  display: grid;
  gap: 1px;
}

.admin-brand__eyebrow {
  margin: 0;
  color: var(--md-on-surface-variant);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.admin-brand__title {
  margin: 0;
  color: var(--md-on-surface);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0;
}

.admin-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill,
.badge,
.vote-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--md-outline);
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
}

.status-pill[data-state='connected'] {
  border-color: #c7e8d2;
  background: var(--md-success-container);
  color: var(--md-success);
}

.status-pill[data-state='error'] {
  border-color: #f4c7c3;
  background: var(--md-error-container);
  color: var(--md-error);
}

.auth-panel,
.admin-panel {
  border: 1px solid var(--md-outline);
  border-radius: 8px;
  background: var(--md-surface);
  box-shadow: var(--md-shadow-1);
}

.auth-panel {
  padding: 16px;
}

body.admin-page:not([data-admin-access='granted']) .auth-panel {
  padding: 24px;
}

.auth-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.auth-form--google {
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: center;
}

body.admin-page:not([data-admin-access='granted']) .auth-form--google {
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

.auth-summary {
  display: grid;
  gap: 4px;
}

.auth-kicker {
  margin: 0;
  color: var(--md-error);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-summary h2 {
  margin: 0;
  color: var(--md-on-surface);
  font-size: 1.05rem;
  font-weight: 500;
}

.auth-summary p {
  margin: 0;
  color: var(--md-on-surface-variant);
  font-size: 0.9rem;
  line-height: 1.4;
}

.auth-actions,
.form-actions,
.hazard-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

body.admin-page:not([data-admin-access='granted']) .auth-actions {
  align-items: flex-start;
}

.workspace-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--md-outline);
  border-radius: 8px;
  background: var(--md-surface);
  box-shadow: var(--md-shadow-1);
  width: fit-content;
  max-width: 100%;
  flex-wrap: wrap;
}

.workspace-tab,
.tool-button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--md-on-surface-variant);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.workspace-tab:hover,
.tool-button:hover {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
}

.workspace-tab.is-active,
.tool-button.is-active {
  background: var(--md-primary-container);
  color: var(--md-primary);
}

.admin-workspaces,
.admin-workspace {
  display: grid;
  gap: 16px;
}

.admin-main {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.admin-panel {
  padding: 16px;
  display: grid;
  gap: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 {
  margin: 0;
  color: var(--md-on-surface);
  font-size: 1.15rem;
  line-height: 1.25;
  font-weight: 500;
  letter-spacing: 0;
}

.filter-grid,
.field-duo,
.field-trio,
.field-quartet {
  display: grid;
  gap: 12px;
}

.filter-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.field-duo {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.field-trio {
  grid-template-columns: repeat(3, minmax(128px, 1fr));
}

.field-quartet {
  grid-template-columns: repeat(4, minmax(96px, 1fr));
}

label,
.filter-grid label,
.auth-form label,
form#prompt-form label,
#mini-prompt-form label,
#promo-redirect-form label,
#access-code-form label,
.json-tools label,
.level-meta-form label,
.field-trio label,
.field-quartet label {
  display: grid;
  gap: 6px;
  color: var(--md-on-surface-variant);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

input[type='email'],
input[type='number'],
input[type='password'],
input[type='text'],
select,
textarea {
  width: 100%;
  min-height: 44px;
  border-radius: 4px;
  border: 1px solid var(--md-outline-strong);
  background: var(--md-surface);
  color: var(--md-on-surface);
  padding: 10px 12px;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

select {
  cursor: pointer;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.prompt-row:focus-visible,
.level-cell:focus-visible {
  border-color: var(--md-primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.18);
}

input:disabled,
select:disabled,
textarea:disabled,
button:disabled,
textarea[readonly] {
  cursor: not-allowed;
}

input:disabled,
select:disabled,
textarea:disabled,
textarea[readonly] {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
}

.prompt-list {
  display: grid;
  gap: 8px;
  max-height: 62vh;
  overflow: auto;
  padding-right: 2px;
}

.prompt-row {
  border: 1px solid var(--md-outline);
  border-radius: 8px;
  padding: 12px;
  background: var(--md-surface);
  display: grid;
  gap: 8px;
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.prompt-row:hover {
  border-color: var(--md-primary);
  background: #fbfcff;
  box-shadow: var(--md-shadow-1);
}

.prompt-row__title {
  margin: 0;
  color: var(--md-on-surface);
  font-size: 0.95rem;
  line-height: 1.35;
  font-weight: 500;
  letter-spacing: 0;
}

.prompt-row__meta {
  margin: 0;
  color: var(--md-on-surface-variant);
  font-size: 0.82rem;
  line-height: 1.35;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.prompt-row__votes {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.vote-pill {
  min-height: 28px;
  padding: 4px 10px;
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
}

.vote-pill--up {
  border-color: #c7e8d2;
  background: var(--md-success-container);
  color: var(--md-success);
}

.vote-pill--down,
.vote-pill--negative {
  border-color: #f4c7c3;
  background: var(--md-error-container);
  color: var(--md-error);
}

.vote-pill--net {
  border-color: #d2e3fc;
  background: var(--md-primary-container);
  color: var(--md-primary);
}

form#prompt-form,
#mini-prompt-form,
#promo-redirect-form,
#access-code-form,
#signal-symbol-form,
.level-meta-form,
.json-tools,
.camera-editor,
.hazard-editor {
  display: grid;
  gap: 12px;
}

.field-group {
  display: grid;
  gap: 8px;
}

.json-tools {
  padding-top: 2px;
}

.json-tools textarea {
  min-height: 190px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 0.86rem;
  line-height: 1.45;
  white-space: pre;
  overflow: auto;
}

.helper {
  color: var(--md-on-surface-variant);
  font-size: 0.85rem;
  line-height: 1.4;
  margin: 0;
}

.btn {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 0 20px;
  background: var(--md-primary);
  color: var(--md-on-primary);
  box-shadow: none;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.btn:hover:not(:disabled) {
  background: var(--md-primary-hover);
  box-shadow: var(--md-shadow-1);
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.btn.is-disabled,
.btn[aria-disabled='true'] {
  opacity: 0.48;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--ghost {
  border-color: var(--md-outline-strong);
  background: var(--md-surface);
  color: var(--md-primary);
}

.btn--ghost:hover:not(:disabled) {
  border-color: var(--md-primary);
  background: var(--md-primary-container);
  box-shadow: none;
}

.badge {
  background: var(--md-primary-container);
  border-color: #d2e3fc;
  color: var(--md-primary);
}

.admin-note {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--md-outline);
  border-radius: 8px;
  background: var(--md-surface-container);
}

.admin-note h3 {
  margin: 0;
  color: var(--md-on-surface);
  font-size: 0.98rem;
  font-weight: 500;
}

.admin-note p {
  margin: 0;
  color: var(--md-on-surface-variant);
  font-size: 0.86rem;
  line-height: 1.4;
}

.admin-note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 0.82rem;
}

.level-designer {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(560px, 1.28fr);
  gap: 16px;
  align-items: start;
}

.level-editor-panel {
  gap: 14px;
}

.level-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px;
  border: 1px solid var(--md-outline);
  border-radius: 8px;
  background: var(--md-surface-container);
}

.level-toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--md-outline);
  border-radius: 8px;
  background: var(--md-surface);
  color: var(--md-on-surface);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.level-toggle-control input {
  accent-color: var(--md-primary);
}

.tile-palette {
  gap: 8px;
}

.tool-button {
  min-width: 92px;
}

.tile-token {
  min-width: 108px;
  cursor: pointer;
}

.tile-token:disabled {
  cursor: not-allowed;
}

.tile-token__swatch {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--md-outline-strong);
  background: var(--md-surface);
  flex: 0 0 auto;
}

.tile-token__swatch--wall {
  background: #3c4043;
}

.tile-token__swatch--circle {
  border-radius: 999px;
  background: #3c4043;
}

.tile-token__swatch--road {
  background: #2f343b;
}

.tile-token__swatch--intersection {
  background:
    linear-gradient(90deg, transparent 36%, #f8fafc 36% 46%, transparent 46% 54%, #f8fafc 54% 64%, transparent 64%),
    linear-gradient(0deg, transparent 36%, #f8fafc 36% 46%, transparent 46% 54%, #f8fafc 54% 64%, transparent 64%),
    #2f343b;
}

.tile-token__swatch--start {
  background: var(--md-secondary-container);
}

.tile-token__swatch--goal {
  background: var(--md-success-container);
}

.tile-token__swatch--exit {
  background: #ffffff;
  border: 3px solid var(--md-error);
}

.tile-token__swatch--hazard {
  border: 3px solid #fbbc04;
}

.tile-token__swatch--camera {
  background:
    linear-gradient(135deg, rgba(60, 154, 147, 0.86), rgba(251, 188, 4, 0.48)),
    var(--md-surface);
}

.tile-token__swatch--pickup {
  background: #8ff7c8;
}

.tile-token__swatch--dropoff {
  background: #3c9a93;
}

.tile-token__swatch--decor {
  background: #8b7e45;
}

.tile-token__swatch--water {
  background: #28beff;
}

.tile-token__swatch--erase {
  background:
    linear-gradient(135deg, transparent 42%, var(--md-error) 43%, var(--md-error) 57%, transparent 58%),
    var(--md-surface);
}

.level-grid-wrap {
  width: 100%;
  overflow: auto;
  max-height: 78vh;
  padding: 12px;
  border-radius: 8px;
  background: var(--md-surface-container);
  border: 1px solid var(--md-outline);
}

.level-grid {
  --cell-size: 42px;
  display: grid;
  position: relative;
  width: max-content;
  border: 1px solid var(--md-outline-strong);
  background: var(--md-outline-strong);
  touch-action: pan-y;
}

.level-map-editor {
  display: block;
  overflow: hidden;
  background: #101418;
  touch-action: none;
  transform: scale(var(--level-zoom, 1));
  transform-origin: top left;
}

.level-map-editor__image,
.level-map-editor__fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.level-map-editor__image {
  object-fit: fill;
  opacity: 0.92;
  user-select: none;
}

.level-map-editor__fallback {
  display: grid;
  place-items: center;
  color: var(--md-on-surface-variant);
  background:
    linear-gradient(135deg, rgba(60, 154, 147, 0.16), rgba(251, 188, 4, 0.08)),
    #101418;
  font-weight: 800;
}

.level-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border: 1px solid var(--md-outline);
  background: var(--md-surface);
  position: relative;
  cursor: pointer;
}

.level-cell:hover:not(.is-locked) {
  outline: 2px solid var(--md-primary);
  outline-offset: -2px;
}

.level-grid.is-locked .level-cell,
.level-cell.is-locked {
  cursor: not-allowed;
}

.level-cell.is-wall {
  background: #3c4043;
}

.level-cell.is-road {
  background: #2f343b;
}

.level-cell.is-intersection {
  background:
    linear-gradient(90deg, transparent 39%, #f8fafc 39% 44%, transparent 44% 56%, #f8fafc 56% 61%, transparent 61%),
    linear-gradient(0deg, transparent 39%, #f8fafc 39% 44%, transparent 44% 56%, #f8fafc 56% 61%, transparent 61%),
    #2f343b;
}

.level-cell.is-start {
  background: var(--md-secondary-container);
}

.level-cell.is-goal {
  background: var(--md-success-container);
}

.level-cell.is-hazard {
  box-shadow: inset 0 0 0 4px #fbbc04;
}

.level-cell.is-pickup {
  background: #8ff7c8;
}

.level-cell.is-dropoff {
  background: #3c9a93;
}

.level-cell.is-decor {
  background: #8b7e45;
}

.level-cell.is-selected-hazard {
  box-shadow: inset 0 0 0 4px var(--md-error);
}

.camera-region {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: start;
  padding: 4px 6px;
  border: 2px solid rgba(60, 154, 147, 0.8);
  background: rgba(60, 154, 147, 0.13);
  color: var(--md-on-surface);
  font-size: 0.7rem;
  font-weight: 800;
  pointer-events: none;
  text-align: left;
}

.camera-region.is-active {
  border-color: #fbbc04;
  background: rgba(251, 188, 4, 0.16);
}

.map-camera-region {
  z-index: 5;
  pointer-events: auto;
  cursor: move;
  min-width: 42px;
  min-height: 30px;
}

.map-patrol-lines {
  position: absolute;
  inset: 0;
  z-index: 6;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.map-patrol-line {
  fill: none;
  stroke: rgba(251, 188, 4, 0.72);
  stroke-width: 0.08;
  vector-effect: non-scaling-stroke;
}

.map-patrol-line.is-active {
  stroke: var(--md-error);
  stroke-width: 0.12;
}

.map-point {
  position: absolute;
  z-index: 8;
  width: 28px;
  height: 28px;
  border: 2px solid var(--md-surface);
  border-radius: 999px;
  translate: -50% -50%;
  display: grid;
  place-items: center;
  color: var(--md-on-surface);
  font-size: 0.75rem;
  font-weight: 900;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.34);
  cursor: grab;
}

.map-point--patrol {
  background: #fbbc04;
}

.map-point--patrol.is-active {
  background: var(--md-error);
  color: var(--md-on-primary);
}

.map-point--start {
  background: var(--md-secondary-container);
}

.map-point--goal {
  background: var(--md-success-container);
}

.map-point--exit {
  background: #ffffff;
  color: var(--md-error);
}

.map-point--chest {
  background: var(--md-success-container);
}

.map-edge-wall {
  position: absolute;
  z-index: 7;
  background: rgba(20, 24, 28, 0.92);
  box-shadow: 0 0 0 1px rgba(255, 246, 238, 0.35);
  pointer-events: auto;
  cursor: move;
}

.map-edge-wall--vertical {
  width: 5px;
  translate: -50% 0;
}

.map-edge-wall--horizontal {
  height: 5px;
  translate: 0 -50%;
}

.map-edge-wall.is-active {
  background: var(--md-error);
  box-shadow: 0 0 0 2px rgba(255, 246, 238, 0.9);
}

.map-custom-wall {
  position: absolute;
  z-index: 7;
  min-width: 6px;
  min-height: 6px;
  border-radius: 6px;
  background: rgba(20, 24, 28, 0.9);
  box-shadow:
    0 0 0 1px rgba(255, 246, 238, 0.42),
    0 2px 7px rgba(0, 0, 0, 0.34);
  pointer-events: auto;
  cursor: move;
}

.map-custom-circle {
  position: absolute;
  z-index: 7;
  min-width: 8px;
  min-height: 8px;
  border-radius: 999px;
  background: rgba(20, 24, 28, 0.9);
  box-shadow:
    0 0 0 1px rgba(255, 246, 238, 0.42),
    0 2px 7px rgba(0, 0, 0, 0.34);
  pointer-events: auto;
  cursor: move;
}

.map-custom-circle.is-active {
  background: var(--md-error);
  box-shadow:
    0 0 0 2px rgba(255, 246, 238, 0.9),
    0 2px 8px rgba(0, 0, 0, 0.36);
}

.map-custom-wall.is-active {
  background: var(--md-error);
  box-shadow:
    0 0 0 2px rgba(255, 246, 238, 0.9),
    0 2px 8px rgba(0, 0, 0, 0.36);
}

.map-wall-handle,
.map-resize-handle {
  position: absolute;
  z-index: 9;
  width: 12px;
  height: 12px;
  border: 2px solid var(--md-surface);
  border-radius: 999px;
  background: var(--md-primary);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.32);
}

.map-edge-wall--vertical .map-wall-handle {
  left: 50%;
  translate: -50% -50%;
  cursor: ns-resize;
}

.map-edge-wall--vertical .map-wall-handle--start {
  top: 0;
}

.map-edge-wall--vertical .map-wall-handle--end {
  top: 100%;
}

.map-edge-wall--horizontal .map-wall-handle {
  top: 50%;
  translate: -50% -50%;
  cursor: ew-resize;
}

.map-edge-wall--horizontal .map-wall-handle--start {
  left: 0;
}

.map-edge-wall--horizontal .map-wall-handle--end {
  left: 100%;
}

.map-custom-wall--vertical .map-wall-handle {
  left: 50%;
  translate: -50% -50%;
  cursor: ns-resize;
}

.map-custom-wall--vertical .map-wall-handle--start {
  top: 0;
}

.map-custom-wall--vertical .map-wall-handle--end {
  top: 100%;
}

.map-custom-wall--horizontal .map-wall-handle {
  top: 50%;
  translate: -50% -50%;
  cursor: ew-resize;
}

.map-custom-wall--horizontal .map-wall-handle--start {
  left: 0;
}

.map-custom-wall--horizontal .map-wall-handle--end {
  left: 100%;
}

.map-resize-handle {
  translate: -50% -50%;
}

.map-resize-handle--nw,
.map-resize-handle--n,
.map-resize-handle--ne {
  top: 0;
}

.map-resize-handle--sw,
.map-resize-handle--s,
.map-resize-handle--se {
  top: 100%;
}

.map-resize-handle--nw,
.map-resize-handle--w,
.map-resize-handle--sw {
  left: 0;
}

.map-resize-handle--ne,
.map-resize-handle--e,
.map-resize-handle--se {
  left: 100%;
}

.map-resize-handle--n,
.map-resize-handle--s {
  left: 50%;
}

.map-resize-handle--w,
.map-resize-handle--e {
  top: 50%;
}

.map-resize-handle--nw,
.map-resize-handle--se {
  cursor: nwse-resize;
}

.map-resize-handle--ne,
.map-resize-handle--sw {
  cursor: nesw-resize;
}

.map-resize-handle--n,
.map-resize-handle--s {
  cursor: ns-resize;
}

.map-resize-handle--e,
.map-resize-handle--w {
  cursor: ew-resize;
}

.level-inspector {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--md-outline);
  border-radius: 8px;
  background: var(--md-surface-container);
}

.level-inspector h3 {
  margin: 0 0 4px;
}

.level-inspector__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.level-wall-width-control {
  display: grid;
  gap: 4px;
  min-width: 148px;
  color: var(--md-on-surface-variant);
  font-size: 0.74rem;
  font-weight: 800;
}

.level-wall-width-control input {
  width: 100%;
  accent-color: var(--md-primary);
}

.level-cell__edge {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  background: transparent;
}

.level-cell__edge--top,
.level-cell__edge--bottom {
  left: -1px;
  right: -1px;
  height: 4px;
}

.level-cell__edge--top {
  top: -2px;
}

.level-cell__edge--bottom {
  bottom: -2px;
}

.level-cell__edge--left,
.level-cell__edge--right {
  top: -1px;
  bottom: -1px;
  width: 4px;
}

.level-cell__edge--left {
  left: -2px;
}

.level-cell__edge--right {
  right: -2px;
}

.level-cell.has-edge-top .level-cell__edge--top,
.level-cell.has-edge-right .level-cell__edge--right,
.level-cell.has-edge-bottom .level-cell__edge--bottom,
.level-cell.has-edge-left .level-cell__edge--left {
  background: #111827;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.44);
}

.level-cell__label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--md-on-surface);
  font-size: 0.72rem;
  font-weight: 700;
  pointer-events: none;
}

.level-cell.is-wall .level-cell__label {
  color: var(--md-on-primary);
}

.town-map-editor {
  display: grid;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
}

.town-map-editor[hidden] {
  display: none;
}

.panel-head--compact {
  align-items: start;
}

.panel-head--compact h3 {
  margin: 0 0 4px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.backseat-builder-shell {
  display: grid;
  grid-template-columns: minmax(210px, 260px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.backseat-toolbox {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 12px;
  padding: 12px;
  border: 1px solid var(--md-outline);
  border-radius: 8px;
  background: var(--md-surface-container);
}

.backseat-toolbox__group {
  display: grid;
  gap: 8px;
}

.backseat-toolbox__group + .backseat-toolbox__group {
  padding-top: 12px;
  border-top: 1px solid var(--md-outline);
}

.backseat-toolbox__label {
  color: var(--md-on-surface-variant);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.segmented-control .tool-button {
  justify-content: center;
}

.toggle-row {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--md-on-surface);
  font-size: 0.86rem;
  font-weight: 700;
}

.toggle-row--nested {
  margin-left: 18px;
  color: var(--md-on-surface-variant);
  font-size: 0.78rem;
}

.backseat-toolbox label {
  display: grid;
  gap: 4px;
  color: var(--md-on-surface-variant);
  font-size: 0.8rem;
  font-weight: 700;
}

.backseat-toolbox label.toggle-row {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  color: var(--md-on-surface);
  font-size: 0.86rem;
  line-height: 1.25;
  text-align: left;
  width: fit-content;
}

.backseat-toolbox label.toggle-row--nested {
  color: var(--md-on-surface-variant);
  font-size: 0.78rem;
}

.backseat-toolbox label.toggle-row input {
  flex: 0 0 auto;
  width: 16px;
  min-height: 16px;
}

.town-map-zoom-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.town-map-toolbar-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.town-map-zoom-control {
  display: grid;
  gap: 5px;
}

.town-map-building-preview {
  width: 100%;
  min-height: 82px;
  border: 1px solid var(--md-outline);
  border-radius: 8px;
  background-color: var(--md-surface);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.town-map-building-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.town-map-building-cell {
  min-height: 46px;
  border: 1px solid var(--md-outline);
  border-radius: 7px;
  background-color: var(--md-surface);
  background-repeat: no-repeat;
  cursor: pointer;
}

.town-map-building-cell.is-active {
  border-color: var(--md-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--md-primary) 30%, transparent);
}

.building-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.building-preset {
  min-height: 34px;
  border: 1px solid var(--md-outline);
  border-radius: 7px;
  background: var(--md-surface);
  color: var(--md-on-surface);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

.building-preset.is-active,
.segmented-control .tool-button.is-active {
  border-color: var(--md-primary);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
}

.town-map-inspector {
  display: grid;
  gap: 10px;
}

.town-map-inspector-fields {
  display: grid;
  gap: 10px;
}

.town-map-inspector-fields[hidden] {
  display: none;
}

.town-map-inspector .field-quartet {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.town-map-inspector-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.town-map-inspector-actions #town-map-auto-hitbox {
  grid-column: 1 / -1;
}

.town-map-validation {
  display: grid;
  gap: 6px;
}

.town-map-validation__item {
  display: block;
  padding: 6px 8px;
  border: 1px solid var(--md-outline);
  border-radius: 7px;
  color: var(--md-on-surface);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.3;
}

.town-map-validation__item--good {
  border-color: color-mix(in srgb, var(--md-success) 38%, var(--md-outline));
  background: color-mix(in srgb, var(--md-success-container) 55%, transparent);
}

.town-map-validation__item--warn {
  border-color: color-mix(in srgb, var(--md-error) 42%, var(--md-outline));
  background: color-mix(in srgb, var(--md-error-container) 55%, transparent);
}

.town-map-canvas-wrap {
  overflow: auto;
  max-height: 78vh;
  border: 1px solid var(--md-outline-strong);
  border-radius: 8px;
  background: #101418;
}

#town-map-canvas {
  display: block;
  width: 990px;
  height: 630px;
  cursor: crosshair;
}

[data-town-map-tool='pan'].is-active ~ #town-map-canvas,
#town-map-canvas:active {
  cursor: grab;
}

@media (max-width: 980px) {
  .backseat-builder-shell {
    grid-template-columns: 1fr;
  }

  .backseat-toolbox {
    position: static;
  }
}

body[data-level-game='backseatDriver'] .level-editor-panel {
  gap: 16px;
}

body[data-level-game='backseatDriver'] .level-meta-form {
  max-width: 720px;
}

.level-list .prompt-row.is-active {
  border-color: var(--md-primary);
  background: var(--md-primary-container);
}

.level-zoom-control {
  min-width: 150px;
  display: grid;
  gap: 3px;
  color: var(--md-on-surface-variant);
  font-size: 0.78rem;
  font-weight: 700;
}

#promo-list .prompt-row.is-active {
  border-color: var(--md-primary);
  background: var(--md-primary-container);
}

.signal-symbol-list .prompt-row.is-active {
  border-color: var(--md-primary);
  background: var(--md-primary-container);
}

.signal-symbol-editor-panel {
  gap: 14px;
}

.signal-symbol-layout {
  display: grid;
  grid-template-columns: minmax(300px, max-content) minmax(220px, 1fr);
  gap: 16px;
  align-items: start;
}

.signal-symbol-grid-wrap {
  width: max-content;
  max-width: 100%;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: var(--md-surface-container);
  border: 1px solid var(--md-outline);
}

.signal-symbol-grid {
  --symbol-cell-size: 22px;
  display: grid;
  grid-template-columns: repeat(16, var(--symbol-cell-size));
  grid-template-rows: repeat(16, var(--symbol-cell-size));
  width: max-content;
  border: 1px solid var(--md-outline-strong);
  background: var(--md-outline-strong);
  touch-action: none;
}

.signal-symbol-cell {
  width: var(--symbol-cell-size);
  height: var(--symbol-cell-size);
  border: 1px solid var(--md-outline);
  background: var(--md-surface);
  cursor: pointer;
}

.signal-symbol-cell:hover:not(:disabled),
.signal-symbol-cell:focus-visible {
  outline: 2px solid var(--md-primary);
  outline-offset: -2px;
}

.signal-symbol-cell.is-on {
  background: var(--signal-symbol-color, #ffe7a6);
}

.signal-symbol-grid.is-locked .signal-symbol-cell {
  cursor: not-allowed;
}

.signal-symbol-side {
  display: grid;
  gap: 12px;
}

.signal-symbol-preview {
  --preview-cell-size: 8px;
  display: grid;
  grid-template-columns: repeat(16, var(--preview-cell-size));
  grid-template-rows: repeat(16, var(--preview-cell-size));
  width: max-content;
  padding: 12px;
  border: 1px solid var(--md-outline);
  border-radius: 8px;
  background: #071019;
}

.signal-symbol-preview__cell {
  width: var(--preview-cell-size);
  height: var(--preview-cell-size);
  background: transparent;
}

.signal-symbol-preview__cell.is-on {
  background: var(--signal-symbol-color, #ffe7a6);
}

.promo-link-preview {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--md-outline);
  border-radius: 8px;
  background: var(--md-surface-container);
}

.promo-link-preview span {
  color: var(--md-on-surface-variant);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.promo-link-preview a {
  min-width: 0;
  color: var(--md-primary);
  font-size: 0.92rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.hazard-editor {
  padding: 12px;
  border-radius: 8px;
  background: var(--md-surface-container);
  border: 1px solid var(--md-outline);
}

.hazard-path {
  min-height: 40px;
  border-radius: 4px;
  border: 1px solid var(--md-outline);
  background: var(--md-surface);
  color: var(--md-on-surface-variant);
  padding: 10px 12px;
  font-size: 0.88rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

@media (max-width: 1080px) {
  .admin-main,
  .level-designer,
  .signal-symbol-layout {
    grid-template-columns: 1fr;
  }

  .workspace-tabs {
    width: 100%;
  }
}

@media (max-width: 720px) {
  body.admin-page {
    padding-top: 12px;
  }

  .admin-shell {
    width: min(100vw - 20px, 1280px);
    gap: 12px;
  }

  .admin-header {
    position: static;
    flex-direction: column;
    align-items: flex-start;
  }

  .admin-status {
    justify-content: flex-start;
  }

  .prompt-list {
    max-height: none;
  }

  .auth-form,
  .auth-form--google,
  .field-trio {
    grid-template-columns: 1fr;
  }

  .workspace-tab,
  .tool-button {
    flex: 1 1 150px;
  }

  .level-grid {
    --cell-size: 26px;
  }
}
