:root {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --ink: #2b2620;
  --muted: #6f665a;
  --line: #d9d1c3;
  --accent: #b5651d;
  --accent-ink: #fff;
  --option: #ff9f1c;
  --holy: #f3dc8a;
  --judgment: #c9b6dd;
  --miracle: #b8d8ec;
  --empty: #e6e0d4;
  --birth: #8c8273;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
a { color: var(--accent); }
.brand { color: inherit; text-decoration: none; font-weight: 700; }
.muted { color: var(--muted); }
.small-text { font-size: .85rem; }
.error { color: #a93226; font-weight: 600; }

button {
  font: inherit;
  padding: .45rem .9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.small { padding: .2rem .6rem; font-size: .85rem; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--option); outline-offset: 2px; }

input, select {
  font: inherit;
  padding: .45rem .6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.row { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.row input { flex: 1; }

/* ---- Start page and lobby ---- */

.page { max-width: 560px; margin: 0 auto; padding: 2rem 16px; }
.form { display: grid; gap: 1rem; }
.form label { display: grid; gap: .3rem; }
.form fieldset { border: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.form legend { font-weight: 600; margin-bottom: .4rem; }
.form .radio { display: flex; gap: .6rem; align-items: flex-start; }
.form .radio input { margin-top: .3rem; }
.lobby-seats { padding-left: 1.4rem; }
.lobby-seats li { padding: .15rem 0; }
.lobby-seats li button { margin-left: .5rem; }
.bot-mark { color: var(--muted); }

/* ---- Game ---- */

.game { max-width: 1400px; margin: 0 auto; padding: 0 16px 2rem; }

.topbar {
  display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; align-items: baseline;
  padding: .8rem 0; color: var(--muted);
}
.topbar .brand { font-size: 1.2rem; color: var(--ink); }
.topbar .decks { margin-left: auto; font-size: .85rem; }
.topbar .version { font-size: .8rem; border: 1px solid var(--line); border-radius: 6px; padding: 0 .4rem; }

/*
 * The board box's top-right corner holds the prompt card and, under it, the cards
 * played this turn. On narrow screens the prompt sits above the board and the
 * played cards float over the board's top-right corner.
 */
.board-corner {
  position: absolute; top: .6rem; right: .6rem; z-index: 2;
  width: min(310px, 36%);
  display: flex; flex-direction: column; align-items: flex-end; gap: .6rem;
}
.board-corner .promptbar { align-self: stretch; }
.played-stack { display: grid; gap: .5rem; width: min(220px, 100%); }
.played {
  display: grid; gap: .4rem;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .5rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
  animation: played-in .3s ease-out;
}
.played-title { margin: 0; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.played .card { cursor: default; }
.played--leaving { animation: played-out 1s ease forwards; }
@keyframes played-in { from { opacity: 0; transform: translateY(-6px); } }
@keyframes played-out { to { opacity: 0; } }
.promptbar {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: .7rem .85rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
}
.promptbar p { margin: 0; font-weight: 600; }
.promptbar--you { border-color: var(--accent); }
.promptbar .buttons { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .55rem; }
.promptbar .cards--drawn { grid-template-columns: 1fr 1fr; }
.prompt-title { margin: 0 0 .35rem; font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.tally { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; }
.tally-line { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem; align-items: center; font-size: 1rem; line-height: 1.5; }
.tally-line strong { font-variant-numeric: tabular-nums; min-width: 2.5ch; text-align: right; font-size: 1.15rem; }
.tally-line--waiting { opacity: .45; }
.tally-line--counting { font-weight: 700; }
.tally-line--counting strong { color: var(--accent); }
.dot--small { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.score-flight {
  position: fixed; z-index: 30; pointer-events: none;
  font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 4px #fff, 0 0 2px #fff;
}
@media (max-width: 900px) {
  .board-corner { position: relative; top: auto; right: auto; width: auto; margin-bottom: .5rem; }
  .played-stack { position: absolute; top: 100%; right: 0; margin-top: .4rem; width: auto; max-width: 70%; justify-items: end; }
  .played--compact { padding: .3rem .45rem; max-width: 220px; }
  .played-tab { all: unset; cursor: pointer; font-size: .85rem; color: var(--muted); }
  .played-tab strong { color: var(--ink); }
  .played-tab:focus-visible { outline: 3px solid var(--option); outline-offset: 2px; }
  .played .card-text { font-size: .78rem; }
}
.countdown { color: #a93226; }

.notice { background: #fbeee6; border: 1px solid #e6b8a2; border-radius: 8px; padding: .5rem .8rem; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.board-wrap { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; }
/* The board sits most of the way to the left, leaving the top-right corner to the prompt card. */
.board { width: 100%; height: auto; display: block; max-height: calc(100vh - 90px); padding-left: 2%; }
.board .edges line { stroke: #8b6b47; stroke-width: 7; }
.board text { text-anchor: middle; dominant-baseline: central; pointer-events: none; }

.tile .tile-shape { stroke: #8a7f6d; stroke-width: 2; }
.tile--holyCity .tile-shape { fill: var(--holy); }
.tile--judgment .tile-shape { fill: var(--judgment); }
.tile--miracle .tile-shape { fill: var(--miracle); }
.tile--empty .tile-shape { fill: var(--empty); }
.tile--birthSite .tile-shape { fill: var(--birth); }
.tile-label { font-weight: 700; fill: var(--ink); }
.tile--birthSite .tile-label { fill: #fff; }

.tile--option { cursor: pointer; }
.tile--option .tile-shape { stroke: var(--option); stroke-width: 7; animation: pulse 1.4s ease-in-out infinite; }
.tile--option:hover .tile-shape { filter: brightness(1.07); }
.tile--selected .tile-shape { stroke: var(--accent); stroke-width: 9; filter: brightness(1.1); }
.tile--flash .tile-shape { stroke: var(--accent); stroke-width: 9; }
.flash-label { font-weight: 900; paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; }
.tile--highlight .tile-shape { stroke: #2b2620; stroke-width: 7; stroke-dasharray: 14 8; }

.sanctuary-ring { fill: none; stroke-width: 4; stroke-dasharray: 10 6; }
.famine-ring { fill: none; stroke: #7b241c; stroke-width: 3; stroke-dasharray: 2 6; stroke-linecap: round; }

.chip circle { stroke: #fff; stroke-width: 2; }
.chip text { fill: #fff; font-weight: 700; }
.chip--option { cursor: pointer; }
.chip--option circle { stroke: var(--option); stroke-width: 5; animation: pulse 1.4s ease-in-out infinite; }
.chip--flying { pointer-events: none; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .35)); }
/* Clickable outlines pulse like the active prophet's halo, never fading below half strength. */
@keyframes pulse { 50% { stroke-opacity: .45; } }
.chip--option:hover circle { stroke-width: 7; }

.prophet { pointer-events: none; }
.prophet path { stroke: #fff; stroke-width: 3; stroke-linejoin: round; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .55)); }
.prophet text { fill: #fff; font-weight: 800; }

.prophet-glow { fill: var(--option); opacity: .7; stroke: #fff; stroke-width: 3; animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) {
  .prophet-glow, .tile--option .tile-shape, .chip--option circle { animation: none; }
}

/* Bottom-right of the board: the "i" button, and the legend above it when switched on. */
.board-area { position: relative; }
.legend-corner {
  position: absolute; right: .2rem; bottom: .2rem; z-index: 1;
  display: flex; flex-direction: column; align-items: flex-end; gap: .4rem;
}
.info-button {
  width: 2rem; height: 2rem; padding: 0; border-radius: 50%;
  font: italic 700 1.1rem Georgia, serif; line-height: 1;
  background: #fff; color: var(--accent); border: 2px solid var(--accent);
}
.info-button--on { background: var(--accent); color: var(--accent-ink); }
.legend {
  list-style: none; margin: 0; padding: .45rem .65rem;
  display: grid; gap: .2rem;
  background: rgba(255, 255, 255, .92); border: 1px solid var(--line); border-radius: 10px;
  font-size: .8rem; color: var(--muted);
}
.legend li { display: flex; align-items: center; gap: .45rem; }
.legend strong { color: var(--ink); }
.legend .tile-shape { stroke-width: 1.5; }

/* Someone else's card, big in the middle of the board for a moment. */
.reveal {
  position: absolute; left: 50%; top: 50%; z-index: 6;
  width: min(260px, 60%);
  background: #fff; border: 2px solid var(--accent); border-radius: 14px; padding: .6rem;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .3);
  cursor: pointer;
}
.reveal-title { margin: 0 0 .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.reveal .card { cursor: pointer; }
.reveal .card-name { font-size: 1.25rem; }
.reveal .card-text { font-size: .95rem; }

/* A drawn card, face down, on its way to a player. */
.card-flight {
  position: fixed; z-index: 30; pointer-events: none;
  width: 34px; height: 48px; border-radius: 5px;
  background: repeating-linear-gradient(45deg, #8c6a3f 0 6px, #a47e4e 6px 12px);
  border: 2px solid #fff; box-shadow: 0 4px 10px rgba(0, 0, 0, .35);
  display: grid; place-items: center;
}
.card-flight-count { color: #fff; font-weight: 800; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }

/* Phones: the Cards button (bottom-left of the board) and the hand that slides up over the board's bottom edge. */
.cards-button {
  position: absolute; left: .2rem; bottom: .2rem; z-index: 3;
  font-weight: 700; background: #fff; border: 2px solid var(--accent); color: var(--accent);
}
.cards-button--active { background: var(--accent); color: var(--accent-ink); outline: 3px solid var(--option); animation: card-pulse 1.4s ease-in-out infinite; }
.hand-drawer {
  position: relative; z-index: 4; margin-top: -2.8rem;
  background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: .5rem .6rem .6rem;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, .15);
  animation: drawer-up .25s ease-out;
}
.hand-drawer.panel--active { border-color: var(--accent); }
.hand-drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; }
.hand-drawer h2 { margin: 0; }
.hand-drawer .cards { display: flex; overflow-x: auto; gap: .5rem; padding: .2rem .1rem .3rem; }
.hand-drawer .card { flex: 0 0 9.5rem; }
@keyframes drawer-up { from { opacity: 0; transform: translateY(1.5rem); } }
@media (prefers-reduced-motion: reduce) {
  .hand-drawer, .played, .played--leaving { animation: none; }
  .played--leaving { opacity: 0; }
  .cards-button--active { animation: none; }
}

/* Stopwatches: time on this step (prompt card) and on this turn (players panel). */
.phase-clock {
  float: right; margin: 0 0 .2rem .6rem;
  font-size: .85rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--muted); background: var(--bg, #f4efe6); border-radius: 6px; padding: 0 .35rem;
}
.player-name .no-prophet { color: #a93226; }
.turn-clock { font-variant-numeric: tabular-nums; color: var(--ink); margin-left: .25rem; }

/* ---- Side panels ---- */

.players { list-style: none; margin: 0; padding: 0; }
.player {
  display: grid; grid-template-columns: auto 1fr auto; gap: .1rem .6rem; align-items: center;
  padding: .45rem .5rem; border-radius: 8px;
}
.player--active { background: #fbf0dc; }

.player .dot {
  grid-row: span 2; width: 28px; height: 28px; border-radius: 50%;
  color: #fff; font-weight: 800; display: grid; place-items: center;
}
.player-name { font-weight: 600; }
.player-name em { font-weight: 400; color: var(--muted); font-style: normal; }
.player-stats { grid-column: 2; font-size: .85rem; color: var(--muted); }
.player-stats strong { color: var(--ink); }
.player button, .player .small-text { grid-column: 3; grid-row: 1 / span 2; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.cards--drawn { margin-top: .6rem; max-width: 640px; }
.card {
  display: flex; flex-direction: column; gap: .25rem; text-align: left;
  border-radius: 10px; padding: .6rem .7rem; border: 2px solid transparent;
}
.card--miracle { background: #e3f0f8; border-color: #8fbcd8; }
.card--judgment { background: #efe7f6; border-color: #b49fcb; }
.card--divine { background: #fbf1d9; border-color: #d4ad55; }
.card--dim { opacity: .55; }
.card--active { outline: 3px solid var(--option); }
/* Card step: the hand is where the choice is. Playable cards pulse like the board's clickable tiles. */
.panel--active { border-color: var(--accent); border-width: 2px; }
.card--playable { outline: 3px solid var(--option); animation: card-pulse 1.4s ease-in-out infinite; }
@keyframes card-pulse { 50% { outline-color: rgba(255, 159, 28, .45); } }
@media (prefers-reduced-motion: reduce) { .card--playable { animation: none; } }
.card--hidden { background: #e6e0d4; color: var(--muted); padding: .6rem; border-radius: 10px; }
.card-deck { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.card-name { font-size: 1rem; }
.card-text { font-size: .85rem; }
.card-note { font-size: .75rem; color: #a93226; }

.log { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; font-size: .85rem; }
.log--collapsed li { border-bottom: none; }
.log-toggle {
  all: unset; cursor: pointer; display: inline-flex; align-items: baseline; gap: .1rem;
  font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit;
}
.log-toggle:focus-visible { outline: 3px solid var(--option); outline-offset: 2px; }
.log-arrow { display: inline-block; width: 1em; }
.log-count { text-transform: none; letter-spacing: 0; font-size: .85rem; }
.log li { padding: .2rem .3rem; border-bottom: 1px solid #efe9de; border-radius: 4px; cursor: default; }
.log li:hover { background: #f3ead8; }
.log-round { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: .3rem; }

.toasts { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 10; width: min(92vw, 480px); }
.toast { background: #2b2620; color: #fff; padding: .7rem 1rem; border-radius: 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.offline { position: fixed; top: 0; left: 0; right: 0; background: #a93226; color: #fff; text-align: center; padding: .3rem; z-index: 20; }

/* Prompt messages cross-fade: the old one fades out as the new one fades in. */
.xfade { position: relative; }
.xfade-in { animation: fade-in .5s ease both; }
.xfade-out { position: absolute; top: 0; left: 0; right: 0; animation: fade-out .5s ease both; pointer-events: none; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

/* Card step: the hand box scales up from its top-right corner (0.4 s each way). */
.hand-panel { position: relative; z-index: 5; transform-origin: top right; transition: transform .4s ease; box-shadow: 0 0 0 rgba(0, 0, 0, 0); }
.hand-panel.panel--active { box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }

@media (prefers-reduced-motion: reduce) {
  .xfade-in, .xfade-out { animation: none; }
  .xfade-out { display: none; }
  .hand-panel { transition: none; }
}

/* ---- Rules link and the rules page (/rules) ---- */

.footer { margin-top: 1.5rem; }
.side-footer { margin: .5rem 0 0; text-align: center; font-size: .85rem; }
.rules-link { color: var(--muted); }
.rules-link:hover { color: var(--ink); }

.page.rules { max-width: 46rem; line-height: 1.6; }
.rules h1 { font-size: 2.2rem; margin-bottom: .2rem; }
.rules h1 + p { margin-top: 0; color: var(--muted); }
.rules h2 { font-size: 1.3rem; text-transform: none; letter-spacing: 0; color: var(--ink); margin-top: 2.2rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.rules h3 { font-size: 1.05rem; margin: 1.5rem 0 .4rem; }
.rules p, .rules li { max-width: 68ch; }
.rules ul { padding-left: 1.3rem; }
.rules li { margin-bottom: .25rem; }
.rules table { border-collapse: collapse; width: 100%; margin: .8rem 0 1rem; font-size: .92rem; display: block; overflow-x: auto; }
.rules th, .rules td { text-align: left; vertical-align: top; padding: .45rem .6rem; border-bottom: 1px solid var(--line); }
.rules thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.rules-board { margin: 1rem auto; max-width: 30rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; }
.rules-board .board { max-height: none; padding-left: 0; }
.rules-board figcaption { text-align: center; color: var(--muted); font-size: .85rem; margin-top: .3rem; }
