/* Quips — shared look for the phone, host and TV pages */
:root {
  --bg: #1a1026;
  --bg-2: #241634;
  --surface: #2d1d42;
  --surface-2: #3a2655;
  --line: #4b3369;
  --ink: #fff8f0;
  --muted: #bba9d1;
  --pink: #ff4f8b;
  --orange: #ff8a3d;
  --yellow: #ffd23f;
  --teal: #2fe0c0;
  --red: #ff5a5a;
  --green: #4ade80;
  --radius: 20px;
  --radius-sm: 12px;
  --display: "Fredoka", "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #4a1d5e 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #5a2340 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }

.hidden { display: none !important; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.app {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 0 16px 40px;
  display: grid;
  gap: 16px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 -16px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

.logo {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(90deg, var(--yellow), var(--orange) 45%, var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo-tag {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 3px 8px;
}
.topbar .spacer { flex: 1; }
.topbar a {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
}
.topbar a:hover { color: var(--ink); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--surface-2);
  color: var(--ink);
  white-space: nowrap;
}
.pill.phase-collecting { background: color-mix(in srgb, var(--orange) 25%, var(--surface)); color: var(--yellow); }
.pill.phase-voting { background: color-mix(in srgb, var(--teal) 22%, var(--surface)); color: var(--teal); }
.pill.phase-results, .pill.phase-display { background: color-mix(in srgb, var(--pink) 25%, var(--surface)); color: #ffc2d6; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  gap: 12px;
  min-width: 0;
}
.card > h2 { font-size: 1.25rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.eyebrow {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* The big centered "what's happening" panel */
.hero {
  text-align: center;
  padding: 28px 20px;
  gap: 10px;
  justify-items: center;
}
.hero-emoji { font-size: 3.2rem; line-height: 1; }
.hero h2 { font-size: 1.7rem; }
.hero .muted { max-width: 34ch; }

/* A question, styled as a speech bubble */
.prompt {
  position: relative;
  font-family: var(--display);
  font-size: clamp(1.3rem, 5vw, 1.75rem);
  font-weight: 600;
  line-height: 1.25;
  color: #241634;
  background: var(--yellow);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 8px;
  box-shadow: 0 6px 0 #c99a10;
}
.prompt::after {
  content: "";
  position: absolute;
  left: 28px;
  bottom: -14px;
  border: 10px solid transparent;
  border-top: 14px solid var(--yellow);
  border-bottom: 0;
}
.prompt.small {
  font-size: 1.1rem;
  padding: 14px 16px;
  box-shadow: 0 4px 0 #c99a10;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */
label { display: block; font-weight: 700; font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }

input, select, textarea, button { font: inherit; }

input, select, textarea {
  width: 100%;
  min-height: 48px;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 16px;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--pink); }
textarea { min-height: 120px; resize: vertical; line-height: 1.4; }
input::placeholder, textarea::placeholder { color: #8e7aa8; }
input:disabled, textarea:disabled { opacity: .5; }

.field { min-width: 0; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.char-count { font-size: 0.8rem; color: var(--muted); text-align: right; margin-top: 4px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
button {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #ff6b9d, var(--pink));
  box-shadow: 0 5px 0 #b81e55;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
button:hover:not(:disabled) { filter: brightness(1.06); }
button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 #b81e55; }
button:disabled { opacity: .4; cursor: default; }

button.secondary {
  background: var(--surface-2);
  box-shadow: 0 5px 0 #1c1029;
  color: var(--ink);
}
button.secondary:active:not(:disabled) { box-shadow: 0 2px 0 #1c1029; }
button.teal { background: linear-gradient(180deg, #5cf0d4, var(--teal)); color: #10261f; box-shadow: 0 5px 0 #13917a; }
button.teal:active:not(:disabled) { box-shadow: 0 2px 0 #13917a; }
button.danger { background: transparent; box-shadow: none; color: var(--red); border: 2px solid color-mix(in srgb, var(--red) 55%, transparent); }
button.danger:active:not(:disabled) { transform: none; }
button.small { min-height: 42px; font-size: 0.95rem; padding: 8px 14px; box-shadow: 0 3px 0 #1c1029; }
button.danger.small { box-shadow: none; }
button.link {
  width: auto;
  min-height: 0;
  padding: 4px 8px;
  background: none;
  box-shadow: none;
  font-family: var(--body);
  font-size: 0.85rem;
  color: var(--teal);
  text-decoration: underline;
}
button.link:active:not(:disabled) { transform: none; }

.btn-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }

/* ── Chips (player names) ───────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  width: auto;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 99px;
  font-family: var(--body);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface-2);
  border: 2px solid var(--line);
  box-shadow: none;
}
.chip:active:not(:disabled) { transform: scale(.97); box-shadow: none; }
.chip.selected { background: var(--pink); border-color: #ff9cbf; color: #fff; }
.chip.done { background: transparent; border-color: color-mix(in srgb, var(--green) 50%, transparent); color: var(--green); opacity: 1; }

/* Status dots for who's still writing/voting */
.status-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--bg-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.status-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); animation: pulse 1.4s infinite; }
.status-chip.done { color: var(--ink); }
.status-chip.done::before { background: var(--green); animation: none; }
@keyframes pulse { 50% { opacity: .35; } }

/* ── Progress ───────────────────────────────────────────────────────────── */
.progress { display: grid; gap: 6px; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.progress-track { height: 10px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--orange), var(--pink)); transition: width .4s ease; }
.progress.voting .progress-fill { background: linear-gradient(90deg, var(--teal), #7ce8ff); }

/* ── Voting ─────────────────────────────────────────────────────────────── */
.options { display: grid; gap: 18px; }
.option { display: grid; gap: 10px; min-width: 0; }
.option.locked { opacity: .55; }
.option.locked .prompt { box-shadow: none; }
.vote-btn {
  min-height: 60px;
  text-align: left;
  font-family: var(--body);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
  background: var(--surface-2);
  border: 2px solid var(--line);
  box-shadow: 0 4px 0 #1c1029;
  padding: 14px 16px;
}
.vote-btn:hover:not(:disabled) { border-color: var(--teal); }
.vote-btn:active:not(:disabled) { box-shadow: 0 1px 0 #1c1029; }
.vote-btn.picked { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 18%, var(--surface-2)); opacity: 1; }
.locked-note { font-size: 0.9rem; font-weight: 700; color: var(--teal); }

/* ── Results & scores ───────────────────────────────────────────────────── */
.results { display: grid; gap: 16px; }
.result { display: grid; gap: 10px; min-width: 0; }
.answer {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 2px solid var(--line);
  overflow: hidden;
}
.answer.top { border-color: var(--yellow); }
.answer-text { position: relative; font-size: 1.05rem; font-weight: 600; line-height: 1.35; }
.answer-meta { position: relative; display: flex; justify-content: space-between; gap: 10px; font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.answer-meta .author { color: var(--teal); }
.answer-bar { position: absolute; inset: 0 auto 0 0; width: 0; background: color-mix(in srgb, var(--pink) 16%, transparent); transition: width .8s ease; }
.answer.top .answer-bar { background: color-mix(in srgb, var(--yellow) 18%, transparent); }
.crown { margin-right: 4px; }

.scoreboard { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.scoreboard li {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  min-width: 0;
}
.scoreboard .rank { font-family: var(--display); font-weight: 700; color: var(--muted); }
.scoreboard .name { font-weight: 700; min-width: 0; }
.scoreboard .score { font-family: var(--display); font-weight: 700; font-size: 1.1rem; color: var(--yellow); }
.scoreboard li:first-child .rank { color: var(--yellow); }
.score-track { grid-column: 2 / 4; height: 6px; border-radius: 99px; background: var(--surface); overflow: hidden; }
.score-fill { height: 100%; background: linear-gradient(90deg, var(--orange), var(--pink)); border-radius: 99px; transition: width .6s ease; }

.winner-banner {
  text-align: center;
  padding: 22px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--yellow), var(--orange) 55%, var(--pink));
  color: #241634;
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 700;
}
.winner-banner:empty { display: none; }

/* ── Small text ─────────────────────────────────────────────────────────── */
.muted { color: var(--muted); }
.info { font-size: 0.92rem; color: var(--muted); }
.info:empty { display: none; }
.info.all-done {
  text-align: center;
  font-size: 1.05rem;
  color: var(--ink);
  padding: 22px 12px 8px;
}
.info.all-done::before { content: "✅"; display: block; font-size: 2.6rem; margin-bottom: 8px; }
.error {
  position: sticky;
  bottom: 12px;
  color: #fff;
  background: var(--red);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 700;
}
.error:empty { display: none; }

/* Long names and unbroken answers must not widen the page */
.chip, .option, .result, .answer, .scoreboard li, .prompt, .vote-btn, .status-chip, .name { overflow-wrap: anywhere; }

/* Name inputs on host setup */
.name-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.name-row { display: grid; gap: 4px; min-width: 0; }
.name-row label { margin: 0; font-size: 0.75rem; }

details.drawer > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}
details.drawer > summary::-webkit-details-marker { display: none; }
details.drawer > summary::after { content: "▾"; color: var(--muted); transition: transform .2s; }
details.drawer[open] > summary::after { transform: rotate(180deg); }
details.drawer[open] > summary { margin-bottom: 12px; }

/* Entry animation for each phase panel */
.enter { animation: enter .35s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

/* Narrow phones: the round number is in the cards, keep the header on one line */
@media (max-width: 420px) {
  .compact-pills .pill:not([class*="phase-"]) { display: none; }
  .topbar { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── TV display ─────────────────────────────────────────────────────────── */
.tv { width: min(1600px, 100%); padding: 0 32px 40px; gap: 24px; }
.tv .topbar { margin: 0 -32px; padding: 18px 32px; }
.tv .logo { font-size: 2.4rem; }
.tv .pill { font-size: 1rem; padding: 7px 14px; }
.tv-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.tv-hero { text-align: center; padding: 60px 30px; gap: 18px; justify-items: center; }
.tv-hero .hero-emoji { font-size: 5rem; }
.tv-hero h2 { font-size: clamp(2.2rem, 4vw, 3.4rem); }
.tv-hero .muted { font-size: 1.3rem; }
.tv-hero .status-chips { justify-content: center; }
.tv-hero .status-chip { font-size: 1.05rem; padding: 8px 14px; }
.tv-hero .progress { width: min(560px, 100%); }
.tv .results { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 24px; }
.tv .result { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.tv .prompt { font-size: 1.5rem; }
.tv .answer-text { font-size: 1.2rem; }
.tv .winner-banner { font-size: 2.6rem; padding: 30px; }
.tv .join-hint { font-size: 1.1rem; }
.tv .join-hint strong { color: var(--yellow); }

@media (max-width: 900px) {
  .tv { padding: 0 16px 32px; }
  .tv .topbar { margin: 0 -16px; padding: 12px 16px; flex-wrap: wrap; }
  .tv .join-hint { flex-basis: 100%; overflow-wrap: anywhere; }
  .tv .topbar .spacer { display: none; }
  .tv-grid { grid-template-columns: 1fr; }
  .tv .results { grid-template-columns: 1fr; }
}
