:root {
  --bg: #0a0a18;
  --surface: #141428;
  --surface-light: #1e1e3a;
  --border: #2a2a4a;
  --text: #e0e0f0;
  --text-muted: #8888aa;
  --pink: #EC4899;
  --pink-light: #F472B6;
  --amethyst: #A855F7;
  --periwinkle: #818CF8;
  --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(--pink), var(--amethyst));
  -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(--pink);
}

.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(236, 72, 153, 0.15);
  color: var(--pink);
}

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

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

.btn-primary {
  background: linear-gradient(135deg, var(--pink), var(--amethyst));
  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(--pink); }
.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(--pink);
  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(--pink), var(--amethyst));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

/* ===== 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(--pink);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: rgba(236, 72, 153, 0.1);
  border: 1px solid rgba(236, 72, 153, 0.3);
  border-radius: 20px;
  padding: 3px 10px;
}

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

/* ===== Modifier Badge ===== */

.modifier-badge {
  display: inline-block;
  font-size: 0.85rem;
  background: rgba(250, 204, 21, 0.15);
  border: 1px solid rgba(250, 204, 21, 0.4);
  color: #FACC15;
  border-radius: 20px;
  padding: 6px 16px;
  margin-top: 8px;
  letter-spacing: 0.05em;
}

.modifier-badge-sm {
  display: inline-block;
  font-size: 0.7rem;
  background: rgba(250, 204, 21, 0.15);
  border: 1px solid rgba(250, 204, 21, 0.4);
  color: #FACC15;
  border-radius: 20px;
  padding: 3px 10px;
  letter-spacing: 0.05em;
}

/* ===== Prompt card ===== */

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

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

/* ===== Write Area ===== */

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

.write-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;
  resize: none;
}

.write-input:focus {
  border-color: var(--pink);
}

.write-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(--pink), var(--amethyst));
  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;
}

/* ===== Waiting ===== */

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

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

.vote-header {
  width: 100%;
  max-width: 480px;
  text-align: center;
}

.vote-instruction {
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

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

.vote-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 16px 20px;
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
  line-height: 1.4;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

.vote-card:hover {
  border-color: var(--pink-light);
  background: rgba(236, 72, 153, 0.05);
  transform: scale(1.01);
}

.vote-card:active {
  transform: scale(0.97);
}

.vote-card.selected {
  border-color: var(--pink);
  background: rgba(236, 72, 153, 0.12);
}

.vote-card.disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

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

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

.reveal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  animation: slideIn 0.4s ease forwards;
}

.reveal-card.winner {
  border-color: var(--pink);
  border-width: 2px;
}

.reveal-answer-text {
  font-size: 1.1rem;
  line-height: 1.4;
  margin-bottom: 8px;
}

.reveal-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.reveal-author {
  color: var(--text-muted);
}

.reveal-votes {
  color: var(--pink-light);
}

.reveal-points {
  color: var(--green);
  font-weight: 600;
}

/* ===== 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(236, 72, 153, 0.07);
  border-color: rgba(236, 72, 153, 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-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);
}

/* ===== 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(--pink), var(--amethyst));
  -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;
  }

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

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

  .vote-card {
    font-size: 1.05rem;
    padding: 20px 24px;
  }
}

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

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