/* Palette drawn from the book cover and the approved stills: night ink,
   frost grey, lantern brass. */
:root {
  --ink: #0d0f12;
  --frost: #d9dde0;
  --mist: #8d969c;
  --brass: #c8a35a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--frost);
  font-family: var(--serif);
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  text-align: center;
  background: radial-gradient(ellipse at center, #1a1e24 0%, var(--ink) 70%);
  transition: opacity 1.2s ease;
}
.overlay.gone { opacity: 0; pointer-events: none; }

.kicker { margin: 0; letter-spacing: 0.3em; text-transform: uppercase; font-size: 0.8rem; color: var(--mist); }
h1 { margin: 0; font-weight: normal; font-size: clamp(2.2rem, 7vw, 4.5rem); letter-spacing: 0.04em; }
.subtitle { margin: 0 0 1.5rem; font-style: italic; font-size: clamp(1.1rem, 3vw, 1.5rem); color: var(--brass); }
.note { margin: 0.75rem 0 0; font-size: 0.85rem; color: var(--mist); }

button {
  font: inherit;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  color: var(--frost);
  background: transparent;
  border: 1px solid var(--brass);
  padding: 0.7rem 2rem;
  cursor: pointer;
}
button:hover:not(:disabled) { background: rgba(200, 163, 90, 0.12); }
button:disabled { opacity: 0.5; cursor: default; }

button.small { font-size: 0.85rem; padding: 0.35rem 1rem; letter-spacing: 0.08em; margin-top: 0.4rem; border-color: rgba(200, 163, 90, 0.6); }
button.small[hidden] { display: none; }

/* Quinn's skill: Gentle · Fair · Sharp (landing, and the end of a game). */
.levels { display: flex; align-items: center; justify-content: center; gap: 0.35rem; margin: 0.9rem 0 0.2rem; flex-wrap: wrap; }
.levels-label { font-size: 0.8rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--mist); margin-right: 0.4rem; }
.levels button { font-size: 0.9rem; padding: 0.3rem 0.85rem; letter-spacing: 0.06em; border-color: rgba(200, 163, 90, 0.35); color: var(--mist); }
.levels button.on { border-color: var(--brass); color: var(--frost); background: rgba(200, 163, 90, 0.14); }
.hud-levels { margin: 0 0 0.8rem; }
.hud-levels .levels-label { color: var(--frost); opacity: 0.75; }

.credits-link { position: absolute; bottom: 1rem; left: 1rem; font-size: 0.8rem; color: var(--mist); text-decoration: none; letter-spacing: 0.1em; }
.credits-link:hover { color: var(--brass); }
.end-card .credits { margin: 0.9rem 0 0; font-size: 0.8rem; font-style: normal; }
.end-card .credits a { border: none; background: none; padding: 0; color: var(--mist); }

.tier { position: absolute; bottom: 1rem; right: 1rem; font-size: 0.8rem; color: var(--mist); }
.tier select { font: inherit; background: var(--ink); color: var(--frost); border: 1px solid #333; }

.prompt {
  position: fixed;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--frost);
  text-shadow: 0 0 8px #000;
  pointer-events: none;
}

.card {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(1rem, 2.6vw, 1.4rem);
  letter-spacing: 0.08em;
  pointer-events: none;
  z-index: 9;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  transition: opacity 1.4s ease;
}
.card.faded { opacity: 0; }
.card .waiting { display: inline-block; font-size: 2rem; letter-spacing: 0.3em; animation: waiting 1.6s ease-in-out infinite; }
@keyframes waiting { 0%, 100% { opacity: 0.25; } 50% { opacity: 0.8; } }

/* The gray between worlds (src/fx/veil.js). Above the scene and its HUD. */
.veil {
  position: fixed;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  z-index: 8;
}

/* --- The Gate: title over the night plate, and the end card ---------------- */
.gate-title {
  position: fixed;
  left: 50%;
  top: 9%;
  transform: translateX(-50%);
  width: calc(100vw - 32px);
  text-align: center;
  pointer-events: none;
  text-shadow: 0 0 18px rgba(0, 0, 0, 0.9), 0 1px 3px #000;
  opacity: 0;
  transition: opacity 2.4s ease;
  z-index: 3;
}
.gate-title.on { opacity: 1; }
.gate-title h1 { font-size: clamp(2rem, 6vw, 4rem); }
.gate-title .subtitle { margin: 0.3rem 0 0; }
@media (max-height: 500px) {
  .gate-title { top: 4%; }
  .gate-title h1 { font-size: clamp(1.6rem, 5vw, 2.6rem); }
  .gate-title .subtitle { font-size: 1rem; margin-top: 0; }
}
.prompt.gate { transition: opacity 1.2s ease; }
.prompt.later { opacity: 0; }

