:root {
  color-scheme: dark;
  --bg: #14110e;
  --bg-2: #221c16;
  --ink: #f6efe4;
  --muted: #b3a394;
  --line: #3a3128;
  --ember: #ff6a2c;
  --gold: #e7c27a;
  --good: #9cbe86;
  --bad: #e15b4c;
  --pad: 44px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

body {
  padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom));
}

#app {
  max-width: 760px;
  margin: 0 auto;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { touch-action: manipulation; }

h1, h2, p { margin: 0; }

h1 {
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.kicker {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
}

.slogan {
  margin-top: 6px;
  color: var(--muted);
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 17px;
  line-height: 1.35;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  padding: 18px 0 12px;
  border-bottom: 1px solid var(--line);
}

.clock {
  text-align: right;
}

.clock strong {
  display: block;
  font-variant-numeric: tabular-nums;
  font-size: 28px;
}

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

.stack { display: grid; gap: 12px; margin-top: 16px; min-width: 0; }

.stack > * { min-width: 0; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.maze-size { min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }

.btn, .choice {
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 8px;
  padding: 12px 14px;
  min-height: 44px;
}

.btn.primary {
  background: var(--ember);
  border-color: var(--ember);
  color: #1a0d08;
  font-weight: 650;
}

.btn.quiet { color: var(--muted); }

.btn:disabled, .choice:disabled { opacity: 0.45; }

.choice.on, .pad.lit {
  background: var(--ember);
  color: #1a0d08;
  border-color: var(--ember);
}

.card, .sheet, .ticket, .counsel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.card img, .ticket img, .shot {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
}

.cards {
  display: grid;
  gap: 12px;
}

@media (min-width: 700px) {
  .cards { grid-template-columns: 1fr 1fr; }
}

label.field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }

input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  background: #100e0c;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 44px;
}

.check { display: flex; gap: 10px; align-items: flex-start; color: var(--ink); }

.roster { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  font-size: 13px;
}

.pill.host, .pill.me { color: var(--gold); }

.stakes {
  margin: 6px 0 0;
  font-family: Georgia, Palatino, serif;
  font-size: 20px;
  line-height: 1.3;
}

.maze-wrap {
  width: 100%;
  max-width: 100%;
  height: 52vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0d0b09;
  touch-action: none;
  position: relative;
}

.maze-wrap.three {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #070605;
}

.maze-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.maze3d {
  width: 100%;
  height: 100%;
  display: block;
}

.maze-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
  font-family: Georgia, Palatino, serif;
  color: #f4efe6;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85);
}

