/* ===========================
   Would You Rather — style.css
   V2: Clean, light/dark, themed
   =========================== */

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

:root {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --option-a: #f97316;
  --option-a-light: #fed7aa;
  --option-b: #06b6d4;
  --option-b-light: #a5f3fc;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --success: #22c55e;
  --timer-warn: #eab308;
  --timer-danger: #ef4444;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);
  --transition: 0.25s ease;
}

/* ===== THEME COLORS ===== */
[data-color-theme="ocean"] {
  --primary: #0284c7;
  --primary-light: #38bdf8;
  --primary-dark: #0369a1;
}
[data-color-theme="sunset"] {
  --primary: #ea580c;
  --primary-light: #fb923c;
  --primary-dark: #c2410c;
}
[data-color-theme="forest"] {
  --primary: #16a34a;
  --primary-light: #4ade80;
  --primary-dark: #15803d;
}
[data-color-theme="candy"] {
  --primary: #db2777;
  --primary-light: #f472b6;
  --primary-dark: #be185d;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-light: #64748b;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .option-btn.option-a:hover:not(:disabled) {
  background: rgba(249, 115, 22, 0.1);
}
[data-theme="dark"] .option-btn.option-b:hover:not(:disabled) {
  background: rgba(6, 182, 212, 0.1);
}
[data-theme="dark"] .option-btn.selected.option-a {
  background: rgba(249, 115, 22, 0.15);
}
[data-theme="dark"] .option-btn.selected.option-b {
  background: rgba(6, 182, 212, 0.15);
}
[data-theme="dark"] .btn-ghost:hover {
  background: #334155;
}
[data-theme="dark"] .btn-secondary:hover {
  background: rgba(79, 70, 229, 0.2);
}
[data-theme="dark"] .status-msg.info {
  background: rgba(99, 102, 241, 0.2);
  color: var(--primary-light);
}
[data-theme="dark"] .status-msg.success {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}
[data-theme="dark"] .status-msg.error {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}
[data-theme="dark"] .status-msg.warning {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
}
[data-theme="dark"] .room-code-display {
  background: #0f172a;
}
[data-theme="dark"] .vs-badge {
  background: var(--surface);
}
[data-theme="dark"] .timer-option-label {
  background: #0f172a;
  border-color: #334155;
}
[data-theme="dark"] .timer-option input:checked + .timer-option-label {
  background: rgba(79, 70, 229, 0.2);
}
[data-theme="dark"] .category-chip {
  background: #0f172a;
}
[data-theme="dark"] .category-chip input:checked + .category-chip-label {
  background: rgba(79, 70, 229, 0.2);
  border-color: var(--primary);
}
[data-theme="dark"] .achievement-card.locked {
  background: #0f172a;
}
[data-theme="dark"] .stat-card {
  background: #0f172a;
  border-color: #334155;
}
[data-theme="dark"] .history-item {
  background: #0f172a;
  border-color: #334155;
}
[data-theme="dark"] .history-panel {
  background: var(--surface);
}
[data-theme="dark"] #toast {
  background: #f1f5f9;
  color: #0f172a;
}
[data-theme="dark"] .btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background var(--transition), color var(--transition);
}

/* ---- APP WRAPPER ---- */
#app {
  width: 100%;
  max-width: 680px;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* ---- HEADER ---- */
header {
  width: 100%;
  padding: 20px 0 16px;
  text-align: center;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.logo-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.logo-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 400;
  text-align: center;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), transform var(--transition);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.icon-btn:hover {
  background: var(--border);
  transform: scale(1.1);
}

.icon-btn:active {
  transform: scale(0.95);
}

/* ---- SCREENS ---- */
.screen {
  width: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: flex;
}

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

/* ---- CARD ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  width: 100%;
  border: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}

/* ---- HOME SCREEN ---- */
.home-hero {
  text-align: center;
  padding: 16px 0 8px;
}

.home-hero h1 {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 10px;
}

.home-hero .highlight {
  color: var(--primary);
}

.home-hero p {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.5;
}

.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.home-secondary-btns {
  display: flex;
  gap: 10px;
}

.home-secondary-btns .btn {
  flex: 1;
}

