:root {
  color-scheme: light;
  --ink: #18211f;
  --muted: #6d7771;
  --paper: #f7f3ea;
  --panel: #fffdfa;
  --line: #d9d1c3;
  --accent: #c9472c;
  --accent-2: #18746b;
  --gold: #d99f2b;
  --shadow: 0 22px 70px rgba(42, 31, 20, .16);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Aptos", "Malgun Gothic", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(24,33,31,.07) 1px, transparent 1px),
    linear-gradient(rgba(24,33,31,.06) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; box-shadow: none; }

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid var(--ink);
  background: var(--gold);
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 5px 5px 0 var(--ink);
}

.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); margin-top: 2px; }

.identity {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.identity-editor {
  display: grid;
  gap: 0;
  justify-items: end;
  line-height: 1.2;
  cursor: text;
}

.identity-name {
  width: min(220px, 42vw);
  height: auto;
  min-height: 0;
  border: 1px solid transparent;
  border-radius: 0;
  margin: 0;
  padding: 0 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  line-height: 1.2;
  text-align: right;
  outline: none;
}

.identity-name:hover {
  border-color: var(--line);
}

.identity-name:focus {
  border-color: var(--ink);
  background: #fff;
}

.name-hint {
  margin-top: 2px;
  padding-right: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-style: italic;
  line-height: 1.2;
}

.name-hint.hidden {
  display: none;
}

.identity-status {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.identity-status .status-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.identity-status .status-ring {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.identity-status .status-check {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.identity-status.is-pending {
  color: #9aa5a0;
}

.identity-status.is-pending .status-ring {
  fill: currentColor;
  stroke: none;
  opacity: 0.85;
}

.identity-status.is-connected {
  color: #1f6feb;
}

.identity-status.is-connected .status-check {
  opacity: 1;
}

.identity-status.is-failed {
  color: var(--accent);
}

.identity-status.is-failed .status-ring {
  fill: currentColor;
  stroke: none;
}

.identity-status.is-failed .status-check {
  display: none;
}

.workspace {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 22px;
  padding-top: 22px;
}

.workspace.dashboard-only,
.workspace.setup-only {
  grid-template-columns: 1fr;
}

.panel, .answer-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.creator-panel {
  position: sticky;
  top: 18px;
  align-self: start;
  padding: 18px;
  background:
    linear-gradient(160deg, rgba(217, 159, 43, 0.18) 0%, transparent 46%),
    linear-gradient(180deg, #efe6d4 0%, #e4dac6 100%);
  border-color: var(--ink);
  box-shadow: 6px 6px 0 rgba(24, 33, 31, 0.18);
}

.visibility-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 4px;
  background: transparent;
}

.visibility-option {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 42px;
  cursor: pointer;
  font-weight: 800;
}

.visibility-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.visibility-option span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  background: #efeae0;
  color: var(--muted);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease, color .14s ease, border-color .14s ease;
}

.visibility-option input:checked + span {
  border-color: var(--ink);
  background: var(--gold);
  color: var(--ink);
  transform: translate(-3px, -3px);
  box-shadow: 4px 4px 0 var(--ink);
}

.visibility-option input:focus-visible + span {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.creator-heading {
  margin: 22px 0 12px;
  font-size: 1.05rem;
  font-weight: 850;
}

.game-picker {
  display: grid;
  gap: 10px;
}

.game-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--ink);
  background: #fff;
  box-shadow: 5px 5px 0 var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}

.game-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 var(--ink);
}

.game-card:active {
  transform: translate(1px, 1px);
  box-shadow: 3px 3px 0 var(--ink);
}

.game-card img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--paper);
}

.game-card-title {
  font-size: 1.05rem;
  font-weight: 850;
  color: var(--ink);
  line-height: 1.25;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.section-title span, .eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

#roomPasswordField {
  margin-top: 12px;
  margin-bottom: 0;
}

.field span {
  font-weight: 800;
}

input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px 12px;
  color: var(--ink);
}

.field small {
  color: var(--muted);
  line-height: 1.45;
}

.place-map-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  gap: 6px;
  align-items: stretch;
  width: 100%;
  height: 200px;
}