.maze-cross {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  background:
    linear-gradient(#f6efe4, #f6efe4) center / 10px 1px no-repeat,
    linear-gradient(#f6efe4, #f6efe4) center / 1px 10px no-repeat;
  opacity: 0.8;
}

.maze-facing,
.maze-place,
.maze-watch,
.maze-beside {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
}

.maze-facing { top: 12px; color: #e7c27a; letter-spacing: 0.14em; }
.maze-place { bottom: 22px; color: #e7c27a; font-size: 22px; }
.maze-watch { bottom: 18px; font-size: 16px; }
.maze-beside { bottom: 52px; color: #e7c27a; font-size: 16px; }

.maze-standing {
  position: absolute;
  left: 50%;
  bottom: 10%;
  width: 28%;
  height: 18px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(231, 194, 122, 0.28);
}

.maze-cue {
  position: absolute;
  top: 18%;
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 72px;
  color: #e7c27a;
  font-size: 14px;
}

.maze-cue span { font-size: 22px; line-height: 1; }
.maze-cue.left { left: 8%; }
.maze-cue.right { right: 8%; }

.maze-label {
  position: absolute;
  transform: translate(-50%, -130%);
  white-space: nowrap;
  font-size: 15px;
}

.graffiti-pad {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.paint-bar {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 72px;
  z-index: 7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(7, 6, 5, 0.78);
  color: var(--ink);
}

.inks {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.ink {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(244, 239, 230, 0.35);
  cursor: pointer;
}

.ink.on {
  border-color: #f4efe6;
  box-shadow: 0 0 0 2px rgba(244, 239, 230, 0.35);
}

.carrying {
  margin: 6px 0 0;
  color: var(--gold);
  font-size: 14px;
}

.glint {
  margin: 0;
  color: var(--gold);
  font-family: Georgia, Palatino, serif;
  font-size: 18px;
  min-height: 1.2em;
}

.company {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  min-height: 1.2em;
}

.maze-hud {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #16110d;
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  display: grid;
  gap: 8px;
  touch-action: manipulation;
  pointer-events: auto;
}

.maze-wrap.three > .maze-hud {
  flex: 0 0 auto;
  max-height: 70%;
  min-height: 0;
  overflow: auto;
}

.sheet img {
  display: block;
  width: 72px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
}

.vault-here .sheet {
  margin-top: 0;
  padding: 8px;
}

.vault-here .sheet:has(img) {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  column-gap: 10px;
  row-gap: 4px;
  align-items: center;
}

.vault-here .sheet:has(img) img {
  grid-row: 1 / span 3;
}

.vault-here .sheet h2 {
  margin: 0;
  font-size: 18px;
}

.vault-here .sheet p {
  margin: 0;
}

.vault-here .sheet .btn {
  justify-self: start;
  min-height: 36px;
  padding: 8px 12px;
}

.scoreboard p { font-size: 14px; }

.vault-here {
  display: grid;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--gold);
}

.maze-hint { margin: 8px 0 0; }

.maze-fab {
  position: absolute;
  z-index: 6;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(231, 194, 122, 0.55);
  background: rgba(7, 6, 5, 0.78);
  color: var(--gold);
  display: grid;
  place-items: center;
  padding: 0;
}

.maze-fab svg { width: 22px; height: 22px; display: block; }
.maze-fab.paint { left: 12px; bottom: 12px; }
.maze-fab.full { right: 12px; top: 12px; }
.maze-fab[hidden] { display: none; }

html:fullscreen body.in-maze .maze-wrap.three,
body.in-maze.maze-immersive .maze-wrap.three {
  position: fixed;
  inset: 0;
  z-index: 130;
  width: 100%;
  height: 100%;
  max-height: none;
  border: 0;
  border-radius: 0;
  background: #070605;
}

.sheet { margin-top: 12px; }

.track {
  position: relative;
  height: 36px;
  border-radius: 999px;
  background: #100e0c;
  border: 1px solid var(--line);
  overflow: hidden;
}

.window {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(255, 106, 44, 0.45);
}

.marker {
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 4px;
  margin-left: -2px;
  background: var(--ink);
}

.pads, .board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.board { grid-template-columns: repeat(3, 72px); justify-content: center; }

.pad, .tile {
  min-height: 72px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #100e0c;
}

.tile.empty { visibility: hidden; }

.lane {
  position: relative;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #100e0c;
}

.hit {
  position: absolute;
  left: 18%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gold);
}

.beat, .tapmark {
  position: absolute;
  top: 22px;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border-radius: 50%;
  background: var(--ember);
}

.tapmark { background: var(--ink); top: 40px; }

.chat {
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #100e0c;
}

.chat p { font-size: 14px; }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  margin: 0 auto;
  max-width: 728px;
  background: var(--ink);
  color: #1a0d08;
  border-radius: 10px;
  padding: 12px 14px;
  display: none;
}

.toast.show { display: block; }

.ticket h2 {
  font-family: Georgia, Palatino, serif;
  font-size: 28px;
  font-weight: 500;
}

.hostbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.transfers {
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--gold);
  padding-top: 8px;
}

.transfers .kicker { margin: 0; }

.bad { color: var(--bad); }
.good { color: var(--good); }

.avatars {
  max-height: 42vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: #100e0c;
}

.avatar-movie { margin: 0 0 10px; }

.avatar-row { display: flex; gap: 8px; flex-wrap: wrap; }

.avatar-pick {
  width: 92px;
  margin: 0;
  padding: 4px;
  display: grid;
  justify-items: center;
  gap: 2px;
  background: #100e0c;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.avatar-pick.on { border-color: var(--gold); }

.avatar-pick span {
  font-size: 11px;
  line-height: 1.2;
  color: var(--muted);
  text-align: center;
}

.avatar-face {
  width: 42px;
  height: 64px;
  image-rendering: pixelated;
  background: transparent;
}

.plaza-poster {
  width: 100%;
  height: 210px;
  object-fit: cover;
  object-position: center;
  border-radius: 16px;
  display: block;
}

.plaza-stage { display: grid; gap: 10px; }

.plaza-hint { font-size: 14px; line-height: 1.4; }

.plaza-map {
  position: relative;
  touch-action: none;
  user-select: none;
}

.plaza-bg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 16px;
  border: 1px solid var(--line);
}

.plaza-actors {
  position: absolute;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.plaza-actor {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: max-content;
}

.plaza-actor img {
  width: 46px;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 6px rgba(0, 0, 0, 0.45));
}

.plaza-shadow {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 26px;
  height: 8px;
  margin-left: -13px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 50%;
  z-index: -1;
}

.plaza-name {
  position: absolute;
  top: 100%;
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #f6efe4;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
}

.plaza-actor.me .plaza-name { color: var(--gold); }

.plaza-bubble {
  max-width: 168px;
  margin: 0 0 6px;
  padding: 6px 10px;
  border-radius: 14px 14px 14px 4px;
  background: #f3e2b8;
  color: #2a160f;
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.plaza-bubble[hidden] { display: none; }

.plaza-pad {
  display: grid;
  grid-template-columns: 72px 72px 72px;
  grid-template-areas:
    ". north ."
    "west jump east"
    ". south .";
  gap: 8px;
  justify-content: center;
}

.plaza-pad [data-plaza-dir="n"] { grid-area: north; }
.plaza-pad [data-plaza-dir="w"] { grid-area: west; }
.plaza-pad [data-plaza-dir="e"] { grid-area: east; }
.plaza-pad [data-plaza-dir="s"] { grid-area: south; }
.plaza-pad [data-plaza-jump] { grid-area: jump; }

.plaza-pad .btn { min-width: 0; padding: 12px 8px; }

body.at-gate {
  padding: 0;
  background: #070605;
}

body.at-gate #app {
  max-width: none;
}

body.in-plaza #app,
body.in-maze #app {
  max-width: 1040px;
}

body.in-maze .maze-wrap.three {
  height: min(72vh, 760px);
}

body.in-maze .top h1 { font-size: 32px; }

@media (max-width: 720px) {
  body.in-maze { padding-left: 8px; padding-right: 8px; }
  body.in-maze .top h1 { font-size: 24px; }
  body.in-maze .slogan { display: none; }
  body.in-maze .maze-wrap.three { height: 68dvh; }
}

.gate {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  overflow: hidden;
}

.gate-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
  filter: brightness(0.38) saturate(1.15);
}

.gate-card {
  position: relative;
  width: min(560px, 100%);
  display: grid;
  gap: 12px;
  padding: 28px 24px 22px;
  border-radius: 22px;
  background: rgba(12, 9, 7, 0.82);
  border: 1px solid rgba(231, 194, 122, 0.38);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
}

.gate-card h1 { font-size: 52px; }

.gate-actions .btn.primary {
  min-width: 180px;
  padding-inline: 22px;
}

.presence {
  margin: 8px 0 0;
  color: var(--gold);
  font-size: 14px;
  letter-spacing: 0.02em;
}

.party { display: flex; flex-wrap: wrap; gap: 6px; }

.hunt-banner {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(231, 194, 122, 0.45);
  background: #24180f;
  color: var(--gold);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: Georgia, Palatino, serif;
  cursor: pointer;
}

.maze3d { cursor: crosshair; }

.section-title {
  font-family: Georgia, Palatino, serif;
  font-size: 22px;
  font-weight: 500;
}

.figure-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.figure-strip .avatar-pick { flex: 0 0 auto; }

.purse { color: var(--gold); }
.proposal { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.proposal.pick { display: flex; gap: 10px; align-items: flex-start; }
.proposal.pick input { margin-top: 4px; }
.proposal .row { justify-content: space-between; }
.proposal p { white-space: pre-wrap; }

.log-fold {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #100e0c;
}

.log-fold summary {
  cursor: pointer;
  color: var(--muted);
}

.log-fold .stack { margin-top: 12px; }

.figures-all { margin-top: 4px; }

.practice-fold {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #100e0c;
}

.practice-fold summary {
  cursor: pointer;
  color: var(--muted);
}

.practice-fold .row { margin-top: 10px; }

.chat-bubble-container {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: 16px;
  z-index: 100;
}

.chat-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ember);
  border: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.chat-bubble:active {
  transform: scale(0.95);
}

.chat-bubble-icon {
  font-size: 24px;
  line-height: 1;
}

.chat-bubble-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--bad);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-bubble-badge[hidden] {
  display: none;
}

.chat-overlay {
  position: fixed;
  bottom: calc(90px + env(safe-area-inset-bottom));
  right: 16px;
  width: min(360px, calc(100vw - 32px));
  max-height: min(420px, 50vh);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 99;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-overlay[hidden] {
  display: none;
}

.chat-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--gold);
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chat-overlay-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  margin: -4px -8px;
  line-height: 1;
}

.chat-overlay-close:hover {
  color: var(--ink);
}

.chat-overlay .chat {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  border: none;
  border-radius: 0;
  background: transparent;
}

.chat-overlay-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.chat-overlay-form input {
  flex: 1 1 auto;
  min-width: 0;
}

.chat-overlay-form .btn {
  flex: 0 0 auto;
}
