/* Shared styles for all pages. Mobile-first; the host screen scales things up. */
:root {
  --bg: #14110f;
  --panel: #221d1a;
  --panel-2: #2d2622;
  --text: #f3ede6;
  --muted: #a89d92;
  --accent: #e8a33d;
  --accent-text: #1c1408;
  --danger: #d9534f;
  --ok: #5cb85c;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

h1, h2, h3 { margin: 0 0 12px; line-height: 1.15; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.hidden, [hidden] { display: none !important; }

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

/* Buttons and inputs: big touch targets */
button, .button {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 14px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.secondary, .button.secondary { background: var(--panel-2); color: var(--text); }
button.small { display: inline-block; width: auto; min-height: 40px; padding: 8px 14px; font-size: 0.95rem; }
.stack > * + * { margin-top: 12px; }

input, select, textarea {
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  border: 2px solid var(--panel-2);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 1.3rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { font-size: 1rem; resize: vertical; }
input.code-input { text-transform: uppercase; letter-spacing: 0.4em; text-align: center; font-weight: 700; }

/* Toggle switch: <label class="switch"><input type="checkbox"> Text</label> */
.switch { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; }
.switch input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 56px;
  height: 32px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--panel-2);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.switch input::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.2s;
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(24px); background: var(--accent-text); }

/* Two buttons acting as one choice */
.segmented { display: flex; gap: 8px; flex-wrap: wrap; }
.segmented button.active { background: var(--accent); color: var(--accent-text); }

.small-text { font-size: 0.9rem; margin-top: 4px; }
.muted-on-accent { opacity: 0.6; font-weight: 400; }
.district-group + .district-group { margin-top: 14px; }
.district-group h3 { font-size: 1rem; color: var(--muted); margin-bottom: 6px; }

.error { color: var(--danger); min-height: 1.4em; margin-top: 8px; }

/* Choice buttons on the player screen */
.choices { display: grid; gap: 12px; }
.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 80px;
  text-align: left;
  background: var(--panel-2);
  color: var(--text);
  border: 3px solid transparent;
}
.choice .emoji { font-size: 2rem; }
.choice .hint { display: block; font-size: 0.9rem; font-weight: 400; color: var(--muted); }
.choice.selected { border-color: var(--accent); background: #3a2e20; }

/* Lists of names */
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.chips li { background: var(--panel-2); padding: 8px 14px; border-radius: 999px; }
.chips li.offline { opacity: 0.45; }
.chips li.dead { text-decoration: line-through; opacity: 0.5; }

/* Story events */
.events { list-style: none; padding: 0; margin: 0; }
.events li { background: var(--panel); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.events li.deadly { border-left: 5px solid var(--danger); }
.events li.pop { animation: pop 0.5s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }

.big-code { font-size: 4rem; font-weight: 800; letter-spacing: 0.15em; color: var(--accent); }
.countdown { font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.headline { font-size: 1.6rem; font-weight: 800; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--panel-2); }
th { color: var(--muted); font-weight: 600; }

/* Host screen is meant for a big display: scale everything up */
body.host main { max-width: 1100px; }
body.host { font-size: 1.25rem; }
body.host .big-code { font-size: 8rem; }
body.host .countdown { font-size: 7rem; }
body.host .events li { font-size: 1.5rem; padding: 18px 22px; }
body.host .row { display: flex; gap: 12px; flex-wrap: wrap; }
body.host .row > * { flex: 1; }

/* --- "The Fallen" night-sky recap (public/fallen.js) ----------------------- */
.fallen-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 120%, #1d2b4a 0%, #0b1020 55%, #04060d 100%);
  opacity: 0;
  transition: opacity 600ms ease;
  overflow: hidden;
}
.fallen-overlay.open { opacity: 1; }
.fallen-overlay.closing { opacity: 0; }

.fallen-stars span {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fff;
  animation: twinkle 4s ease-in-out infinite;
}
.fallen-stars span.big { width: 3px; height: 3px; box-shadow: 0 0 6px #fff; }
@keyframes twinkle { 50% { opacity: 0.15; } }

.fallen-stage { position: relative; text-align: center; padding: 16px; }
.fallen-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation-name: fallenCard;
  animation-timing-function: ease;
  animation-fill-mode: both;
}
/* Fade in from a blur, hold, then drift up and fade out (duration set from JS) */
@keyframes fallenCard {
  0%   { opacity: 0; transform: scale(0.94); filter: blur(10px); }
  18%  { opacity: 1; transform: none; filter: blur(0); }
  82%  { opacity: 1; transform: none; filter: blur(0); }
  100% { opacity: 0; transform: translateY(-24px); filter: blur(6px); }
}

.fallen-heading { font-size: clamp(2.5rem, 8vw, 6rem); letter-spacing: 0.12em; text-transform: uppercase; color: #e9eefc; margin: 0; }
.fallen-subtitle { font-size: clamp(1.2rem, 3vw, 2rem); color: #9fb0d8; letter-spacing: 0.08em; margin: 0; }
.fallen-portrait {
  width: clamp(140px, 22vw, 240px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: clamp(3rem, 7vw, 5.5rem);
  font-weight: 800;
  color: #fff;
  background: radial-gradient(circle at 35% 30%, hsl(var(--hue) 45% 55%), hsl(var(--hue) 50% 22%));
  box-shadow: 0 0 60px hsl(var(--hue) 70% 60% / 0.45), inset 0 0 30px rgba(0, 0, 0, 0.4);
  filter: grayscale(0.35);
}
.fallen-name { font-size: clamp(2rem, 6vw, 4.5rem); font-weight: 800; color: #f4f6ff; text-shadow: 0 0 24px rgba(160, 190, 255, 0.5); }
.fallen-district { font-size: clamp(1.1rem, 3vw, 2rem); color: #9fb0d8; letter-spacing: 0.15em; text-transform: uppercase; }
.fallen-skip { position: absolute; right: 24px; bottom: 24px; opacity: 0.6; }
.fallen-skip:hover { opacity: 1; }
