/* ============================================================
   Vampire Parchís — interface
   Dark wood, brass and candlelight. The 3D scene is the page; every
   screen floats over it, and only the panels take pointer events.
   ============================================================ */
:root {
  color-scheme: dark;
  --ink: #f3e4c8;
  --muted: #b9a588;
  --dim: #8b765d;
  --gold: #e8b54a;
  --gold-soft: #c99c45;
  --cream: #e8d5a3;
  --orange: #e07b1f;
  --crimson: #8b1f3a;
  --black: #231e1b;
  --ivory: #efe6d6;
  --wood: #2a1a10;
  --wood-2: #1a100a;
  --brass: #8a6428;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #0d0806;
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
body {
  height: 100dvh;
  min-height: 100svh;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

#stage3d {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  z-index: 0;
  background: #0d0806;
}
.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(78% 62% at 50% 44%, transparent 52%, rgba(0, 0, 0, .58) 100%),
    linear-gradient(180deg, rgba(6, 4, 3, .55) 0%, transparent 18%, transparent 76%, rgba(6, 4, 3, .72) 100%);
}
.app {
  position: relative;
  z-index: 2;
  height: 100dvh;
  height: 100svh;
  pointer-events: none;
}

/* ---------- screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  pointer-events: none;
  padding:
    calc(16px + var(--safe-top)) calc(18px + var(--safe-right))
    calc(16px + var(--safe-bottom)) calc(18px + var(--safe-left));
}
.screen.is-active { display: flex; animation: screen-in .5s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- menu ---------- */
.menu-screen {
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-left: max(24px, 6vw);
  padding-right: max(24px, 5vw);
  isolation: isolate;
}
.menu-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(5, 3, 2, .86) 0%, rgba(5, 3, 2, .55) 34%, rgba(5, 3, 2, .12) 56%, transparent 72%),
    linear-gradient(0deg, rgba(5, 3, 2, .55), transparent 34%);
}
.menu-panel {
  pointer-events: auto;
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 3.4vh, 34px);
  animation: screen-in .7s .05s both;
}
.brand-eyebrow, .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-family: var(--sans);
  font-size: clamp(.6rem, .7vw + .32rem, .72rem);
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold);
}
.brand-eyebrow::before, .eyebrow::after {
  content: "";
  width: 1.9rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
}
.eyebrow::after { background: linear-gradient(90deg, var(--gold), transparent); }
.brand h1 {
  margin: .25rem 0 .5rem;
  font-size: clamp(2.3rem, 4.6vw + .6rem, 4.4rem);
  line-height: .94;
  font-weight: 500;
  letter-spacing: -.02em;
  color: #f8ecd6;
  text-shadow: 0 4px 34px rgba(0, 0, 0, .8);
}
.brand h1 em { color: var(--gold); font-style: italic; }
.plaques {
  display: grid;
  gap: 10px;
  max-width: 360px;
}
/* three plaques on a phone: the last one fills the second row instead of
   leaving an empty cell where the fourth plaque used to be */
.plaques > .plaque:last-child:nth-child(odd) { grid-column: 1 / -1; }
.plaque {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 12px 18px;
  border: 1px solid rgba(232, 181, 74, .34);
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(94, 58, 30, .92), rgba(46, 27, 14, .95)),
    repeating-linear-gradient(92deg, rgba(255, 226, 180, .05) 0 2px, transparent 2px 9px);
  box-shadow:
    inset 0 1px 0 rgba(255, 226, 178, .18),
    inset 0 -2px 0 rgba(0, 0, 0, .45),
    0 8px 18px -10px rgba(0, 0, 0, .9);
  color: #f3e4c8;
  cursor: pointer;
  text-align: left;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.plaque::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(232, 181, 74, .14);
  border-radius: 2px;
  pointer-events: none;
}
.plaque span {
  font-size: 1.06rem;
  letter-spacing: .02em;
}
.plaque small {
  font-family: var(--sans);
  font-size: .62rem;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: #bfa880;
}
.plaque:active { transform: translateY(2px) scale(.995); box-shadow: inset 0 2px 6px rgba(0, 0, 0, .6); }
@media (hover: hover) and (pointer: fine) {
  .plaque:hover {
    transform: translateY(-2px);
    border-color: rgba(232, 181, 74, .7);
    box-shadow:
      inset 0 1px 0 rgba(255, 226, 178, .26),
      0 14px 26px -12px rgba(0, 0, 0, .95),
      0 0 22px -6px rgba(232, 181, 74, .3);
  }
}
/* quiet build stamp, bottom-left of the menu only: never interactive, and it
   keeps clear of the phone's home bar through the safe-area inset */