.btn-home-sec {
  width: 100%;
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-secondary:hover {
  background: #ede9fe;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

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

.btn-timed {
  background: linear-gradient(135deg, #f97316, #ef4444);
  color: #fff;
  border-color: #f97316;
}

.btn-timed:hover {
  background: linear-gradient(135deg, #ea580c, #dc2626);
  border-color: #ea580c;
}

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

.btn-danger:hover {
  background: #fecaca;
}

.btn-lg {
  padding: 18px 28px;
  font-size: 1.1rem;
  border-radius: var(--radius);
  width: 100%;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
}

.btn-icon {
  font-size: 1.2em;
}

/* ---- RIPPLE EFFECT ---- */
.ripple::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.35) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.ripple:active::after {
  opacity: 1;
}

/* ---- CATEGORY PICKER ---- */
.screen-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.screen-subtitle {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.category-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.category-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-chip {
  position: relative;
}

.category-chip input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.category-chip-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 99px;
  border: 2px solid var(--border);
  background: var(--bg);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.category-chip-label:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}

.category-chip input:checked + .category-chip-label {
  background: #ede9fe;
  border-color: var(--primary);
  color: var(--primary);
}

/* ---- TIMED MODE SETUP ---- */
.timer-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.timer-option {
  position: relative;
  cursor: pointer;
}

.timer-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.timer-option-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 14px 10px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg);
  transition: all var(--transition);
  cursor: pointer;
}

.timer-option-label:hover {
  border-color: var(--primary-light);
}

.timer-option input:checked + .timer-option-label {
  border-color: var(--primary);
  background: #ede9fe;
  color: var(--primary);
}

.timer-option-num {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text-primary);
}

.timer-option input:checked + .timer-option-label .timer-option-num {
  color: var(--primary);
}

.timer-option-desc {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---- SOLO GAME HEADER ---- */
.solo-game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.solo-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- CATEGORY BADGE ---- */
.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: #ede9fe;
  color: var(--primary);
  margin-bottom: 10px;
  border: 1px solid var(--primary-light);
  min-height: 22px;
}

/* ---- CIRCULAR TIMER ---- */
.timer-container {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 60px;
  height: 60px;
  margin: 0 auto 12px;
}

.timer-svg {
  width: 60px;
  height: 60px;
  transform: rotate(-90deg);
}

.timer-bg-circle {
  fill: none;
  stroke: var(--border);
  stroke-width: 5;
}

.timer-progress-circle {
  fill: none;
  stroke: var(--success);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 163.36; /* 2 * π * r = 2 * π * 26 ≈ 163.36 (rounded to 2dp) */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.9s linear, stroke 0.3s ease;
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.timer-container.timer-warning .timer-svg {
  animation: timerPulse 0.5s infinite;
}

@keyframes timerPulse {
  0%, 100% { transform: rotate(-90deg) scale(1); }
  50% { transform: rotate(-90deg) scale(1.05); }
}

/* ---- QUESTION CARD ---- */
.solo-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.question-number {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  font-weight: 600;
  margin-bottom: 8px;
}

.question-label {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  margin-bottom: 18px;
  letter-spacing: 0.5px;
  width: 100%;
}

.vs-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  width: 100%;
}

.vs-divider::before,
.vs-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.vs-badge {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-light);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: orPulse 3s ease-in-out infinite;
}

@keyframes orPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
  50% { box-shadow: 0 0 0 5px rgba(79, 70, 229, 0.08); }
}

/* ---- OPTION BUTTONS ---- */
.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.option-btn {
  width: 100%;
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.option-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.option-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.option-btn.option-a {
  border-color: var(--option-a-light);
}

.option-btn.option-a:hover:not(:disabled) {
  border-color: var(--option-a);
  background: #fff7ed;
}

.option-btn.option-b {
  border-color: var(--option-b-light);
}

.option-btn.option-b:hover:not(:disabled) {
  border-color: var(--option-b);
  background: #ecfeff;
}

.option-btn:disabled {
  cursor: default;
}

.option-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.9rem;
  flex-shrink: 0;
  margin-top: 1px;
  transition: background var(--transition);
}

.option-a .option-letter {
  background: var(--option-a-light);
  color: var(--option-a);
}

.option-b .option-letter {
  background: var(--option-b-light);
  color: var(--option-b);
}