.place-map-wrap.hidden {
  display: none;
}

.place-map-inline {
  min-width: 0;
  height: 100%;
  border: 1px solid var(--ink);
  background: #efeae0;
  overflow: hidden;
}

.place-map-inline iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.map-zoom-stack {
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  gap: 2px;
  height: 100%;
  min-height: 0;
}

.map-zoom-mark {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  user-select: none;
}

.map-zoom-range {
  width: 24px;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  writing-mode: vertical-lr;
  direction: rtl;
  accent-color: var(--accent-2);
  cursor: pointer;
  appearance: slider-vertical;
  -webkit-appearance: slider-vertical;
}

.place-input-field {
  display: block;
}

.place-picker small {
  color: var(--muted);
  line-height: 1.45;
}

.primary-btn, .secondary-btn, .ghost-btn, .tab {
  min-height: 42px;
  border: 1px solid var(--ink);
  padding: 9px 14px;
  font-weight: 850;
  background: #fff;
  color: var(--ink);
}

.primary-btn {
  width: 100%;
  margin-top: 18px;
  background: var(--accent);
  color: #fffdfa;
  box-shadow: 4px 4px 0 var(--ink);
}

.secondary-btn {
  width: 100%;
  margin-top: 12px;
  background: #f4e5bd;
}

.ghost-btn {
  background: transparent;
}

.cropper {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.crop-controls {
  display: grid;
  gap: 8px;
  margin-top: 0;
  max-width: 400px;
}

.crop-controls label {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}

.field-label-row > span {
  font-weight: 800;
}

.crop-hint {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: right;
}

.crop-hint.hidden {
  display: none;
}

.share-result {
  min-height: 22px;
  color: var(--accent-2);
  word-break: break-all;
  line-height: 1.45;
}

.setup-panel {
  padding: 22px;
  box-shadow: none;
}

.setup-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.setup-head h1 {
  margin: 6px 0 0;
  font-size: clamp(28px, 3.4vw, 42px);
  line-height: 1.05;
}

.setup-meta {
  display: grid;
  gap: 4px;
  min-width: 110px;
  text-align: right;
}

.setup-meta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
}

.setup-meta strong {
  font-size: 18px;
}

.setup-warning {
  margin: 14px 0 0;
  padding: 11px 12px;
  border: 1px solid var(--gold);
  background: #fff4cf;
  color: #684c0c;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
  max-width: 52ch;
}

.setup-layout {
  display: grid;
  grid-template-columns: minmax(0, 440px) minmax(280px, 1fr);
  gap: 28px;
  margin-top: 20px;
  align-items: start;
}

.setup-media .secondary-btn {
  margin-top: 12px;
}

.setup-media .field {
  margin-top: 0;
}

.image-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.image-dropzone {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1;
  border: 1px dashed var(--ink);
  background: #efeae0;
  cursor: pointer;
  outline: none;
  transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}

.image-dropzone:hover,
.image-dropzone:focus-visible {
  border-style: solid;
  box-shadow: 4px 4px 0 rgba(24, 33, 31, 0.16);
}

.image-dropzone.is-dragover {
  border-style: solid;
  border-color: var(--accent-2);
  background: #e9f5f1;
  box-shadow: 4px 4px 0 rgba(24, 116, 107, 0.2);
}

.image-dropzone:not(.is-empty) {
  border-style: solid;
  background: #fff;
  cursor: grab;
}

.image-dropzone:not(.is-empty).is-panning {
  cursor: grabbing;
}

#cropCanvas {
  width: 100%;
  height: 100%;
  display: block;
  aspect-ratio: 1;
  background: transparent;
}

.image-drop-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  pointer-events: none;
  color: var(--muted);
}

.image-drop-hint strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.image-drop-hint span {
  font-size: 0.92rem;
  line-height: 1.4;
}

.image-dropzone:not(.is-empty) .image-drop-hint {
  display: none;
}

.image-dropzone + .crop-controls {
  margin-top: -2px;
}

.crop-controls.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.setup-details {
  display: grid;
  gap: 4px;
  align-content: start;
  max-width: 420px;
}

.setup-details .primary-btn {
  margin-top: 22px;
}

