:root {
  --bg: #0a0a18;
  --surface: #141428;
  --surface-light: #1e1e3a;
  --border: #2a2a4a;
  --text: #e0e0f0;
  --text-muted: #8888aa;
  --pink: #FF4D8D;
  --amethyst: #A855F7;
  --periwinkle: #818CF8;
  --warm-orange: #F4A261;
  --warm-pink: #E87461;
  --warm-cream: #FFF3E0;
  --green: #4ade80;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
}

.hidden { display: none !important; }

.play-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ===== Shared layout ===== */

.center-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  gap: 24px;
}

.game-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 20px 32px;
  gap: 16px;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* ===== Cat Loaf ===== */

.catloaf-img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  border-radius: 50%;
  display: block;
}

.catloaf-img.catloaf-sm {
  width: 64px;
  height: 64px;
}

.logo-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.catloaf-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  max-width: 480px;
  padding-top: 8px;
}

/* ===== Quip Bubble ===== */

.quip-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 2px;
  padding: 10px 14px;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.4;
  flex: 1;
  opacity: 0;
  transition: opacity 0.4s ease;
  min-height: 42px;
}

.quip-bubble.quip-show {
  opacity: 1;
}

/* ===== Home / Join / Create screens ===== */

.game-title {
  font-size: 2rem;
  font-weight: 300;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--warm-orange), var(--warm-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 300px;
}

.form-stack input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 14px 18px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  text-align: center;
  font-family: inherit;
}

.form-stack input:focus {
  border-color: var(--warm-orange);
}

.form-stack input::placeholder {
  color: var(--text-muted);
}

#input-room-code {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ===== Buttons ===== */

.btn-primary {
  background: linear-gradient(135deg, var(--warm-orange), var(--warm-pink));
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 14px 24px;
  font-size: 1rem;
  cursor: pointer;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  width: 100%;
}

.btn-primary:hover { opacity: 0.88; }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.4; cursor: default; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 24px;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  width: 100%;
}

.btn-secondary:hover { border-color: var(--warm-orange); }
.btn-secondary:active { transform: scale(0.97); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius);
  padding: 10px 24px;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
}

.btn-ghost:hover { color: var(--text); }

.form-error {
  color: var(--pink);
  font-size: 0.85rem;
  text-align: center;
  min-height: 1.2em;
}

/* ===== Lobby ===== */

.lobby-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 360px;
}

.room-code-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.room-code-display {
  font-size: 2rem;
  font-weight: 700;
  color: var(--warm-orange);
  letter-spacing: 0.12em;
}

.lobby-players {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
}

.player-chip {
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 0.9rem;
}

.lobby-waiting {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

#btn-start {
  max-width: 300px;
}

/* ===== Phase badge ===== */

.phase-badge {
  font-size: 0.75rem;
  color: var(--warm-orange);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: rgba(244, 162, 97, 0.1);
  border: 1px solid rgba(244, 162, 97, 0.3);
  border-radius: 20px;
  padding: 4px 14px;
}

/* ===== Question card ===== */

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  width: 100%;
  max-width: 480px;
  text-align: center;
}

.question-number {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.question-text {
  font-size: 1.2rem;
  line-height: 1.5;
}

/* ===== Write phase ===== */

.write-area {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#write-question-card {
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--text-muted);
  font-style: italic;
  padding: 12px 16px;
  text-align: center;
  max-width: 480px;
  width: 100%;
}

.answer-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 16px;
  font-size: 1rem;
  outline: none;
  resize: none;
  min-height: 80px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.answer-input:focus {
  border-color: var(--warm-orange);
}

/* ===== Truth card ===== */

.truth-card {
  background: rgba(244, 162, 97, 0.07);
  border: 1px solid rgba(244, 162, 97, 0.4);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.truth-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.truth-answer {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--warm-orange);
  line-height: 1.3;
}

.truth-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ===== Timer ===== */

.timer-bar {
  width: 100%;
  max-width: 480px;
  height: 4px;
  background: var(--surface-light);
  border-radius: 2px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--warm-orange), var(--warm-pink));
  border-radius: 2px;
  transition: width 1s linear;
}

.timer-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== Vote phase ===== */

.vote-options {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vote-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 16px 20px;
  font-size: 1rem;
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  transition: border-color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
  min-height: 52px;
  font-family: inherit;
  width: 100%;
}

.vote-btn:hover {
  border-color: var(--warm-orange);
  background: rgba(244, 162, 97, 0.05);
}

.vote-btn:active { transform: scale(0.98); }

.vote-btn.selected {
  border-color: var(--warm-orange);
  background: rgba(244, 162, 97, 0.12);
}

/* ===== Reveal phase ===== */

.reveal-answers {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reveal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reveal-card.is-truth {
  border-color: var(--warm-orange);
  background: rgba(244, 162, 97, 0.06);
}

.reveal-answer-text {
  font-size: 1rem;
  line-height: 1.4;
}

.truth-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--warm-orange);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.reveal-author {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.reveal-voters {
  font-size: 0.8rem;
  color: var(--periwinkle);
}

/* ===== Scoreboard ===== */

.scoreboard {
  width: 100%;
  max-width: 480px;
  margin-top: 8px;
}

.standings-header {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
  text-align: center;
}

.my-points {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--green);
  margin-bottom: 12px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
}

.score-row.is-me {
  background: rgba(244, 162, 97, 0.07);
  border-color: rgba(244, 162, 97, 0.3);
}

.score-rank {
  color: var(--text-muted);
  font-size: 0.9rem;
  width: 20px;
  flex-shrink: 0;
}

.score-name {
  flex: 1;
  font-size: 0.95rem;
}

.score-points {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--warm-cream);
}

.score-delta {
  font-size: 0.8rem;
  color: var(--green);
  font-weight: 600;
  min-width: 32px;
  text-align: right;
}

/* ===== End screen ===== */

.end-winner {
  text-align: center;
  padding: 8px 0;
}

.end-winner-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 4px;
}

.end-winner-name {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--warm-orange), var(--warm-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== Disconnected ===== */

.disconnected-msg {
  color: var(--pink);
  font-size: 1rem;
  text-align: center;
}

/* ===== Desktop tweaks ===== */

@media (min-width: 600px) {
  .catloaf-img {
    width: 112px;
    height: 112px;
  }

  .game-title {
    font-size: 2.4rem;
  }

  .question-text {
    font-size: 1.35rem;
  }

  .vote-btn {
    font-size: 1.05rem;
  }

  .reveal-card {
    padding: 16px 22px;
  }
}