.option-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  flex: 1;
}

/* ---- SELECTED STATE ---- */
.option-btn.selected.option-a {
  border-color: var(--option-a);
  background: #fff7ed;
}

.option-btn.selected.option-a .option-letter {
  background: var(--option-a);
  color: #fff;
}

.option-btn.selected.option-b {
  border-color: var(--option-b);
  background: #ecfeff;
}

.option-btn.selected.option-b .option-letter {
  background: var(--option-b);
  color: #fff;
}

/* ---- RESULTS ---- */
.results-container {
  margin-top: 12px;
  display: none;
  flex-direction: column;
  gap: 12px;
  animation: slideUp 0.35s ease;
  width: 100%;
}

.results-container.visible {
  display: flex;
}

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

.result-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.result-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.result-opt-letter {
  width: 22px;
  height: 22px;
  font-size: 0.7rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
}

.opt-a-letter {
  background: var(--option-a-light);
  color: var(--option-a);
}

.opt-b-letter {
  background: var(--option-b-light);
  color: var(--option-b);
}

.result-pct {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
}

.result-bar-bg {
  width: 100%;
  height: 10px;
  border-radius: 99px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.result-bar {
  height: 100%;
  border-radius: 99px;
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}

.result-bar.bar-a {
  background: var(--option-a);
}

.result-bar.bar-b {
  background: var(--option-b);
}

.result-votes {
  font-size: 0.78rem;
  color: var(--text-light);
}

.result-total {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ---- GAME ACTIONS ---- */
.game-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  flex-wrap: wrap;
}

.game-actions .btn {
  flex: 1;
  min-width: 120px;
}

/* ---- MULTIPLAYER ---- */
.mp-setup {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.mp-setup h2 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
}

.mp-setup p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.mp-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.room-code-display {
  background: var(--bg);
  border: 2px dashed var(--primary-light);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.room-code-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 600;
}

.room-code-value {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: 6px;
  font-family: 'Courier New', monospace;
  line-height: 1;
}

.room-code-hint {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 10px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--transition);
  outline: none;
  font-family: inherit;
}

.input-field:focus {
  border-color: var(--primary);
}

.input-field.code-input {
  text-transform: uppercase;
  letter-spacing: 4px;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  text-align: center;
}

/* ---- PLAYER COUNT ---- */
.player-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.player-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 10px;
  flex-wrap: wrap;
}

.game-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- WAITING ROOM ---- */
.waiting-room {
  text-align: center;
}

.waiting-room h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.waiting-room p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.waiting-animation {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 16px 0;
}

.waiting-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary-light);
  animation: bounce 1.2s infinite ease-in-out;
}

.waiting-dot:nth-child(2) { animation-delay: 0.2s; }
.waiting-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.2); opacity: 1; }
}

/* ---- PLAYER LIST ---- */
.player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
  justify-content: center;
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

.player-chip .avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
}

/* ---- STATUS MESSAGE ---- */
.status-msg {
  text-align: center;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
}

.status-msg.info {
  background: #ede9fe;
  color: var(--primary-dark);
}

.status-msg.success {
  background: #dcfce7;
  color: #15803d;
}

.status-msg.error {
  background: #fee2e2;
  color: #dc2626;
}

.status-msg.warning {
  background: #fef9c3;
  color: #854d0e;
}

/* ---- VOTE STATUS (multiplayer) ---- */
.vote-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 8px 0;
}

.vote-icons {
  display: flex;
  gap: 4px;
}

.vote-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  transition: all var(--transition);
}

.vote-icon.voted {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

/* ---- BACK BUTTON ---- */
.back-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 0;
  transition: color var(--transition);
}

.back-btn:hover {
  color: var(--primary);
}

/* ---- DIVIDER ---- */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  color: var(--text-light);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---- TOAST ---- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  text-align: center;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- STATS SCREEN ---- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  transition: background var(--transition), border-color var(--transition);
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1.1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.ab-split {
  margin-bottom: 20px;
}

.ab-bar-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ab-bar-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 40px;
  white-space: nowrap;
}

.ab-bar-bg {
  flex: 1;
  height: 14px;
  border-radius: 99px;
  overflow: hidden;
  display: flex;
  border: 1px solid var(--border);
}