.dashboard-actions {
  display: grid;
  grid-template-columns: 1fr 210px 210px;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--ink);
  background: var(--gold);
  box-shadow: 6px 6px 0 var(--ink);
}

.dashboard-actions > div {
  display: grid;
  gap: 4px;
}

.dashboard-actions > div > strong { font-size: 18px; }
.dashboard-actions small { color: #563e0b; }
.room-name-field { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.room-name-field span { font-size: 11px; font-weight: 900; }
.room-name-field input { min-height: 34px; max-width: 220px; padding: 6px 8px; }
.dashboard-actions .primary-btn,
.dashboard-actions .secondary-btn { margin-top: 0; }

.dashboard-actions .secondary-btn.is-copied {
  background: var(--accent-2);
  color: #fff;
  border-color: var(--ink);
}

.play-surface {
  min-width: 0;
}

.hero-strip {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  align-items: start;
  padding: 14px 18px;
  background: var(--ink);
  color: #fffdfa;
  border: 1px solid var(--ink);
}

.hero-strip .eyebrow {
  margin: 0;
  font-size: 11px;
}

.hero-strip h1, .runner-head h1 {
  margin: 0;
  font-size: clamp(15px, 1.5vw, 18px);
  line-height: 1.35;
  letter-spacing: 0;
  font-weight: 750;
}

#roomDashboard .hero-strip {
  grid-template-columns: 1fr 190px;
  gap: 18px;
  align-items: stretch;
  padding: 18px 22px;
}

#roomDashboard .hero-strip h1 {
  font-size: clamp(18px, 2vw, 26px);
  font-weight: 850;
}

.status-card {
  display: grid;
  align-content: center;
  gap: 6px;
  border-left: 1px solid rgba(255,255,255,.25);
  padding-left: 18px;
}

.status-card span, .timer span {
  color: rgba(255,255,255,.72);
  font-size: 13px;
}

.status-card strong, .timer strong {
  font-size: 20px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 18px 0;
}

.tab.active {
  background: var(--accent-2);
  color: #fff;
}

.list-view {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.room-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, .7fr);
  gap: 14px;
  margin: 18px 0;
}

.room-grid .results-panel {
  grid-column: 1 / -1;
  margin-top: 0;
}

.room-panel {
  padding: 16px;
  box-shadow: none;
}

.asset-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 84px;
  margin-top: 14px;
  color: var(--muted);
}

.asset-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border: 1px solid var(--ink);
}

.user-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.user-pill {
  border: 1px solid var(--ink);
  background: #fff;
  padding: 7px 9px;
  font-weight: 800;
  font-size: 13px;
}

.game-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  background: rgba(255,253,250,.82);
  border: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}

.game-row:hover {
  border-color: var(--ink);
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--ink);
}

.game-row:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.game-row img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border: 1px solid var(--ink);
}

.game-row h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.game-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.row-status {
  border: 1px solid var(--line);
  background: #efeae0;
  color: var(--muted);
  padding: 8px 10px;
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
}

.row-status.status-published {
  border-color: var(--accent-2);
  background: rgba(24, 116, 107, 0.12);
  color: var(--accent-2);
}

.row-status.status-archived {
  border-color: var(--line);
  background: #e7e2d8;
  color: var(--muted);
}

.game-row.is-archived {
  opacity: 0.78;
}

.row-status.status-draft {
  border-color: var(--gold);
  background: rgba(217, 159, 43, 0.16);
  color: #8a6410;
}

.runner {
  padding-top: 24px;
}

.runner-head {
  display: grid;
  grid-template-columns: 160px 1fr 140px;
  gap: 18px;
  align-items: center;
  padding: 22px;
  background: var(--ink);
  color: #fffdfa;
}

.back-link {
  color: #fffdfa;
  text-decoration: none;
  font-weight: 850;
}

.timer {
  text-align: right;
}

.game-board-wrap {
  display: grid;
  grid-template-columns: minmax(320px, 720px) 300px;
  gap: 20px;
  align-items: start;
  margin-top: 20px;
}

.puzzle-board {
  display: grid;
  width: min(720px, 100%);
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  background: #111;
  box-shadow: var(--shadow);
}