.build-label {
  position: absolute;
  left: max(16px, env(safe-area-inset-left, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  font-family: var(--sans);
  font-size: .6rem;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: #8d7a61;
  opacity: .6;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}
/* ---------- panels ---------- */
.panel-screen {
  align-items: center;
  justify-content: center;
}
.panel {
  pointer-events: auto;
  width: min(1080px, 100%);
  max-height: min(88dvh, 900px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(16px, 2.2vw, 28px);
  border: 1px solid rgba(232, 181, 74, .32);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(31, 19, 12, .97), rgba(14, 9, 6, .98)),
    repeating-linear-gradient(91deg, rgba(255, 226, 180, .035) 0 2px, transparent 2px 11px);
  box-shadow:
    0 40px 90px -30px rgba(0, 0, 0, .95),
    inset 0 1px 0 rgba(255, 226, 178, .14);
  scrollbar-width: thin;
  scrollbar-color: #6b4f2a transparent;
}
.panel::before {
  content: "";
  position: sticky;
  top: 0;
  display: block;
  height: 2px;
  margin: -2px 0 14px;
  background: linear-gradient(90deg, transparent, rgba(232, 181, 74, .7), transparent);
}
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: #5a4426; border-radius: 8px; }
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.head-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.head-start { min-height: 44px; padding: 8px 16px; }
.panel-head h2, .modal-head h2 {
  margin: .15rem 0 0;
  font-size: clamp(1.4rem, 2vw + .7rem, 2.1rem);
  font-weight: 500;
  letter-spacing: -.01em;
  color: #f8ecd6;
}
.panel-lede {
  margin: -.2rem 0 18px;
  max-width: 66ch;
  font-family: var(--sans);
  font-size: .85rem;
  line-height: 1.5;
  color: #bda98b;
}
.icon-btn {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(232, 181, 74, .3);
  border-radius: 50%;
  background: rgba(20, 12, 8, .8);
  color: #d9c6a4;
  font-size: 1rem;
  cursor: pointer;
}
.icon-btn:active { transform: scale(.94); }
@media (hover: hover) { .icon-btn:hover { border-color: var(--gold); color: var(--gold); } }

/* ---------- setup ---------- */
.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: clamp(18px, 2.6vw, 34px);
  align-items: start;
}
.setup-body { display: grid; gap: 12px; min-width: 0; }
.field {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.field legend {
  width: 100%;
  padding: 0 0 6px;
  font-family: var(--sans);
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #bda98b;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.legend-note {
  font-size: .6rem;
  letter-spacing: .1em;
  color: var(--gold);
  font-weight: 500;
  text-transform: none;
}
.field-note {
  margin: 8px 0 0;
  font-family: var(--sans);
  font-size: .74rem;
  line-height: 1.45;
  color: #9d8a70;
}
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
}
.segmented button {
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid rgba(232, 181, 74, .22);
  border-radius: 4px;
  background: rgba(255, 233, 200, .035);
  color: #d9c6a4;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 1rem;
  transition: background .16s ease, border-color .16s ease;
}
.segmented button small {
  font-family: var(--sans);
  font-size: .56rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #8e7b61;
}
.segmented button[aria-pressed="true"] {
  border-color: rgba(232, 181, 74, .8);
  background: linear-gradient(180deg, rgba(120, 82, 34, .55), rgba(58, 36, 16, .55));
  color: #fff0d4;
  box-shadow: inset 0 0 0 1px rgba(232, 181, 74, .22), 0 0 18px -6px rgba(232, 181, 74, .45);
}
.segmented button[aria-pressed="true"] small { color: var(--gold); }
.segmented.compact button { min-height: 44px; font-size: .9rem; }
/* five quality levels: same row, never wider than the panel on a phone */
.segmented.quality {
  grid-auto-flow: row;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.segmented.quality button { padding: 6px 4px; font-size: .82rem; }
.segmented.quality button small { font-size: .5rem; letter-spacing: .06em; }
@media (max-width: 420px) {
  .segmented.quality { gap: 4px; }
  .segmented.quality button { font-size: .7rem; }
  .segmented.quality button small { font-size: .45rem; letter-spacing: .04em; }
}
.swatches { display: flex; gap: 12px; flex-wrap: wrap; }
.swatches button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 8px 14px 8px 8px;
  border: 1px solid rgba(232, 181, 74, .18);
  border-radius: 999px;
  background: rgba(255, 233, 200, .03);
  color: #d9c6a4;
  cursor: pointer;
  font-family: var(--sans);
  font-size: .8rem;
}
.swatches i {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 2px 5px rgba(255, 255, 255, .18), 0 2px 8px rgba(0, 0, 0, .5);
  border: 1px solid rgba(255, 255, 255, .14);
}
.swatches button[aria-pressed="true"] {
  border-color: var(--swatch, var(--gold));
  background: rgba(232, 181, 74, .1);
  color: #fff0d4;
}
.map-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(150px, 1fr);
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: #5a4426 transparent;
}
.map-row::-webkit-scrollbar { height: 6px; }
/* five across only when a card is wide enough for its name; below that the
   row stays a swipeable filmstrip, which reads better on tablets in landscape */
