/* Astro ATM — public fascia.
   The page is the cash machine. Steel around a glass well. Not a brochure.
   Palette stolen from the cabinet (void, gold, brass, parchment, hairline).
   Shore motion lives in shore.css. Do not copy the TV-guide rail.

   Fonts — local woff2 (same cabinet faces). No Google.
   VT323 = machine chrome (wordmark, clock, signal, mode keys)
   Cormorant Garamond = prose / receipt
*/

@font-face {
  font-family: VT323;
  src: url("../fonts/vt323.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("../fonts/corm.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("../fonts/cormi.woff2") format("woff2");
  font-weight: 500;
  font-style: italic;
  font-display: block;
}

:root {
  --void: #0d0b14;
  --parchment: #e8d5a3;
  --gold: #d4a03c;
  --brass: #b8924a;
  --hairline: rgba(212, 160, 60, 0.3);
  --ember: #e2703a;
  --rose: #e0607e;
  --violet: #c4a0ff;
  --teal: #3ddcb4;
  --live: #3ee08a;
  --steel: #2c3038;
  --steel-hi: #5a606a;
  --steel-lo: #14161a;
  --pace: 1000ms;
  --tap: 72px;
  --chrome: "VT323", ui-monospace, monospace;
  --prose: "Cormorant Garamond", Georgia, "Times New Roman", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #000;
  color: var(--parchment);
  overflow-x: hidden;
  overflow-x: clip;
  max-width: 100%;
  color-scheme: dark;
}

.pei-sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  background: #000;
}

body {
  font-family: var(--chrome);
}

img,
video,
canvas {
  max-width: 100%;
}

a {
  color: var(--gold);
  text-decoration: none;
}

::selection {
  background: color-mix(in srgb, var(--gold) 42%, transparent);
  color: var(--void);
}

/* ---- cold boot: true black, then the steel ---- */
.cold {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #000;
  pointer-events: none;
  animation: cold-lift 0.8s ease 0.9s forwards;
}

@keyframes cold-lift {
  to { opacity: 0; }
}

.machine {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
  font-family: var(--chrome);
  color: var(--parchment);
  -webkit-tap-highlight-color: transparent;
}

/* ---- night column: screen + keys. No steel chassis. ---- */
.fascia {
  position: relative;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  overflow-x: clip;
  overflow-anchor: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding:
    max(12px, env(safe-area-inset-top, 0px))
    max(12px, env(safe-area-inset-right, 0px))
    max(12px, env(safe-area-inset-bottom, 0px))
    max(12px, env(safe-area-inset-left, 0px));
  background: transparent;
  box-shadow: none;
}

.bezel {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  container-type: inline-size;
}

.glass {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  background: var(--void);
  border: 1px solid var(--hairline);
  border-radius: 2px;
  overflow: hidden;
  box-shadow:
    inset 0 0 70px rgba(0, 0, 0, 0.62),
    inset 0 1px 0 rgba(232, 213, 163, 0.1);
}

.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  background: linear-gradient(
    165deg,
    rgba(232, 213, 163, 0.07) 0 18%,
    transparent 42%
  );
}

/* ---- nameplate on the glass ---- */
.chrome {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "wordmark clock"
    "signal signal";
  align-items: center;
  gap: 4px 12px;
  width: 100%;
  min-width: 0;
  padding: 8px 12px 7px;
  overflow: hidden;
  border-bottom: 1px solid var(--hairline);
  background: rgba(9, 8, 15, 0.72);
}

.wordmark {
  grid-area: wordmark;
  margin: 0;
  min-width: 0;
  font-family: var(--chrome);
  font-size: clamp(20px, 5.6vw, 38px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.1em;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-shadow:
    0 1px 0 rgba(255, 230, 180, 0.32),
    0 -1px 0 rgba(0, 0, 0, 0.55);
}

.wordmark-star {
  display: inline-block;
  margin: 0 0.08em;
  animation: wordmark-star calc(var(--pace) * 2.6) ease-in-out infinite;
  text-shadow: 0 0 14px color-mix(in srgb, var(--gold) 45%, transparent);
}

@keyframes wordmark-star {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.38; }
}