.end-card {
  position: fixed;
  left: 50%;
  bottom: 9%;
  transform: translateX(-50%);
  width: min(34rem, calc(100vw - 32px));
  text-align: center;
  text-shadow: 0 0 18px rgba(0, 0, 0, 0.95), 0 1px 3px #000;
  opacity: 0;
  transition: opacity 2.4s ease;
  z-index: 3;
}
.end-card.on { opacity: 1; }
.end-card p { margin: 0 0 0.9rem; font-style: italic; font-size: clamp(1rem, 2.2vw, 1.25rem); }
.end-card nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; }
.end-card a, .end-card button {
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--frost);
  text-decoration: none;
  background: rgba(13, 15, 18, 0.45);
  border: 1px solid rgba(200, 163, 90, 0.6);
  padding: 0.5rem 1.1rem;
}
.end-card a:hover, .end-card button:hover { background: rgba(200, 163, 90, 0.16); }

/* --- Board HUD: type over the scene, no panels ----------------------------- */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  color: var(--frost);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 12px rgba(0, 0, 0, 0.6);
  font-size: clamp(0.95rem, 1.6vw, 1.15rem);
}
.hud button { pointer-events: auto; }

.hud-pips {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  letter-spacing: 0.06em;
  opacity: 0.85;
  transition: opacity 0.4s;
}
.hud-pips .who { font-style: italic; }
.hud-pips .n { font-variant-numeric: oldstyle-nums; margin-left: 0.3em; }
.hud-quinn { top: 14px; }
.hud-you { bottom: 14px; }
.hud.turn-you .hud-you .who, .hud.turn-quinn .hud-quinn .who { color: var(--brass); }
.hud.no-pips .n { display: none; }

.hud-line {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.8em;
  white-space: nowrap;
}
.hud-prompt { font-style: italic; }
.hud-dice .die { font-size: 1.6em; line-height: 1; margin: 0 0.06em; transition: opacity 0.3s; }
.hud-dice .die.used { opacity: 0.3; }

.hud-buttons {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: 12px;
  display: flex;
  gap: 0.6rem;
}
.hud-buttons button, .hud-end button, .hud-toggles button {
  font-size: 1rem;
  padding: 0.45rem 1.1rem;
  background: rgba(13, 15, 18, 0.35);
  border: 1px solid rgba(200, 163, 90, 0.6);
  text-shadow: inherit;
}
.hud-buttons .hud-done.ready { border-color: var(--brass); color: #fff; }
.hud-buttons button[hidden] { display: none; }

.hud-toggles {
  position: absolute;
  top: 10px;
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  gap: 0.4rem;
}
.hud-toggles button {
  font-size: 0.8rem !important;
  padding: 0.2rem 0.6rem !important;
  font-style: italic;
  opacity: 0.45;
  transition: opacity 0.3s;
}
.hud-toggles button.on { opacity: 0.85; }
.hud-toggles .hud-quit { opacity: 0.7; font-style: normal; }
.hud-toggles .hud-quit.on { opacity: 1; color: #fff; border-color: var(--brass); }

.hud-end {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.hud-end[hidden], .hud-staying[hidden] { display: none; }
.hud-choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; }
.hud-staying {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: 12px;
  display: flex;
  gap: 0.6rem;
}
.hud-staying button {
  font-size: 0.95rem;
  padding: 0.45rem 1.1rem;
  background: rgba(13, 15, 18, 0.35);
  border: 1px solid rgba(200, 163, 90, 0.6);
}
/* Staying a while: the board's own type steps aside for the river. */
.hud.is-staying > :not(.hud-staying) { opacity: 0; pointer-events: none; }
.hud.is-gone { opacity: 0; transition: opacity 0.8s; }
.hud.is-gone * { pointer-events: none !important; }
.hud > * { transition: opacity 0.6s; }
.hud-result { font-size: clamp(1.6rem, 4vw, 2.6rem); margin: 0 0 1rem; letter-spacing: 0.04em; }

/* --- Subtitles: the book's style, lowercase italic, above the HUD line ------- */
.subs {
  position: fixed;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  width: min(42rem, calc(100vw - 32px));
  text-align: center;
  pointer-events: none;
  font-style: italic;
  font-size: clamp(1rem, 1.8vw, 1.3rem);
  line-height: 1.35;
  color: var(--frost);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95), 0 0 14px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 5;
}
.subs.on { opacity: 1; }
.subs p { margin: 0; }
.subs-who { color: var(--brass); letter-spacing: 0.04em; }

/* Touch: bigger targets. */
@media (pointer: coarse) {
  .hud-buttons button, .hud-end button { font-size: 1.15rem; padding: 0.7rem 1.4rem; }
  .hud-toggles button { font-size: 0.95rem !important; padding: 0.45rem 0.8rem !important; }
  .hud-line { bottom: 64px; }
  .subs { bottom: 104px; }
}

/* Phones in portrait: the board is landscape-only. */
.hud-rotate { display: none; }
@media (pointer: coarse) and (orientation: portrait) {
  .hud-rotate {
    display: flex;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: rgba(13, 15, 18, 0.82);
    pointer-events: auto;
    font-style: italic;
    font-size: 1.3rem;
    text-align: center;
    padding: 16px;
  }
}

/* --- The lane: the blockout plan (M) --------------------------------------- */
.lane-map {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  text-align: center;
  pointer-events: none;
}
.lane-map[hidden] { display: none; }
.lane-map canvas { border: 1px solid rgba(200, 163, 90, 0.5); }
.lane-map p { margin: 0.3rem 0 0; font-size: 0.8rem; font-style: italic; color: var(--mist); text-shadow: 0 0 6px #000; }