@media (min-width: 1250px) {
  .map-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-auto-flow: row;
    grid-auto-columns: auto;
    overflow: visible;
    padding-bottom: 2px;
  }
  .map-row .map-card .thumb { aspect-ratio: 16 / 10; }
  .map-row .map-card .card-body { padding: 7px 8px 8px; }
  .map-row .map-card b { font-size: .74rem; }
  .map-row .map-card small { font-size: .56rem; -webkit-line-clamp: 2; }
}
@media (min-width: 700px) and (max-width: 1249px) {
  .map-row { grid-auto-columns: minmax(0, 38%); }
  .map-row .map-card .thumb { aspect-ratio: 16 / 9; }
  .map-row .map-card .card-body { padding: 7px 9px 8px; }
  .map-row .map-card b { font-size: .78rem; }
  .map-row .map-card small { font-size: .58rem; -webkit-line-clamp: 2; }
}
.map-row::-webkit-scrollbar-thumb { background: #5a4426; border-radius: 6px; }
.map-card {
  scroll-snap-align: start;
  min-width: 0;
  padding: 0;
  border: 1px solid rgba(232, 181, 74, .16);
  border-radius: 5px;
  background: rgba(10, 7, 5, .7);
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  transition: border-color .18s ease, transform .18s ease;
}
.map-card .thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  background:
    radial-gradient(60% 60% at 50% 45%, #2a1d14, #100b07);
  overflow: hidden;
}
.map-card .thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  opacity: 0;
  transition: opacity .5s ease;
}
.map-card .thumb img.is-loaded { opacity: 1; }
.map-card .thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(8, 5, 3, .75));
  pointer-events: none;
}
.map-card .card-body { display: block; padding: 9px 10px 10px; }
.card-dots { display: flex; gap: 4px; margin-top: 6px; }
.card-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: inset 0 0 0 1px rgba(255, 244, 222, .28);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .12);
}
.map-card b {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 2.4em;
  font-size: .84rem;
  font-weight: 500;
  line-height: 1.2;
  color: #efdfc2;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.map-card small {
  display: block;
  margin-top: 3px;
  font-family: var(--sans);
  font-size: .6rem;
  line-height: 1.35;
  color: #96826a;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.map-card[aria-selected="true"] {
  border-color: rgba(232, 181, 74, .85);
  box-shadow: 0 0 0 1px rgba(232, 181, 74, .35), 0 10px 26px -16px rgba(232, 181, 74, .5);
}
.map-card[aria-selected="true"] .card-body { background: rgba(232, 181, 74, .06); }
.map-card:active { transform: scale(.99); }
@media (hover: hover) { .map-card:hover { border-color: rgba(232, 181, 74, .5); } }

/* the setup skin picker is a filmstrip: five finishes always reachable,
   swipeable on a phone and scrollable with a mouse or trackpad */