.clock {
  grid-area: clock;
  font-family: var(--chrome);
  font-size: clamp(18px, 4.4vw, 26px);
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
  color: var(--parchment);
  text-shadow: 0 0 12px color-mix(in srgb, var(--parchment) 22%, transparent);
}

.signal {
  grid-area: signal;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  min-width: 0;
  max-width: 100%;
  font-family: var(--chrome);
  font-size: clamp(12px, 3.2vw, 16px);
  letter-spacing: 0.16em;
  color: color-mix(in srgb, var(--parchment) 55%, transparent);
  opacity: 0.72;
}

.signal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--parchment) 45%, transparent);
  box-shadow: none;
  flex: 0 0 auto;
}

.signal[data-live="1"] {
  color: var(--live);
  opacity: 1;
  text-shadow: 0 0 10px color-mix(in srgb, var(--live) 50%, transparent);
}

.signal[data-live="1"] .signal-dot {
  background: var(--live);
  animation: live-pulse calc(var(--pace) * 1.15) ease-in-out infinite;
  box-shadow:
    0 0 8px var(--live),
    0 0 18px color-mix(in srgb, var(--live) 60%, transparent);
}

.signal[data-live="0"] {
  color: color-mix(in srgb, var(--parchment) 55%, transparent);
  opacity: 0.72;
  text-shadow: none;
}

.signal[data-live="0"] .signal-dot {
  background: color-mix(in srgb, var(--parchment) 45%, transparent);
  box-shadow: none;
  animation: none;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---- 16:9 well ---- */
.stage {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  aspect-ratio: 16 / 9;
  height: auto;
  margin: 0 auto;
  overflow: hidden;
  overflow-anchor: none;
  contain: layout;
  background: var(--void);
  isolation: isolate;
}

.stage > .shore,
.stage #shore-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  aspect-ratio: auto;
  overflow: hidden;
}

.feed,
.shore-feed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  background: var(--void);
  z-index: 2;
}

.stage.is-live .feed { display: block; }
.stage.is-live .shore { visibility: hidden; }
.stage.is-live .watch-still,
.stage.is-live .watch-video { display: none !important; }

.watch-still,
.watch-video {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  background: var(--void);
}

.watch-video { z-index: 3; }

.watch-static {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  overflow: hidden;
  pointer-events: none;
  background: #0d0b14;
}

.watch-static canvas {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0.94;
  animation: watch-static-breathe 8s ease-in-out infinite;
}

.watch-static::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(13, 11, 20, 0) 0 3px,
      rgba(0, 0, 0, 0.1) 3px 4px
    ),
    radial-gradient(ellipse at center, transparent 44%, rgba(6, 4, 12, 0.72) 100%);
}

@keyframes watch-static-breathe {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1; }
}

.stage.is-shot .watch-still { display: block; }
.stage.is-shot .shore { visibility: hidden; }

.stage.is-watch-live .watch-video { display: block; }
.stage.is-watch-live .watch-still,
.stage.is-watch-live .shore { display: none !important; }

.machine[data-mode="watch"] .shore,
.machine:not([data-mode]) .shore {
  display: none !important;
}

.machine[data-mode="watch"] .watch-static,
.machine:not([data-mode]) .watch-static {
  display: block;
}

.stage.is-shot .watch-static,
.stage.is-watch-live .watch-static,
.stage.is-live .watch-static,
.watch-static[hidden] {
  display: none !important;
}

.stage-badge {
  display: none;
}

.stage.is-live .stage-badge,
.stage.is-watch-live .stage-badge,
.stage.is-shot .stage-badge {
  color: var(--live);
  border-color: color-mix(in srgb, var(--live) 50%, transparent);
}

.ticker {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  overflow: hidden;
  max-width: 100%;
  height: 28px;
  border-top: 1px solid var(--hairline);
  background: rgba(13, 11, 20, 0.82);
  pointer-events: none;
}

.ticker-track {
  display: inline-flex;
  white-space: nowrap;
  animation: ticker-crawl var(--ticker-s, 80s) linear infinite;
  will-change: transform;
}

.ticker-run {
  flex: 0 0 auto;
  padding-right: 3.5em;
  font-family: var(--chrome);
  font-size: 16px;
  letter-spacing: 0.14em;
  line-height: 28px;
  color: var(--gold);
}

