/* Tall Country – the Screen.
 *
 * Read from the far side of a table, so everything here is oversized on
 * purpose. Phase 0 establishes the frame and the key grading; the nine real
 * modes (location, cast, fight, showdown, the fire, omens, trail, Death's Door,
 * quiet) arrive in Phase 2. */

:root {
  --ink: #f2e9d8;
  --dim: #9d8f78;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: #14100c;
  color: var(--ink);
  font: 16px/1.4 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  overflow: hidden;
}

/* The key is a visual, not a note. Major sits in high sun; minor is a cold
 * night. Any player can call it, so this class is swapped by an event that may
 * arrive from a phone. */
.stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 4vmin;
  transition: background 900ms ease, color 900ms ease;
}

.stage[data-key="major"] {
  background:
    radial-gradient(120vmax 80vmax at 50% -10%, #f0d9a4 0%, #d9a862 38%, #8d5f33 70%, #43291a 100%);
  color: #2a1c10;
}

.stage[data-key="minor"] {
  background:
    radial-gradient(110vmax 80vmax at 50% 120%, #2b3a4a 0%, #1a222d 45%, #0d1116 100%);
  color: #cfd8e2;
}

.title {
  font-size: clamp(2.5rem, 7.5vw, 7rem);
  line-height: 1.02;
  letter-spacing: 0.02em;
  margin: 0;
  max-width: 20ch;
  text-wrap: balance;
}

.mode {
  font-size: clamp(0.7rem, 1.3vw, 1rem);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  opacity: 0.6;
  margin: 0 0 2.5vmin;
}

.hail {
  margin-top: 4vmin;
  font-size: clamp(1rem, 2.4vw, 2rem);
  font-style: italic;
  opacity: 0.85;
  max-width: 28ch;
}
.hail b { font-style: normal; font-weight: 600; opacity: 0.7; }

.roster {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 2.5vmin;
  justify-content: center;
  padding: 2vmin;
  font-size: clamp(0.7rem, 1.2vw, 1rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.55;
}

.keymark {
  position: absolute;
  top: 2vmin; right: 2.5vmin;
  font-size: clamp(0.65rem, 1.1vw, 0.9rem);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  opacity: 0.45;
}

/* Setup and connection trouble. Deliberately quiet – this is on a wall. */
.setup {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  background: #14100c;
  color: var(--ink);
  padding: 6vmin;
  text-align: center;
}
.setup input {
  font: inherit;
  padding: 0.6rem 0.8rem;
  width: min(28rem, 80vw);
  background: #1e1811;
  color: var(--ink);
  border: 1px solid #4a3f2f;
  border-radius: 2px;
}
.setup button {
  font: inherit;
  padding: 0.6rem 1.4rem;
  background: #f2e9d8;
  color: #14100c;
  border: 0;
  border-radius: 2px;
  cursor: pointer;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.setup .note { color: var(--dim); max-width: 40ch; }

.offline {
  position: absolute;
  bottom: 2vmin; left: 2.5vmin;
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #c9553f;
}
.hidden { display: none !important; }

/* ── Phase 1: dice on the Screen ──────────────────────────────────────── */

.sdice { display: flex; flex-wrap: wrap; gap: 1vmin; justify-content: center; margin-bottom: 2vmin; }
.sdie {
  width: clamp(2.4rem, 6vmin, 5rem);
  height: clamp(2.4rem, 6vmin, 5rem);
  display: grid; place-items: center;
  font-size: clamp(1.1rem, 3vmin, 2.4rem);
  border: 2px solid currentColor; border-radius: 6px;
  opacity: .35;
}
.sdie.hit { opacity: 1; font-weight: 700; }
.sdie.ace {
  opacity: 1; font-weight: 700; border-width: 3px;
  box-shadow: 0 0 0 2px rgba(168,121,31,.35), 0 0 3vmin rgba(240,217,164,.35);
}

.sverdict { font-size: clamp(1.1rem, 3vw, 2.6rem); font-style: normal; }
.sstretch, .sflourish {
  margin-top: 1.2vmin;
  font-size: clamp(.8rem, 1.5vw, 1.2rem);
  letter-spacing: .18em; text-transform: uppercase; opacity: .7;
}

/* The stage takes its cue from the outcome. Deliberately subtle: a border, not
 * a colour wash, so the key's own grading still reads as the dominant mood. */
.stage[data-roll="clean"]   { box-shadow: inset 0 0 0 .6vmin rgba(120,190,130,.45); }
.stage[data-roll="partial"] { box-shadow: inset 0 0 0 .6vmin rgba(200,160,60,.45); }
.stage[data-roll="miss"]    { box-shadow: inset 0 0 0 .6vmin rgba(190,70,50,.5); }

.roster i { font-style: normal; opacity: .75; letter-spacing: .06em; }
.roster i.rw { color: #d08878; }
.roster i.rd { color: #e0a34a; }

/* ── Phase 2: plates, the cut, and the cast ───────────────────────────── */

/* The image sits behind everything, cropped to the card's focus point. When a
 * card has no image the stage falls back to its typographic title card, so the
 * Screen is never blocked on art existing. */
.plate {
  position: absolute; inset: 0;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 600ms ease;
}
.stage[data-plate="on"] .plate { opacity: 1; }

/* Keeps type legible over any photograph without dimming the whole image. */
.vignette {
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 600ms ease;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 30%, rgba(0,0,0,.55) 100%),
    linear-gradient(to top, rgba(0,0,0,.7) 0%, transparent 45%);
}
.stage[data-plate="on"] .vignette { opacity: 1; }
.stage[data-plate="on"] .title,
.stage[data-plate="on"] .mode,
.stage[data-plate="on"] .sub { color: #f6efe2; text-shadow: 0 .2vmin 2vmin rgba(0,0,0,.75); }

.frame {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  width: 100%; height: 100%;
  text-align: center;
}

.sub {
  font-size: clamp(.95rem, 2vw, 1.8rem);
  font-style: italic; opacity: .85;
  margin-top: 1.5vmin; max-width: 26ch;
}

/* ── the cut ──────────────────────────────────────────────────────────── */

.wipe {
  position: fixed; inset: 0; z-index: 50;
  background: #0b0907;
  display: grid; place-items: center;
  opacity: 0; pointer-events: none;
  transition: opacity 200ms ease;
}
.wipe.on { opacity: 1; }
.wipe span {
  color: #cdbfa6;
  font-size: clamp(1rem, 2.4vw, 2rem);
  letter-spacing: .34em; text-transform: uppercase;
  opacity: 0; transform: translateY(.6rem);
}
.wipe.on span { animation: wipeIn 420ms ease forwards; }
@keyframes wipeIn {
  0%   { opacity: 0; transform: translateY(.6rem); }
  35%  { opacity: 1; transform: translateY(0); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ── the cast ─────────────────────────────────────────────────────────── */

.cast {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 2.5vmin; margin-top: 1vmin;
}
.cast:empty { display: none; }
.face { margin: 0; width: clamp(9rem, 15vw, 15rem); }
.face-img {
  width: 100%; aspect-ratio: 3 / 4;
  background-size: cover; background-position: center;
  border: .3vmin solid currentColor; border-radius: 3px;
  opacity: .95;
}
.face-img.none { background: rgba(255,255,255,.06); }
.face figcaption {
  margin-top: .8vmin;
  font-size: clamp(.8rem, 1.5vw, 1.3rem);
  letter-spacing: .04em;
}
.face figcaption span {
  display: block; font-style: italic; opacity: .65;
  font-size: .8em; letter-spacing: 0;
}

/* When a roll is live it owns the stage; the plate stays as the ground. */
.stage[data-mode="roll"] .sub { display: none; }