.skin-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.skin-row::-webkit-scrollbar-thumb { background: #5a4426; border-radius: 6px; }
.skin-row .skin-card {
  display: block;
  flex: 1 0 112px;
  max-width: 166px;
  scroll-snap-align: start;
}
.skin-row .skin-card .thumb { aspect-ratio: 16 / 10; height: auto; min-height: 0; }
.skin-row .skin-name { white-space: nowrap; padding: 7px 8px; font-size: .68rem; }
.skin-card {
  border: 1px solid rgba(232, 181, 74, .16);
  border-radius: 5px;
  background: rgba(10, 7, 5, .7);
  padding: 0;
  overflow: hidden;
  text-align: left;
  cursor: pointer;
}
.skin-card .thumb { position: relative; display: block; aspect-ratio: 16 / 10; background: #0b0705; overflow: hidden; }
.skin-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .5s; }
.skin-card img.is-loaded { opacity: 1; }
.skin-name {
  display: block;
  padding: 8px 9px;
  font-size: .74rem;
  color: #e0cfb0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.skin-card[aria-selected="true"] {
  border-color: rgba(232, 181, 74, .85);
  box-shadow: 0 0 0 1px rgba(232, 181, 74, .3);
}
.row-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- aside ---------- */
.setup-aside { position: sticky; top: 0; }
.aside-plaque {
  padding: 16px;
  border: 1px solid rgba(232, 181, 74, .22);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(66, 42, 23, .55), rgba(20, 13, 8, .6));
}
.aside-plaque h3 {
  margin: .35rem 0 .6rem;
  font-size: 1.3rem;
  font-weight: 500;
  color: #f4e6cb;
}
.aside-dots { display: flex; gap: 6px; margin-bottom: 10px; }
.aside-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: inset 0 0 0 1px rgba(255, 244, 222, .28);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .12);
}
.aside-plaque p {
  margin: 0 0 14px;
  font-family: var(--sans);
  font-size: .76rem;
  line-height: 1.5;
  color: #ac977b;
}
.aside-seats { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.aside-seats li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--sans);
  font-size: .76rem;
  color: #cdba9b;
}
.aside-seats i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .14);
}
.aside-seats b { color: #f1e2c7; font-weight: 600; }
.aside-seats em { margin-left: auto; font-style: normal; font-size: .6rem; letter-spacing: .12em; text-transform: uppercase; color: #8f7c62; }
.aside-actions { display: grid; gap: 8px; }

/* ---------- buttons ---------- */
.primary-btn, .ghost-btn {
  min-height: 46px;
  padding: 10px 18px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  transition: transform .16s ease, filter .16s ease, border-color .16s ease;
}
.primary-btn {
  border: 1px solid rgba(255, 216, 150, .5);
  background: linear-gradient(180deg, #d8a84c, #9a6a24);
  color: #241306;
  box-shadow: inset 0 1px 0 rgba(255, 245, 220, .55), 0 10px 24px -12px rgba(232, 181, 74, .6);
}
.ghost-btn {
  border: 1px solid rgba(232, 181, 74, .26);
  background: rgba(28, 18, 11, .7);
  color: #d7c4a3;
}
.primary-btn.danger { background: linear-gradient(180deg, #b04a56, #6e1c2a); color: #ffe9e2; }
.primary-btn:active, .ghost-btn:active { transform: translateY(1px) scale(.99); }
@media (hover: hover) {
  .primary-btn:hover { filter: brightness(1.08); }
  .ghost-btn:hover { border-color: rgba(232, 181, 74, .6); color: #f0dfc2; }
}

/* ---------- galleries ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.gallery .map-card .thumb { aspect-ratio: 4 / 3; }
.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.skin-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.skin-gallery .skin-card .thumb { aspect-ratio: 16 / 10; }
.skin-gallery .skin-card .skin-name { padding: 10px 12px; }

/* preview placeholders: a soft brass sweep until the real render arrives */
.thumb.is-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0) 32%, rgba(232, 181, 74, .13) 48%, rgba(255, 255, 255, 0) 64%);
  background-size: 240% 100%;
  animation: thumb-sweep 1.5s linear infinite;
}
.thumb-status {
  position: absolute;
  left: 50%;
  bottom: 9px;
  z-index: 2;
  transform: translateX(-50%);
  font: 500 .56rem/1 var(--sans);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(232, 181, 74, .72);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity .3s ease;
}
.thumb.is-loaded .thumb-status { opacity: 0; }
@keyframes thumb-sweep {
  from { background-position: 170% 0; }
  to { background-position: -70% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .thumb.is-loading::before { animation: none; }
}
.skin-room-note {
  margin: .35rem 0 1rem;
  font-family: var(--sans);
  font-size: .72rem;
  line-height: 1.5;
  color: #a08a6d;
}
.skin-room-note b { color: #e8c987; font-weight: 600; }
.skin-gallery .skin-card small {
  display: block;
  padding: 0 12px 12px;
  font-family: var(--sans);
  font-size: .66rem;
  line-height: 1.4;
  color: #9b876c;
}

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding:
    calc(10px + var(--safe-top)) calc(12px + var(--safe-right))
    10px calc(12px + var(--safe-left));
  background: linear-gradient(180deg, rgba(9, 6, 4, .88), rgba(9, 6, 4, .55) 62%, transparent);
}
.turn-badge {
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 12px 6px 8px;
  border: 1px solid rgba(232, 181, 74, .24);
  border-radius: 999px;
  background: rgba(18, 11, 7, .72);
}
.turn-dot {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .18);
  background: var(--cream);
  box-shadow: 0 0 0 3px rgba(232, 181, 74, .08);
}
.turn-text { display: grid; line-height: 1.15; min-width: 0; }
.turn-text b {
  font-family: var(--sans);
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: #f4e6cb;
  white-space: nowrap;
}
.turn-text span {
  font-family: var(--sans);
  font-size: .6rem;
  color: #a58f72;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 210px;
}
.score-strip {
  display: flex;
  gap: 6px;
  flex: 0 1 auto;
  overflow: hidden;
}
.score-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid rgba(232, 181, 74, .14);
  border-radius: 999px;
  background: rgba(16, 10, 6, .6);
  font-family: var(--sans);
  font-size: .62rem;
  color: #c8b493;
  white-space: nowrap;
}
.score-chip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot);
  border: 1px solid rgba(255, 255, 255, .18);
}
.score-chip b { color: #f2e3c6; font-weight: 600; }
.score-chip.out { opacity: .4; }
.hud-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}
.hud-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid rgba(232, 181, 74, .24);
  border-radius: 4px;
  background: rgba(20, 13, 8, .82);
  color: #e2d0b0;
  font-family: var(--sans);
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  cursor: pointer;
}
.hud-btn.icon { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; }
.hud-btn.icon span { font-size: .6rem; letter-spacing: .08em; }
.hud-btn:active { transform: translateY(1px); }
@media (hover: hover) { .hud-btn:hover { border-color: rgba(232, 181, 74, .65); } }