.ab-bar-fill {
  height: 100%;
  transition: width 0.7s ease;
}

.ab-counts {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 6px;
}

.fav-time {
  margin-bottom: 14px;
}

.fav-time-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.share-stats-row {
  text-align: center;
}

/* ---- ACHIEVEMENTS ---- */
.achievements-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.achievement-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  transition: all var(--transition);
}

.achievement-card.unlocked {
  border-color: var(--primary-light);
  background: #ede9fe;
}

[data-theme="dark"] .achievement-card.unlocked {
  background: rgba(79, 70, 229, 0.15);
  border-color: var(--primary);
}

.achievement-card.locked {
  opacity: 0.5;
  filter: grayscale(0.7);
  background: var(--bg);
}

.achievement-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.achievement-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
}

.achievement-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* ---- ACHIEVEMENT TOAST ---- */
.achievement-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  transform: translateX(120%);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10000;
  max-width: 300px;
}

.achievement-toast.show {
  transform: translateX(0);
}

.achievement-toast-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.achievement-toast-text {
  display: flex;
  flex-direction: column;
}

.achievement-toast-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
}

.achievement-toast-name {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-primary);
}

.achievement-toast-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ---- SETTINGS SCREEN ---- */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 20px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-item-themes {
  flex-wrap: wrap;
  gap: 8px;
}

.settings-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.settings-item-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.settings-item-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 99px;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Theme Swatches */
.theme-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
}

.swatch:hover {
  transform: scale(1.15);
}

.swatch.active {
  border-color: var(--text-primary);
}

.swatch-default { background: #4f46e5; }
.swatch-ocean   { background: #0284c7; }
.swatch-sunset  { background: #ea580c; }
.swatch-forest  { background: #16a34a; }
.swatch-candy   { background: #db2777; }

.settings-danger-zone {
  margin: 8px 0 16px;
}

.settings-about {
  text-align: center;
  color: var(--text-light);
  font-size: 0.8rem;
  line-height: 1.7;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ---- SESSION SUMMARY ---- */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---- HISTORY PANEL ---- */
.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(360px, 100vw);
  height: 100vh;
  background: var(--surface);
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-panel.open {
  transform: translateX(0);
}

.history-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.history-panel-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.history-list {
  overflow-y: auto;
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.82rem;
  transition: background var(--transition), border-color var(--transition);
}

.history-item-choice {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 99px;
  margin-bottom: 4px;
}

.history-item-choice.choice-a {
  background: var(--option-a-light);
  color: var(--option-a);
}

.history-item-choice.choice-b {
  background: var(--option-b-light);
  color: var(--option-b);
}

.history-item-q {
  color: var(--text-secondary);
  line-height: 1.4;
}

.history-item-q strong {
  color: var(--text-primary);
}

.history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.history-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* ---- CONFETTI CANVAS ---- */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9998;
  display: none;
}

/* ===== XP / LEVEL BAR ===== */
.xp-bar-container {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.xp-level-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  min-width: 48px;
}

.xp-level-num {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
}

.xp-level-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
}

.xp-bar-info {
  flex: 1;
}

.xp-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.xp-bar-bg {
  width: 100%;
  height: 8px;
  border-radius: 99px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== SESSION PROGRESS BAR ===== */
.session-progress-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0 2px;
}

.session-progress-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-light);
  white-space: nowrap;
  flex-shrink: 0;
}

.session-progress-bg {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
}

.session-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.4s ease;
  width: 0%;
}

/* ===== DAILY CHALLENGE BUTTON ===== */
.btn-daily {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  border-color: #f59e0b;
  position: relative;
}

.btn-daily:hover {
  background: linear-gradient(135deg, #d97706, #dc2626);
  border-color: #d97706;
}

.daily-challenge-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #22c55e;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border: 2px solid var(--surface);
}

.daily-challenge-badge.done {
  background: var(--text-light);
}

/* ===== FUN POPUP ===== */
#fun-popup {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  z-index: 8000;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#fun-popup.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== COMBO COUNTER ===== */
#combo-popup {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%) scale(0.5);
  font-size: 2rem;
  font-weight: 900;
  color: var(--primary);
  text-shadow: 0 2px 8px rgba(0,0,0,0.18);
  pointer-events: none;
  z-index: 8001;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  letter-spacing: -1px;
}

