: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;
  --red: #ef4444;
  --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;
}

/* ===== Mode Toggle ===== */

.mode-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.mode-btn {
  flex: 1;
  background: var(--surface);
  color: var(--text-muted);
  border: none;
  padding: 10px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, color 0.2s;
}

.mode-btn.active {
  background: rgba(244, 162, 97, 0.15);
  color: var(--warm-orange);
}

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

/* ===== 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;
}

/* ===== Round Announce ===== */

.round-announce {
  text-align: center;
  padding: 32px 0;
}

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

.round-label {
  font-size: 2.5rem;
  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;
  margin-bottom: 8px;
}

.round-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ===== Question header ===== */

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 480px;
}

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

.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;
}

/* ===== Multiple Choice Options ===== */

.mc-options {
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mc-btn {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 18px 16px;
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
  line-height: 1.3;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  min-height: 64px;
  font-family: inherit;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mc-btn:nth-child(1) { border-color: #e74c3c44; }
.mc-btn:nth-child(2) { border-color: #3498db44; }
.mc-btn:nth-child(3) { border-color: #2ecc7144; }
.mc-btn:nth-child(4) { border-color: #f39c1244; }

.mc-btn:hover {
  transform: scale(1.02);
}

.mc-btn:nth-child(1):hover { border-color: #e74c3c; background: #e74c3c15; }
.mc-btn:nth-child(2):hover { border-color: #3498db; background: #3498db15; }
.mc-btn:nth-child(3):hover { border-color: #2ecc71; background: #2ecc7115; }
.mc-btn:nth-child(4):hover { border-color: #f39c12; background: #f39c1215; }

.mc-btn:active { transform: scale(0.97); }

.mc-btn.selected {
  opacity: 1;
}

.mc-btn.selected:nth-child(1) { border-color: #e74c3c; background: #e74c3c22; }
.mc-btn.selected:nth-child(2) { border-color: #3498db; background: #3498db22; }
.mc-btn.selected:nth-child(3) { border-color: #2ecc71; background: #2ecc7122; }
.mc-btn.selected:nth-child(4) { border-color: #f39c12; background: #f39c1222; }

.mc-btn.disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

/* ===== Type-In ===== */

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

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

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

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

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

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

.timer-bar-prominent {
  height: 8px;
  border-radius: 4px;
}

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

.timer-fill.urgent {
  background: linear-gradient(90deg, var(--red), var(--pink));
}

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

.timer-text.urgent {
  color: var(--red);
  font-weight: 600;
}

/* ===== Question Result ===== */

.result-feedback {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  padding: 16px 0 8px;
}

.result-feedback.correct {
  color: var(--green);
}

.result-feedback.wrong {
  color: var(--red);
}

.result-feedback.timeout {
  color: var(--text-muted);
}

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

.result-answer-text {
  color: var(--warm-orange);
  font-weight: 600;
}

.result-points {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--green);
  text-align: center;
}

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

/* ===== 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;
}

.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-row.eliminated {
  opacity: 0.4;
  text-decoration: line-through;
}

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

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

.score-name .ai-badge {
  font-size: 0.7rem;
  color: var(--periwinkle);
  margin-left: 4px;
}

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

/* ===== Eliminations ===== */

.eliminations {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.elimination-card {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  animation: slideIn 0.4s ease forwards;
}

.elimination-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 4px;
}

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

.elimination-quip {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ===== Eliminated Banner ===== */

.eliminated-banner {
  text-align: center;
  padding: 24px;
}

.eliminated-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 8px;
}

.eliminated-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ===== Spectate ===== */

.spectate-banner {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 14px;
}

/* ===== 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;
  }

  .mc-btn {
    font-size: 1.05rem;
    padding: 22px 18px;
  }

  .typein-input {
    font-size: 1.2rem;
  }
}

/* ===== Animations ===== */

@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