.piece {
  border: 1px solid rgba(255,255,255,.35);
  background-repeat: no-repeat;
  touch-action: manipulation;
}

.piece.selected {
  outline: 4px solid var(--gold);
  outline-offset: -4px;
}

.puzzle-board.puzzle-solved {
  box-shadow:
    0 0 0 3px var(--gold),
    0 0 32px rgba(217, 159, 43, .45),
    var(--shadow);
  animation: puzzle-glow 1.4s ease-in-out infinite alternate;
}

.puzzle-board.puzzle-solved .piece {
  pointer-events: none;
  border-color: transparent;
}

@keyframes puzzle-glow {
  from { filter: saturate(1); }
  to { filter: saturate(1.15) brightness(1.04); }
}

.answer-ready {
  border-color: var(--accent-2) !important;
  box-shadow: 0 0 0 3px rgba(24, 116, 107, .22);
  animation: answer-pulse 1.1s ease-in-out infinite alternate;
}

.answer-wrong {
  border-color: var(--accent) !important;
  animation: answer-shake .45s ease;
}

@keyframes answer-pulse {
  from { box-shadow: 0 0 0 2px rgba(24, 116, 107, .15); }
  to { box-shadow: 0 0 0 4px rgba(24, 116, 107, .28); }
}

@keyframes answer-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Fullscreen Three.js celebration overlay (above native dialogs) */
.celebration-root {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  pointer-events: auto;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(24, 33, 31, .55), rgba(24, 33, 31, .78) 70%);
  animation: celebration-fade-in .28s ease-out;
}

.celebration-root--puzzle {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(24, 116, 107, .28), rgba(24, 33, 31, .72) 68%);
}

.celebration-root--clear {
  background:
    radial-gradient(ellipse at 50% 25%, rgba(201, 71, 44, .35), rgba(24, 33, 31, .82) 72%);
}

.celebration-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.celebration-card {
  position: relative;
  z-index: 1;
  width: min(440px, calc(100vw - 40px));
  padding: 28px 28px 24px;
  border: 3px solid var(--ink);
  background: var(--panel);
  box-shadow: 10px 10px 0 var(--ink), 0 30px 80px rgba(0, 0, 0, .35);
  text-align: center;
  animation: celebration-card-pop .55s cubic-bezier(.2, 1.2, .35, 1);
}

.celebration-eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 800;
}

.celebration-card h2 {
  margin: 10px 0 12px;
  font-size: clamp(34px, 7vw, 52px);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--accent);
  text-shadow: 3px 3px 0 rgba(217, 159, 43, .35);
}

.celebration-root--clear .celebration-card h2 {
  background: linear-gradient(120deg, #c9472c, #d99f2b 55%, #18746b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}

.celebration-message {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  font-weight: 600;
}

.celebration-time {
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 2px dashed var(--ink);
  background: #fff6df;
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.celebration-time:empty {
  display: none;
}

.celebration-continue {
  width: 100%;
  margin-top: 20px;
  min-height: 48px;
  font-weight: 800;
}

@keyframes celebration-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes celebration-card-pop {
  0% { transform: scale(.72) translateY(24px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.answer-panel {
  padding: 16px;
}

.answer-panel img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border: 1px solid var(--ink);
}

.score-grid {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.score-grid span {
  color: var(--muted);
}

.offline {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--accent);
  background: #ffe8df;
  color: #7b210e;
  font-weight: 800;
}

.results-panel {
  margin-top: 20px;
  padding: 16px;
  box-shadow: none;
}

.results-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.result-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(140px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.result-row span,
.result-row time { color: var(--muted); }

.game-dialog {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--paper);
  color: var(--ink);
}

.game-dialog::backdrop { background: var(--ink); }

.game-dialog-frame {
  min-height: 100vh;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(24,33,31,.07) 1px, transparent 1px),
    linear-gradient(rgba(24,33,31,.06) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
}

.game-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: 1080px;
  margin: 0 auto 18px;
  padding: 18px 22px;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: #fffdfa;
}

.game-dialog-head h2 { margin: 4px 0 0; font-size: clamp(22px, 3vw, 38px); }
.game-dialog-head .eyebrow { margin: 0; }
.game-clock { display: grid; text-align: right; }
.game-clock span { color: rgba(255,255,255,.7); font-size: 12px; }
.game-clock strong { color: var(--gold); font-size: 30px; }
.game-dialog .game-board-wrap { max-width: 1080px; margin: 0 auto; }
.quit-game-btn { width: 100%; margin-top: 12px; }

.empty {
  padding: 24px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: rgba(255,253,250,.65);
}

.hidden { display: none !important; }

.place-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}

.place-dialog::backdrop {
  background: rgba(12, 18, 17, .78);
  backdrop-filter: blur(5px);
}

.place-dialog[open] .place-dialog-frame {
  animation: dialog-in .18s ease-out;
}

.place-dialog-frame {
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 12px 12px 0 var(--gold);
  overflow: hidden;
}

.place-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--ink);
  background: #fffdfa;
}

.place-dialog-head h2 {
  margin: 4px 0 0;
  font-size: clamp(24px, 4vw, 40px);
  line-height: 1;
}

.place-dialog-head .eyebrow {
  margin: 0;
}

.dialog-close {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-size: 28px;
  line-height: 1;
}

.place-dialog-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .8fr);
  min-height: 500px;
}