@keyframes ticker-crawl {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ---- receipt on the glass (overlay; never fascia flow) ---- */
.receipt {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 4;
  margin: 0;
  width: auto;
  height: auto;
  overflow: hidden;
  overflow-anchor: none;
  overscroll-behavior: contain;
  pointer-events: none;
  scrollbar-width: thin;
  scrollbar-color: var(--hairline) transparent;
}

.receipt__head { margin: 0 0 8px; }
.receipt__mark {
  margin: 0;
  font-family: var(--chrome);
  font-size: 14px;
  letter-spacing: 0.18em;
  color: var(--gold);
}
.receipt__title {
  margin: 4px 0 2px;
  font-family: var(--chrome);
  font-size: clamp(22px, 4vw, 30px);
  letter-spacing: 0.16em;
  font-weight: 400;
  color: var(--gold);
}
.receipt__fare {
  margin: 0;
  font-family: var(--prose);
  font-style: italic;
}
.receipt__rooms {
  margin: 0;
  padding: 0;
  list-style: none;
}
.receipt__item {
  margin: 0;
  padding: 6px 0;
  border-top: 1px solid var(--hairline);
  opacity: 0.72;
  transition: opacity 160ms ease, border-color 160ms ease;
}
.receipt__item.is-on,
.receipt:not(:has(.receipt__item.is-on)) .receipt__item {
  opacity: 1;
}
.receipt__item.is-on { border-color: var(--gold); }
.receipt__name {
  margin: 0;
  font-family: var(--chrome);
  font-size: 18px;
  letter-spacing: 0.12em;
  font-weight: 400;
  color: var(--gold);
}
.receipt__item[data-room="oracle"] .receipt__name { color: var(--gold); }
.receipt__item[data-room="roast"] .receipt__name { color: var(--ember); }
.receipt__item[data-room="mimic"] .receipt__name { color: var(--teal); }
.receipt__item[data-room="lovedoctor"] .receipt__name { color: var(--rose); }
.receipt__item[data-room="starsong"] .receipt__name { color: var(--violet); }
.receipt__copy { margin: 2px 0 0; overflow-wrap: anywhere; }
.receipt__village {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--hairline);
}
.receipt__village .receipt__name { color: var(--parchment); }
.receipt__legal {
  margin: 6px 0 0;
  font-size: 0.92em;
}
.legal { font-style: italic; opacity: 0.72; font-size: 0.9em; }

.prose {
  font-family: var(--prose);
  font-weight: 500;
  font-size: clamp(16px, 2.5vw, 22px);
  line-height: 1.4;
  color: var(--parchment);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.65);
}

.prose em,
.prose i { font-style: italic; }

/* ---- physical keys on the steel: WATCH / TOWN / TONIGHT ---- */
.modes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  flex: 0 0 auto;
  padding: 12px 6px 4px;
  overflow-anchor: none;
  container-type: inline-size;
}

/* TONIGHT rooms live in the well. Never a second steel row. */
.keys,
.tonight-only {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
}