.game-foot {
  position: fixed;
  left: 50%;
  bottom: calc(10px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 4;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(720px, calc(100% - 20px));
  padding: 8px 10px;
  border: 1px solid rgba(232, 181, 74, .2);
  border-radius: 999px;
  background: rgba(14, 9, 6, .82);
  backdrop-filter: blur(8px);
}
.die-readout {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-width: 58px;
  padding: 4px 10px;
  border: 1px solid rgba(232, 181, 74, .2);
  border-radius: 999px;
  background: rgba(236, 226, 205, .08);
}
.die-readout span {
  font-size: 1.05rem;
  color: #f6e8cc;
  line-height: 1;
}
.die-readout.shake { animation: readout-shake .45s ease; }
@keyframes readout-shake {
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
.die-readout small {
  font-family: var(--sans);
  font-size: .5rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #9b876c;
}
.game-message {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--sans);
  font-size: .74rem;
  line-height: 1.35;
  color: #cdb995;
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.auto-btn { pointer-events: auto; min-height: 44px; padding: 8px 14px; font-size: .66rem; }

/* ---------- victory ---------- */
.victory-screen { align-items: center; justify-content: center; pointer-events: none; }
.victory-card {
  pointer-events: auto;
  width: min(520px, 100%);
  padding: clamp(22px, 3vw, 36px);
  border: 1px solid rgba(232, 181, 74, .4);
  border-radius: 8px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(120, 70, 26, .3), transparent 60%),
    linear-gradient(180deg, rgba(26, 16, 10, .97), rgba(11, 7, 5, .98));
  box-shadow: 0 46px 100px -30px #000, inset 0 1px 0 rgba(255, 226, 178, .2);
  text-align: center;
  animation: screen-in .6s both;
}
.victory-card h2 {
  margin: .4rem 0 .5rem;
  font-size: clamp(1.6rem, 3vw + .7rem, 2.5rem);
  font-weight: 500;
  color: #f8ecd6;
}
.victory-card .victory-sub {
  margin: 0 0 18px;
  font-family: var(--sans);
  font-size: .82rem;
  color: #b09b7e;
}
.finish-order {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: grid;
  gap: 7px;
  text-align: left;
}
.finish-order li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid rgba(232, 181, 74, .14);
  border-radius: 4px;
  background: rgba(255, 236, 205, .03);
  font-family: var(--sans);
  font-size: .8rem;
  color: #d9c6a4;
}
.finish-order li b { color: #f4e6cb; font-weight: 600; }
.finish-order li i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .16);
}
.finish-order li em {
  margin-left: auto;
  font-style: normal;
  font-size: .62rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #8e7a5f;
}
.finish-order li:first-child { border-color: rgba(232, 181, 74, .45); background: rgba(232, 181, 74, .08); }
.finish-order li:first-child em { color: var(--gold); }
.victory-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- modals ---------- */
.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: calc(14px + var(--safe-top)) 14px calc(14px + var(--safe-bottom));
  background: rgba(4, 3, 2, .62);
  backdrop-filter: blur(6px);
  animation: fade-in .25s both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(620px, 100%);
  max-height: min(90dvh, 860px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(232, 181, 74, .35);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(32, 20, 12, .99), rgba(12, 8, 5, .99)),
    repeating-linear-gradient(91deg, rgba(255, 226, 180, .03) 0 2px, transparent 2px 10px);
  box-shadow: 0 40px 90px -28px #000, inset 0 1px 0 rgba(255, 226, 178, .16);
  animation: screen-in .35s both;
  scrollbar-width: thin;
  scrollbar-color: #5a4426 transparent;
}
.modal.small { width: min(440px, 100%); }
.modal-head {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid rgba(232, 181, 74, .12);
  background: linear-gradient(180deg, rgba(32, 20, 12, .99), rgba(24, 15, 9, .99));
}
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 20px 20px;
  scrollbar-width: thin;
  scrollbar-color: #5a4426 transparent;
}
.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 54px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(232, 181, 74, .09);
}
.setting:last-of-type { border-bottom: 0; }
.setting.column { display: grid; gap: 10px; border-bottom: 0; padding-top: 14px; }
.setting b { display: block; font-family: var(--sans); font-size: .82rem; font-weight: 600; color: #edddc0; }
.setting small { display: block; margin-top: 2px; font-family: var(--sans); font-size: .68rem; color: #96826a; }
/* the whole 56 × 44 box is the tap target; the pill itself is drawn in ::before */
.toggle {
  position: relative;
  width: 56px;
  height: 44px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.toggle::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 6px;
  height: 32px;
  border: 1px solid rgba(232, 181, 74, .3);
  border-radius: 999px;
  background: rgba(0, 0, 0, .45);
  transition: background .2s ease, border-color .2s ease;
}
.toggle span {
  position: absolute;
  z-index: 1;
  top: 10px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #8f7c62;
  transition: transform .2s cubic-bezier(.3, .8, .3, 1), background .2s ease;
}
.toggle[aria-checked="true"]::before { background: rgba(232, 181, 74, .22); border-color: rgba(232, 181, 74, .7); }
.toggle[aria-checked="true"] span { transform: translateX(24px); background: var(--gold); }
.slider {
  width: min(220px, 46%);
  accent-color: var(--gold);
  height: 44px;
}
.modal-note {
  margin: 16px 0 0;
  font-family: var(--sans);
  font-size: .68rem;
  line-height: 1.5;
  color: #8e7a5f;
}
.rules { margin: 0 0 18px; padding-left: 20px; display: grid; gap: 9px; }
.rules li { font-family: var(--sans); font-size: .8rem; line-height: 1.5; color: #b9a588; }
.rules b { color: #ead9ba; font-weight: 600; }
.rule-demo {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(232, 181, 74, .18);
  border-radius: 6px;
  background: rgba(255, 236, 205, .03);
}
.demo-board {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  background:
    radial-gradient(70% 60% at 50% 45%, #3a291a, #1a110a 75%);
  border: 1px solid rgba(232, 181, 74, .18);
}
.demo-pawn {
  position: absolute;
  width: 26px;
  height: 34px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50% 50% 40% 40%;
  background: linear-gradient(180deg, #b03452, #5c1020);
  box-shadow: inset 0 4px 6px rgba(255, 255, 255, .2), 0 6px 12px rgba(0, 0, 0, .55);
}
.demo-pawn:nth-child(2) { left: 26%; top: 68%; width: 20px; height: 27px; background: linear-gradient(180deg, #f0dda9, #b09a63); }
.demo-pawn:nth-child(3) { left: 72%; top: 34%; width: 20px; height: 27px; background: linear-gradient(180deg, #e88a33, #a55412); }
.demo-pawn:nth-child(3).lit { animation: demo-pulse 1.4s infinite; box-shadow: 0 0 0 4px rgba(232, 181, 74, .18), 0 0 22px rgba(232, 181, 74, .7); }
.demo-pawn:nth-child(3).lit::after {
  content: "";
  position: absolute;
  inset: -12px -10px -8px;
  border-radius: 50%;
  border: 2px solid rgba(232, 181, 74, .6);
  opacity: .7;
}
@keyframes demo-pulse { 50% { filter: brightness(1.25); } }
.demo-copy b { font-family: var(--sans); font-size: .8rem; color: #f0e0c2; }
.demo-copy p { margin: 6px 0 10px; font-family: var(--sans); font-size: .72rem; line-height: 1.5; color: #a99578; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- loading / error ---------- */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background:
    radial-gradient(60% 50% at 50% 44%, #241609, #0b0705 70%);
  transition: opacity .6s ease, visibility .6s;
}
.loading-screen.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-mark {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 1px solid rgba(232, 181, 74, .2);
  border-top-color: var(--gold);
  animation: spin 1.1s linear infinite;
  position: relative;
}
.loading-mark::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  border: 1px solid rgba(139, 31, 58, .55);
  border-bottom-color: transparent;
  animation: spin 1.7s linear infinite reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title { margin: 6px 0 0; font-size: 1.1rem; letter-spacing: .08em; color: #f1e2c7; }
.loading-sub {
  margin: 0;
  font-family: var(--sans);
  font-size: .62rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #8e7a5f;
}
/* the door's threshold: black under the loading screen, and its gold bar */
.fade-layer {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: #050302;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .42s ease, visibility .42s;
}
.fade-layer.is-on { opacity: 1; visibility: visible; }
.loading-bar {
  width: min(240px, 56vw);
  height: 2px;
  margin-top: 4px;
  border-radius: 2px;
  background: rgba(232, 181, 74, .16);
  overflow: hidden;
}
.loading-bar i {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, rgba(139, 31, 58, .9), var(--gold));
  box-shadow: 0 0 12px rgba(232, 181, 74, .45);
  transition: transform .5s cubic-bezier(.4, 0, .2, 1);
}
/* the Start sequence owns the screen: nothing in the app takes a click */
.app.is-busy, .app.is-busy * { pointer-events: none !important; }
.webgl-error {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #0b0705;
}
.webgl-card {
  width: min(480px, 100%);
  padding: 26px;
  border: 1px solid rgba(232, 181, 74, .3);
  border-radius: 8px;
  background: #140d08;
  text-align: center;
}
.webgl-card h2 { margin: .4rem 0 .6rem; font-weight: 500; }
.webgl-card p { font-family: var(--sans); font-size: .8rem; line-height: 1.55; color: #b39e80; }
.webgl-detail { color: #8e7a5f !important; font-size: .72rem !important; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .setup-grid { grid-template-columns: minmax(0, 1fr) 270px; }
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .skin-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .menu-screen { flex-direction: column; justify-content: flex-start; padding-top: calc(18px + var(--safe-top)); }
  .menu-screen::before {
    background:
      linear-gradient(0deg, rgba(5, 3, 2, .92) 0%, rgba(5, 3, 2, .72) 38%, rgba(5, 3, 2, .18) 66%, transparent 84%),
      linear-gradient(180deg, rgba(5, 3, 2, .72), transparent 26%);
  }
  /* room for the build stamp under the plaques: its own height plus 20px */
  .menu-screen { padding-bottom: calc(48px + var(--safe-bottom)); }
  .menu-panel { width: 100%; gap: 14px; flex: 1; justify-content: flex-start; }
  .plaques { margin-top: auto; }
  .brand h1 { font-size: clamp(2.2rem, 11vw, 3.4rem); }
  .plaques { max-width: none; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
  .plaque { min-height: 58px; padding: 10px 13px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; }
  .plaque span { font-size: .95rem; }
  .plaque small { font-size: .52rem; }
  .setup-grid { grid-template-columns: 1fr; }
  .setup-aside { position: static; }
  .aside-plaque { padding: 14px; }
  .aside-seats { grid-template-columns: 1fr 1fr; }
  .aside-actions { grid-template-columns: 1fr 1fr; }
  .aside-actions .primary-btn { grid-column: 1 / -1; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .skin-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel { max-height: calc(100dvh - 24px - var(--safe-top) - var(--safe-bottom)); }
  .setup-body { gap: 10px; }
  .field legend { padding-bottom: 4px; }
  .map-row .map-card .thumb { aspect-ratio: 16 / 9; }
  .score-strip .score-chip:nth-child(n+3) { display: none; }
  .hud { flex-wrap: wrap; row-gap: 6px; }
  .score-strip { order: 3; width: 100%; padding-left: 2px; }
  .turn-text span { max-width: 120px; }
  .hud-btn { padding: 8px 9px; }
  .hud-btn.icon span { display: none; }
}
@media (max-width: 560px) {
  .screen { padding-left: calc(12px + var(--safe-left)); padding-right: calc(12px + var(--safe-right)); }
  .panel { padding: 14px 12px 16px; border-radius: 6px; }
  .panel-head h2 { font-size: 1.4rem; }
  .swatches { gap: 8px; }
  .swatches button { padding-right: 10px; }
  .map-row { grid-auto-columns: 74%; }
  .skin-row .skin-card { flex-basis: 118px; }
  .skin-gallery {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .skin-gallery .skin-card { flex: 0 0 78%; scroll-snap-align: start; }
  .skin-gallery .skin-card .skin-name { padding: 8px 10px; }
  .skin-gallery .skin-card small { padding: 0 10px 10px; }
  .gallery { grid-template-columns: 1fr 1fr; gap: 8px; }
  .map-card .card-body small { display: none; }
  .rule-demo { grid-template-columns: 1fr; }
  .demo-board { max-width: 200px; margin: 0 auto; }
  .setting small { max-width: 24ch; }
  .victory-card { padding: 20px 16px; }
  .game-foot { gap: 6px; padding: 6px 8px; }
  .die-readout { min-width: 48px; padding: 4px 8px; }
  .game-message { font-size: .68rem; }
  .auto-btn { padding: 8px 10px; font-size: .6rem; }
  .turn-badge { padding-right: 9px; }
  .turn-dot { width: 22px; height: 22px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .menu-screen { padding-top: calc(10px + var(--safe-top)); }
  .menu-panel { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 16px; }
  .brand h1 { font-size: 2rem; }
  .plaques { grid-template-columns: 1fr 1fr; gap: 6px; }
  .plaque { min-height: 44px; padding: 7px 10px; }
  .plaque small { display: none; }
  .panel { max-height: calc(100dvh - 32px); }
  .game-foot { width: min(620px, calc(100% - 16px)); }
  .hud { padding-top: calc(6px + var(--safe-top)); padding-bottom: 6px; }
  .score-strip { order: 2; width: auto; }
  .hud-actions { margin-left: auto; }
  .turn-text span { max-width: 150px; }
}

/* short laptops: trim the setup stack so the skin row clears the fold */
@media (max-height: 820px) and (min-width: 821px) {
  .panel { padding: 18px 22px; }
  .panel-head { margin-bottom: 8px; }
  .setup-grid { gap: 24px; }
  .setup-body { gap: 8px; }
  .field legend { padding-bottom: 4px; }
  .map-row { gap: 8px; }
  .map-row .map-card .thumb { aspect-ratio: 16 / 8.4; }
  .map-row .map-card .card-body { padding: 6px 8px 7px; }
  .map-row .map-card small { font-size: .55rem; -webkit-line-clamp: 1; }
  .skin-row .skin-card .thumb { min-height: 54px; }
  .skin-row .skin-name { padding: 6px 8px; }
  .field-note { margin-top: 6px; }
}

/* small phones in portrait: the brand line steps aside so the plaques fit */
@media (max-height: 700px) and (max-width: 820px) and (orientation: portrait) {
  .menu-screen { padding-top: calc(12px + var(--safe-top)); }
  .menu-panel { gap: 10px; }
  .brand h1 { font-size: clamp(2rem, 10vw, 2.8rem); }
  .brand h1 { margin-bottom: .3rem; }
  .plaques { gap: 6px; }
  .plaque { min-height: 48px; padding: 8px 12px; }
}

/* short landscape phones: the victory card cannot be taller than the screen */
@media (max-height: 620px) {
  .victory-card { width: min(620px, 100%); padding: 14px 18px; }
  .victory-card .eyebrow { font-size: .54rem; }
  .victory-card h2 { margin: .2rem 0 .25rem; font-size: clamp(1.25rem, 3.2vw + .4rem, 1.7rem); }
  .victory-card .victory-sub { margin-bottom: 8px; font-size: .72rem; }
  .finish-order { grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 10px; }
  .finish-order li { padding: 5px 8px; font-size: .72rem; }
  .victory-actions .primary-btn, .victory-actions .ghost-btn { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}