#combo-popup.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ===== SPARKLE PARTICLES ===== */
#sparkle-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 7999;
  overflow: hidden;
}

.sparkle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: sparkleFly 0.8s ease-out forwards;
}

@keyframes sparkleFly {
  0%   { opacity: 1; transform: scale(1) translate(0, 0); }
  100% { opacity: 0; transform: scale(0) translate(var(--sx), var(--sy)); }
}

/* ===== SCREEN SHAKE ===== */
@keyframes screenShake {
  0%, 100% { transform: translateX(0); }
  10%       { transform: translateX(-6px) rotate(-0.5deg); }
  20%       { transform: translateX(6px) rotate(0.5deg); }
  30%       { transform: translateX(-5px); }
  40%       { transform: translateX(5px); }
  50%       { transform: translateX(-3px); }
  60%       { transform: translateX(3px); }
  70%       { transform: translateX(-2px); }
  80%       { transform: translateX(2px); }
}

.screen-shake {
  animation: screenShake 0.55s ease !important;
}

/* ===== WINNING OPTION PULSE ===== */
@keyframes winPulse {
  0%   { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4); }
  60%  { box-shadow: 0 0 0 12px rgba(79, 70, 229, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}

.option-btn.winner-pulse {
  animation: winPulse 0.7s ease-out;
}

.option-btn.option-a.winner-pulse {
  animation: winPulseA 0.7s ease-out;
}

@keyframes winPulseA {
  0%   { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.5); }
  60%  { box-shadow: 0 0 0 14px rgba(249, 115, 22, 0); }
  100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); }
}

.option-btn.option-b.winner-pulse {
  animation: winPulseB 0.7s ease-out;
}

@keyframes winPulseB {
  0%   { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.5); }
  60%  { box-shadow: 0 0 0 14px rgba(6, 182, 212, 0); }
  100% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0); }
}

/* ===== VOTE COUNT BOUNCE ===== */
@keyframes countBounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  70%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}

.result-pct.bounce {
  animation: countBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-block;
}

/* ===== GLOW EFFECT ON CHOSEN OPTION ===== */
.option-btn.selected.option-a.glow {
  box-shadow: 0 0 0 3px var(--option-a), 0 0 16px rgba(249, 115, 22, 0.35);
}

.option-btn.selected.option-b.glow {
  box-shadow: 0 0 0 3px var(--option-b), 0 0 16px rgba(6, 182, 212, 0.35);
}

/* ===== LEVEL UP BANNER ===== */
#levelup-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  padding: 28px 36px;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow-lg);
  z-index: 9000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#levelup-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#levelup-banner .levelup-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 8px;
}

#levelup-banner .levelup-title {
  font-size: 1.6rem;
  font-weight: 900;
  display: block;
  margin-bottom: 4px;
}

#levelup-banner .levelup-subtitle {
  font-size: 1rem;
  font-weight: 600;
  opacity: 0.9;
  display: block;
}

/* ===== DAILY CHALLENGE PROGRESS ===== */
.daily-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.daily-progress-bar-bg {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
}

.daily-progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  transition: width 0.5s ease;
}

.daily-reward-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 10px;
}

/* XP bar in game header */
.game-xp-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0 6px;
}

.game-xp-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.game-xp-bg {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
}

.game-xp-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.5s ease;
  width: 0%;
}

[data-theme="dark"] .xp-bar-container {
  background: var(--surface);
}

[data-theme="dark"] #fun-popup {
  background: var(--primary);
}

[data-theme="dark"] #levelup-banner {
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

/* ---- RESPONSIVE ---- */
@media (min-width: 480px) {
  .options {
    gap: 14px;
  }

  .option-text {
    font-size: 1.05rem;
  }

  .mp-options {
    flex-direction: row;
  }

  .mp-options .btn {
    flex: 1;
  }

  .achievements-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (min-width: 600px) {
  #app {
    padding: 24px 24px 60px;
  }

  .home-hero h1 {
    font-size: 2.6rem;
  }

  .card {
    padding: 32px 28px;
  }

  .option-text {
    font-size: 1.1rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr 1fr 1fr;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr 1fr 1fr;
  }
}