.mode {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: var(--tap);
  min-height: var(--tap);
  max-height: var(--tap);
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 8px 10px;
  overflow: hidden;
  white-space: nowrap;
  font-family: var(--chrome);
  font-size: clamp(24px, 5.4vw, 32px);
  letter-spacing: 0.2em;
  line-height: 1.05;
  text-align: center;
  color: var(--parchment);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  border-radius: 4px;
  border: 1px solid #6a7078;
  border-bottom-color: #0c0d10;
  background:
    linear-gradient(180deg, #555b64 0%, #32363e 42%, #1c1f25 100%);
  box-shadow:
    0 0 0 4px var(--steel-lo),
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -2px 0 rgba(0, 0, 0, 0.45),
    0 4px 0 #101114,
    0 6px 10px rgba(0, 0, 0, 0.4);
}

.mode.is-on,
.mode[aria-pressed="true"],
.machine[data-mode="watch"] .mode[data-mode="watch"],
.machine:not([data-mode]) .mode[data-mode="watch"],
.machine[data-mode="town"] .mode[data-mode="town"],
.machine[data-mode="tonight"] .mode[data-mode="tonight"] {
  color: var(--void);
  border-color: color-mix(in srgb, var(--gold) 70%, white);
  background:
    linear-gradient(180deg, #f0d48a 0%, var(--gold) 42%, var(--brass) 100%);
  text-shadow: none;
  box-shadow:
    0 0 0 4px var(--steel-lo),
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -2px 0 rgba(80, 50, 10, 0.45),
    0 4px 0 #3a2a10,
    0 0 18px color-mix(in srgb, var(--gold) 35%, transparent);
}

.mode:active {
  transform: translateY(3px);
  box-shadow:
    0 0 0 4px var(--steel-lo),
    inset 0 3px 6px rgba(0, 0, 0, 0.55),
    0 1px 0 #101114;
}

.mode:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.slot {
  display: none;
}

/* ---- modes ---- */
.machine[data-mode="tonight"] .receipt {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  pointer-events: auto;
}

.machine[data-mode="tonight"] .shore,
.machine[data-mode="tonight"] .feed {
  opacity: 0.22;
  filter: saturate(0.6);
}

.machine[data-mode="tonight"] .ticker,
.machine[data-mode="tonight"] .shore-ticker,
.machine[data-mode="tonight"] .stage-badge {
  display: none;
}

.machine[data-mode="watch"] .stage-badge,
.machine:not([data-mode]) .stage-badge {
  display: none !important;
}

.machine[data-mode="watch"] .town,
.machine:not([data-mode]) .town,
.machine[data-mode="tonight"] .town {
  display: none;
}

.machine[data-mode="town"] .watch-still,
.machine[data-mode="town"] .watch-video,
.machine[data-mode="town"] .watch-static,
.machine[data-mode="tonight"] .watch-still,
.machine[data-mode="tonight"] .watch-video,
.machine[data-mode="tonight"] .watch-static {
  display: none !important;
}

.machine[data-mode="town"] .shore,
.machine[data-mode="town"] .feed,
.machine[data-mode="town"] .ticker,
.machine[data-mode="town"] .receipt,
.machine[data-mode="town"] .stage-badge {
  display: none !important;
}

.machine[data-mode="town"] .town {
  display: block !important;
}

.machine[data-mode="town"] .town.is-empty {
  display: flex !important;
}

.machine[data-mode="town"] .town-ticket,
.machine[data-mode="town"] .town-ticket[hidden] {
  visibility: visible;
  pointer-events: auto;
}

.town-ticket[hidden] {
  display: grid !important;
  visibility: hidden;
  pointer-events: none;
}

/* 3 columns × 4 rows. Drawings + names. */
.town {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0d0b14;
  padding: 0;
}

.town-grid {
  display: grid;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  gap: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  background: #0d0b14;
}

.town-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  min-height: 0;
  padding: 2px 3px 3px;
  margin: 0;
  border: 0;
  background: #0d0b14;
  color: inherit;
  font: inherit;
  overflow: hidden;
  cursor: pointer;
}

.town-cell img {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  max-width: none;
  object-fit: contain;
  image-rendering: pixelated;
}

.town-name {
  flex: 0 0 auto;
  width: 100%;
  margin: 1px 0 0;
  font-family: var(--chrome);
  font-size: clamp(8px, 2.1vw, 13px);
  letter-spacing: 0.1em;
  line-height: 1.1;
  color: var(--parchment);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.town-cell.is-cap .town-name { color: var(--gold); }
.town-bio {
  display: none;
}

.town-sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(10px, 2.2dvh, 18px);
  overflow-anchor: none;
  padding:
    max(20px, env(safe-area-inset-top, 0px))
    max(18px, env(safe-area-inset-right, 0px))
    max(20px, env(safe-area-inset-bottom, 0px))
    max(18px, env(safe-area-inset-left, 0px));
  overflow: auto;
  background: rgba(0, 0, 0, 0.82);
  color: var(--parchment);
}
.town-sheet[hidden] { display: none !important; }
.town-sheet .face {
  flex: 0 0 auto;
  width: min(78vw, 56dvh, 420px);
  height: min(78vw, 56dvh, 420px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0b14;
}
.town-sheet .face img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.town-ticket {
  --ticket-h: 2.4rem;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  align-content: center;
  align-items: stretch;
  gap: 0;
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  height: var(--ticket-h);
  min-height: var(--ticket-h);
  max-height: var(--ticket-h);
  margin: 2px 0 0;
  visibility: hidden;
  pointer-events: none;
  overflow: hidden;
  overflow-anchor: none;
}

.town-ticket > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.town-where {
  margin: 0;
  padding: 0 4px;
  font-family: var(--chrome);
  font-size: clamp(11px, 2.6vw, 14px);
  letter-spacing: 0.14em;
  line-height: 1.25;
  color: var(--brass);
  text-align: center;
}

.town-ticket-link {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0 4px;
  border: 0;
  background: none;
  font-family: var(--chrome);
  font-size: clamp(11px, 2.5vw, 13px);
  letter-spacing: 0.14em;
  line-height: 1.2;
  color: var(--brass);
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  opacity: 0.85;
  touch-action: manipulation;
}
.town-ticket-link:hover,
.town-ticket-link:focus-visible {
  color: var(--gold);
  opacity: 1;
  outline: none;
}

.town-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(16px, env(safe-area-inset-top, 0px))
    max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px));
  overflow: auto;
  background:
    radial-gradient(ellipse 62% 50% at 50% 50%, rgba(13, 11, 20, 0.42), rgba(0, 0, 0, 0.58));
  opacity: 0;
  transition: opacity 340ms ease-out;
}
.town-gate.is-open { opacity: 1; }
.town-gate[hidden] { display: none !important; }