.place-map-panel {
  position: relative;
  min-height: 500px;
  border-right: 1px solid var(--ink);
  background:
    linear-gradient(90deg, rgba(24,33,31,.07) 1px, transparent 1px),
    linear-gradient(rgba(24,33,31,.07) 1px, transparent 1px),
    #e8e2d6;
  background-size: 32px 32px;
}

.place-map-panel iframe {
  width: 100%;
  height: 100%;
  min-height: 500px;
  border: 0;
}

.place-map-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 30px;
  text-align: center;
  color: var(--muted);
}

.place-map-empty strong {
  color: var(--ink);
  font-size: 22px;
}

.place-entry-panel {
  display: flex;
  flex-direction: column;
  padding: 26px;
  background: #fffdfa;
}

.place-entry-panel h3 {
  margin: 12px 0 8px;
  font-size: 22px;
  line-height: 1.15;
}

.place-entry-panel p {
  color: var(--muted);
  line-height: 1.5;
}

.step-number {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--ink);
  background: var(--gold);
  font-weight: 900;
}

.dialog-message {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--accent) !important;
  font-weight: 800;
}

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  margin-top: auto;
  padding-top: 20px;
}

.dialog-actions .primary-btn {
  margin-top: 0;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 980px) {
  .workspace, .game-board-wrap, .hero-strip, .runner-head, .room-grid, .setup-layout {
    grid-template-columns: 1fr;
  }

  .creator-panel {
    position: static;
  }

  .setup-head {
    flex-direction: column;
  }

  .setup-meta {
    text-align: left;
  }

  .status-card {
    border-left: 0;
    border-top: 1px solid rgba(255,255,255,.25);
    padding-left: 0;
    padding-top: 14px;
  }

  .place-dialog {
    overflow: auto;
  }

  .place-dialog-grid {
    grid-template-columns: 1fr;
  }

  .place-map-panel,
  .place-map-panel iframe {
    min-height: 360px;
  }

  .place-map-panel {
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .dashboard-actions { grid-template-columns: 1fr; }
  .game-dialog { overflow: auto; }
}

@media (max-width: 620px) {
  .shell { padding: 10px; }
  .topbar, .identity, .tabs { align-items: stretch; flex-direction: column; }
  .identity-editor { justify-items: start; }
  .identity-name { width: 100%; text-align: left; }
  .name-hint { padding-right: 0; }
  .game-row { grid-template-columns: 64px 1fr; }
  .row-status { grid-column: 1 / -1; justify-self: start; }
  .place-dialog { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
  .place-dialog-head, .place-entry-panel { padding: 18px; }
  .place-map-panel, .place-map-panel iframe { min-height: 280px; }
  .dialog-actions { grid-template-columns: 1fr; }
  .result-row { grid-template-columns: 1fr; gap: 4px; }
  .game-dialog-frame { padding: 10px; }
  .game-dialog-head { align-items: flex-start; padding: 14px; }
}