.town-gate-card {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  width: min(100%, 26rem);
  margin: auto;
  padding: 1.35rem 1.15rem 1.05rem;
  outline: none;
  background:
    radial-gradient(ellipse 90% 50% at 50% 0%, rgba(212, 160, 60, 0.1), transparent 58%),
    linear-gradient(180deg, #16121c 0%, var(--void) 46%, #09070e 100%);
  border: 1px solid var(--gold);
  border-radius: 1px;
  box-shadow:
    0 0 0 1px var(--void),
    0 0 0 3px var(--brass),
    0 0 0 4px color-mix(in srgb, var(--gold) 55%, #4a3210),
    0 0 0 9px var(--void),
    0 0 72px color-mix(in srgb, var(--gold) 16%, transparent),
    0 22px 48px rgba(0, 0, 0, 0.72),
    inset 0 1px 0 rgba(232, 213, 163, 0.16);
  color: var(--parchment);
  text-align: center;
  transform: translateY(12px);
  transition: transform 380ms ease-out;
}
.town-gate.is-open .town-gate-card { transform: none; }

.town-gate-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  z-index: 0;
  pointer-events: none;
  border: 1px solid var(--hairline);
  background:
    linear-gradient(var(--gold), var(--gold)) top left / 16px 1px no-repeat,
    linear-gradient(var(--gold), var(--gold)) top left / 1px 16px no-repeat,
    linear-gradient(var(--gold), var(--gold)) top right / 16px 1px no-repeat,
    linear-gradient(var(--gold), var(--gold)) top right / 1px 16px no-repeat,
    linear-gradient(var(--gold), var(--gold)) bottom left / 16px 1px no-repeat,
    linear-gradient(var(--gold), var(--gold)) bottom left / 1px 16px no-repeat,
    linear-gradient(var(--gold), var(--gold)) bottom right / 16px 1px no-repeat,
    linear-gradient(var(--gold), var(--gold)) bottom right / 1px 16px no-repeat;
}

.town-gate-card > * {
  position: relative;
  z-index: 1;
}

.town-gate-mark {
  margin: 0.15rem 0 0;
  font-family: var(--chrome);
  font-size: clamp(12px, 3vw, 15px);
  letter-spacing: 0.32em;
  color: var(--gold);
  text-shadow: 0 0 14px color-mix(in srgb, var(--gold) 30%, transparent);
}

.town-gate-title {
  margin: 0;
  max-width: 18em;
  font-family: var(--prose);
  font-size: clamp(17px, 4.2vw, 23px);
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.01em;
  line-height: 1.28;
  color: var(--gold);
  text-wrap: balance;
}

.town-gate-title::after {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  margin: 0.7rem auto 0;
  background: var(--gold);
  transform: rotate(45deg);
  box-shadow: 0 0 10px color-mix(in srgb, var(--gold) 55%, transparent);
}

.town-gate-where {
  margin: 0;
  font-family: var(--chrome);
  font-size: clamp(14px, 3.4vw, 18px);
  letter-spacing: 0.14em;
  color: var(--brass);
}

.town-gate-seal {
  width: min(92vw, 22rem);
  padding: 8px;
  background:
    repeating-linear-gradient(
      -18deg,
      transparent 0 3px,
      rgba(184, 146, 74, 0.07) 3px 4px
    ),
    linear-gradient(165deg, #f3e6bc 0%, var(--parchment) 48%, #d2ba7e 100%);
  box-shadow:
    0 0 0 1px var(--brass),
    0 0 0 2px color-mix(in srgb, var(--gold) 70%, #6a4a18),
    inset 0 1px 0 rgba(255, 250, 230, 0.72),
    0 10px 22px rgba(0, 0, 0, 0.4);
}

.town-gate-seal:has(.town-gate-qr[hidden]) {
  display: none;
}

.town-gate-qr {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  margin: 0;
  padding: 0;
  background: #16121c;
  border-radius: 0;
  box-shadow: none;
  image-rendering: pixelated;
}
.town-gate-qr svg {
  display: block;
  width: 100%;
  height: 100%;
}
.town-gate-qr[hidden] { display: none; }

.town-gate-url {
  margin: 4px 0 0;
  padding: 8px 4px;
  width: 100%;
  max-width: 22em;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  font-family: var(--chrome);
  line-height: 1.35;
  user-select: all;
  -webkit-user-select: all;
  cursor: text;
}
.town-gate-url[hidden],
.town-gate-url:empty { display: none; }
.town-gate-url__host {
  display: block;
  padding-inline-start: 0.16em;
  font-family: var(--prose);
  font-size: clamp(16px, 3.5vw, 20px);
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--gold);
}
.town-gate-url__token {
  display: block;
  margin-top: 4px;
  color: var(--brass);
  opacity: 0.55;
  font-size: 11px;
  letter-spacing: 0.04em;
  word-break: break-all;
}

.town-gate-note {
  margin: 0;
  max-width: 22em;
  font-family: var(--prose);
  font-style: italic;
  font-size: clamp(14px, 3.3vw, 17px);
  line-height: 1.35;
  color: var(--parchment);
  text-wrap: balance;
}

.town-gate-map {
  margin: 2px 0 0;
  font-family: var(--chrome);
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--brass);
}

.town-gate-close {
  appearance: none;
  -webkit-appearance: none;
  margin-top: 0.25rem;
  min-height: 52px;
  width: 100%;
  padding: 0 18px;
  font-family: var(--chrome);
  font-size: clamp(18px, 4.4vw, 22px);
  letter-spacing: 0.22em;
  color: var(--void);
  border: 1px solid color-mix(in srgb, var(--gold) 70%, white);
  border-bottom-color: #3a2a10;
  border-radius: 3px;
  background: linear-gradient(180deg, #f0d48a 0%, var(--gold) 42%, var(--brass) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 -2px 0 rgba(80, 50, 10, 0.45),
    0 3px 0 #3a2a10;
  cursor: pointer;
  touch-action: manipulation;
}
.town-gate-close:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 3px 6px rgba(0, 0, 0, 0.45),
    0 1px 0 #3a2a10;
}
.town-gate-close:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

@media (max-height: 560px) {
  .town-gate-card { gap: 0.45rem; padding: 0.85rem 0.9rem 0.75rem; }
  .town-gate-seal { width: min(100%, 34dvh, 14rem); padding: 6px; }
}
.town-sheet .k {
  margin: 0;
  font-family: var(--chrome);
  font-size: clamp(13px, 2.4vw, 16px);
  letter-spacing: 0.16em;
  color: var(--gold);
}
.town-sheet h2 {
  margin: 0;
  font-family: var(--chrome);
  font-size: clamp(28px, 6vw, 44px);
  letter-spacing: 0.1em;
  font-weight: 400;
  color: var(--gold);
}
.town-sheet p {
  margin: 0;
  max-width: 36em;
  font-family: var(--prose);
  font-size: clamp(16px, 3.4vw, 22px);
  line-height: 1.4;
  text-align: center;
  text-wrap: balance;
}
.town-sheet .memory {
  font-style: italic;
  color: var(--parchment);
  opacity: 0.9;
}
.town-sheet button {
  margin-top: 6px;
  min-height: 44px;
  padding: 0 18px;
  font-family: var(--chrome);
  letter-spacing: 0.14em;
  color: var(--void);
  border: 0;
  border-radius: 4px;
  background: var(--gold);
}

.town-meta {
  display: block;
  margin: 0;
  padding: 0 4px;
  font-family: var(--chrome);
  font-size: clamp(11px, 2.6vw, 14px);
  letter-spacing: 0.12em;
  line-height: 1.25;
  color: var(--brass);
  text-align: center;
}

/* JS sets [hidden] off-town; keep the reserved row so the three keys do not jump. */
.town-ticket .town-meta[hidden] {
  display: block !important;
}

.town-empty {
  display: none;
  margin: 0;
  padding: 0 14px;
  font-family: var(--chrome);
  font-size: clamp(16px, 4.2vw, 22px);
  letter-spacing: 0.16em;
  color: var(--parchment);
  text-align: center;
  text-wrap: balance;
}

.town.is-empty .town-grid { display: none !important; }
.town.is-empty .town-empty { display: block; }



/* ---- phone stack: stage, then 72px keys, no sideways scroll ---- */
@media (max-width: 720px) {
  .machine {
    max-width: 100%;
  }

  .fascia {
    padding:
      max(10px, env(safe-area-inset-top, 0px))
      max(10px, env(safe-area-inset-right, 0px))
      max(10px, env(safe-area-inset-bottom, 0px))
      max(10px, env(safe-area-inset-left, 0px));
  }

  .stage {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .modes {
    padding-left: 8px;
    padding-right: 8px;
    gap: 12px;
  }

  .mode {
    font-size: clamp(16px, 5vw, 24px);
    letter-spacing: 0.08em;
  }

  .receipt {
    font-size: clamp(15px, 3.6vw, 18px);
  }

  .receipt__copy {
    overflow-wrap: anywhere;
  }

  .signal {
    letter-spacing: 0.1em;
  }

  .wordmark {
    font-size: 18px;
    letter-spacing: 0.06em;
  }

  .clock {
    font-size: 16px;
  }

  .bezel,
  .glass,
  .modes,
  .town-ticket {
    min-width: 0;
    max-width: 100%;
  }
}

@media (min-width: 721px) {
  :root { --tap: 52px; }

  .chrome {
    grid-template-columns: 1fr auto auto;
    grid-template-areas: "wordmark signal clock";
    padding: 7px 12px;
  }

  .signal { justify-self: center; }

  .wordmark {
    font-size: clamp(18px, 3.2cqi, 24px);
    letter-spacing: 0.08em;
  }

  .clock {
    font-size: clamp(14px, 2.6cqi, 18px);
  }

  .signal {
    font-size: clamp(11px, 2cqi, 13px);
  }

  .mode {
    font-size: clamp(15px, 3.4cqi, 20px);
    letter-spacing: 0.12em;
    padding: 6px 8px;
  }

  .ticker {
    height: 24px;
  }

  .ticker-run {
    font-size: 12px;
    line-height: 24px;
    letter-spacing: 0.1em;
  }

  .town-name {
    font-size: clamp(8px, 1.5cqi, 11px);
  }

  .town-ticket-link {
    font-size: clamp(10px, 1.8cqi, 12px);
  }

  .bezel,
  .modes,
  .town-ticket {
    width: min(100%, 72rem, calc(70dvh * 16 / 9 + 16px));
    margin-inline: auto;
  }

  .stage {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .fascia {
    padding:
      max(18px, env(safe-area-inset-top, 0px))
      max(22px, env(safe-area-inset-right, 0px))
      max(18px, env(safe-area-inset-bottom, 0px))
      max(22px, env(safe-area-inset-left, 0px));
  }
}

@media (hover: hover) and (pointer: fine) {
  .mode:hover {
    filter: brightness(1.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cold {
    animation: none;
    opacity: 0;
  }

  .signal-dot,
  .ticker-track,
  .town-gate,
  .town-gate-card,
  .wordmark-star,
  .watch-static canvas {
    animation: none;
    transition: none;
  }

  .watch-static canvas {
    opacity: 0.94;
  }

  .town-gate-card {
    transform: none;
  }
}
