/* =====================================================================
   Sprint Planning Poker — stylesheet
   Dark, glassmorphism, neon-accent theme
   ===================================================================== */

:root {
  /* Palette */
  --bg-0: #07091a;
  --bg-1: #0f1226;
  --bg-2: #161a3a;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --surface-3: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f3f4f8;
  --text-dim: #a3a8c3;
  --text-faint: #6b7099;

  /* Accents */
  --cyan: #22d3ee;
  --violet: #a78bfa;
  --pink: #f472b6;
  --emerald: #34d399;
  --amber: #fbbf24;
  --rose: #fb7185;

  --accent: var(--cyan);
  --accent-glow: rgba(34, 211, 238, 0.45);

  /* Effects */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --radius-xl: 32px;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 32px var(--accent-glow);
  --transition: 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(ellipse at 0% 0%, rgba(167, 139, 250, 0.18), transparent 50%),
    radial-gradient(ellipse at 100% 0%, rgba(34, 211, 238, 0.15), transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(244, 114, 182, 0.12), transparent 50%),
    linear-gradient(135deg, var(--bg-0) 0%, var(--bg-1) 50%, var(--bg-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

/* ====== Decorative orbs ====== */
.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}
.orb.cyan { background: var(--cyan); width: 320px; height: 320px; top: -80px; right: -80px; }
.orb.violet { background: var(--violet); width: 380px; height: 380px; bottom: -120px; left: -120px; opacity: 0.35; }

/* ====== Layout ====== */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px;
  position: relative;
  z-index: 1;
}

/* ====== Typography ====== */
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: 2.5rem; line-height: 1.1; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.gradient-text {
  background: linear-gradient(135deg, var(--cyan) 0%, var(--violet) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ====== Buttons ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.btn:hover { background: var(--surface-3); border-color: var(--accent); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--cyan) 0%, var(--violet) 100%);
  color: #07091a;
  border: none;
  box-shadow: 0 8px 24px rgba(34, 211, 238, 0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #5be5f3 0%, #b9a3fc 100%);
  box-shadow: 0 12px 36px rgba(34, 211, 238, 0.5);
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
  background: rgba(251, 113, 133, 0.15);
  border: 1px solid rgba(251, 113, 133, 0.3);
  color: var(--rose);
}
.btn-danger:hover { background: rgba(251, 113, 133, 0.25); border-color: var(--rose); }

.btn-lg { padding: 16px 32px; font-size: 1.05rem; border-radius: var(--radius-lg); }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; border-radius: var(--radius-sm); }
.btn-icon { padding: 10px; min-width: 40px; height: 40px; }

/* ====== Inputs ====== */
.input, .textarea, .select {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  outline: none;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input::placeholder { color: var(--text-faint); }

label.field {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ====== Glass card ====== */
.glass {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

/* ====== Landing ====== */
.landing {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.landing-card {
  width: 100%;
  max-width: 460px;
  padding: 40px 36px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--cyan) 0%, var(--violet) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 6px 20px rgba(34, 211, 238, 0.35);
}
.brand-title { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }
.brand-sub { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 32px; }

.landing-form { display: flex; flex-direction: column; gap: 18px; }
.color-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.color-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.selected { border-color: white; box-shadow: 0 0 0 3px rgba(255,255,255,0.2); }

.divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.landing-actions { display: flex; flex-direction: column; gap: 12px; }
.join-row { display: flex; gap: 8px; }

/* ====== Room page ====== */
.room-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .room-layout { grid-template-columns: 1fr; }
}

.sidebar { display: flex; flex-direction: column; gap: 16px; }
.main { display: flex; flex-direction: column; gap: 20px; min-height: 70vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 24px;
  margin-bottom: 24px;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.room-code {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}
.room-code:hover { border-color: var(--accent); color: var(--accent); }
.room-code .copy-icon { width: 14px; height: 14px; }

.round-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(167, 139, 250, 0.15);
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--violet);
}

/* Participants panel */
.participants {
  padding: 20px;
}
.participants-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.participants h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }
.participant-list { display: flex; flex-direction: column; gap: 10px; }
.participant {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: all var(--transition);
}
.participant.offline { opacity: 0.5; }
.participant.you { border-color: rgba(34, 211, 238, 0.3); background: rgba(34, 211, 238, 0.05); }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #07091a;
  font-size: 0.9rem;
  position: relative;
  flex-shrink: 0;
}
.avatar .online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--emerald);
  border: 2px solid var(--bg-1);
}
.avatar .offline-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-faint);
  border: 2px solid var(--bg-1);
}
.participant-info { flex: 1; min-width: 0; }
.participant-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.participant-status { font-size: 0.75rem; color: var(--text-faint); display: flex; align-items: center; gap: 6px; }
.vote-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--emerald);
}
.host-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--amber);
}

/* ====== Deck picker ====== */
.deck-picker {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px;
}
.deck-picker-label { font-size: 0.85rem; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.deck-options { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.deck-option {
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-dim);
  font-family: inherit;
}
.deck-option:hover { border-color: var(--accent); color: var(--text); }
.deck-option.active {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.18) 0%, rgba(167, 139, 250, 0.18) 100%);
  border-color: var(--accent);
  color: var(--text);
}

/* ====== Card fan ====== */
.card-area {
  padding: 48px 32px;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.card-fan {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  align-items: center;
  perspective: 1200px;
}

.card {
  position: relative;
  width: 110px;
  height: 160px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 500ms cubic-bezier(0.2, 0.9, 0.3, 1.2), box-shadow var(--transition);
}
.card:hover { transform: translateY(-8px); }
.card.disabled { cursor: not-allowed; opacity: 0.5; }
.card.disabled:hover { transform: none; }

.card-face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  user-select: none;
}

.card-front {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.08) 0%, rgba(167, 139, 250, 0.08) 100%);
  border: 1.5px solid var(--border-strong);
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.card-front::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.05) 50%, transparent 100%);
  pointer-events: none;
}
.card-back {
  background: linear-gradient(135deg, var(--cyan) 0%, var(--violet) 100%);
  color: #07091a;
  transform: rotateY(180deg);
  box-shadow: 0 12px 36px rgba(34, 211, 238, 0.45);
  font-size: 1.4rem;
}
.card-back::after {
  content: '?';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 800;
  color: rgba(7, 9, 26, 0.9);
}

/* Selected state (face-down back showing, prior to reveal) */
.card.selected .card-front { transform: rotateY(180deg); }
.card.selected .card-back { transform: rotateY(0deg); }

/* Revealed state (face-up showing the actual value) */
.card.revealed .card-front { transform: rotateY(0deg); }
.card.revealed .card-back { transform: rotateY(-180deg); }

.card.selected .card-front,
.card.revealed .card-front {
  background: linear-gradient(135deg, var(--cyan) 0%, var(--violet) 100%);
  color: #07091a;
  border-color: transparent;
  box-shadow: 0 14px 40px rgba(34, 211, 238, 0.55);
}

/* ====== Action bar ====== */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  flex-wrap: wrap;
}

/* ====== Stats panel (shown after reveal) ====== */
.stats-panel {
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 16px;
  animation: fadeIn 400ms ease;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin-bottom: 4px; }
.stat-value { font-size: 1.6rem; font-weight: 800; }
.stat-value.accent {
  background: linear-gradient(135deg, var(--cyan) 0%, var(--violet) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.distribution {
  grid-column: 1 / -1;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.distribution h4 { font-size: 0.85rem; margin-bottom: 12px; color: var(--text-dim); }
.dist-bars { display: flex; gap: 8px; align-items: flex-end; height: 80px; }
.dist-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.dist-bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--cyan) 0%, var(--violet) 100%);
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: height 500ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.dist-bar-label { font-size: 0.75rem; color: var(--text-dim); font-weight: 600; }

/* ====== Modal ====== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 9, 26, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 200ms ease;
  padding: 24px;
}
.modal {
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  animation: slideUp 300ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.4rem;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }

/* Custom deck designer */
.designer-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; min-height: 60px; }
.designer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: grab;
  transition: all var(--transition);
}
.designer-row:active { cursor: grabbing; }
.designer-row.dragging { opacity: 0.4; }
.designer-row.drag-over { border-color: var(--accent); background: rgba(34, 211, 238, 0.05); }
.designer-handle { color: var(--text-faint); cursor: grab; user-select: none; font-size: 1.1rem; }
.designer-input { background: transparent; border: none; color: var(--text); font-size: 1rem; font-family: inherit; flex: 1; outline: none; }
.designer-input:focus { outline: none; }
.designer-delete {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
}
.designer-delete:hover { color: var(--rose); background: rgba(251, 113, 133, 0.1); }

.designer-add-row { display: flex; gap: 8px; margin-bottom: 18px; }
.designer-add-row .input { flex: 1; }
.designer-meta { font-size: 0.8rem; color: var(--text-faint); margin-bottom: 12px; }
.designer-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ====== Toast ====== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  padding: 12px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  box-shadow: var(--shadow-soft);
  animation: slideInRight 300ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
}
.toast.error { border-color: var(--rose); background: rgba(251, 113, 133, 0.12); }
.toast.success { border-color: var(--emerald); background: rgba(52, 211, 153, 0.12); }

/* ====== Animations ====== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.pulse { animation: pulse 1.4s ease-in-out infinite; }

/* ====== Connection indicator ====== */
.conn-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-dim);
}
.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}
.conn-dot.disconnected { background: var(--rose); box-shadow: 0 0 8px var(--rose); }

/* ====== Empty state ====== */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-faint);
}

/* ====== Helpers ====== */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* Smaller cards on narrow screens */
@media (max-width: 600px) {
  .card { width: 78px; height: 116px; }
  .card-face { font-size: 1.7rem; }
  .card-back::after { font-size: 1.7rem; }
  .card-area { padding: 24px 12px; min-height: 220px; }
  .card-fan { gap: 10px; }
  h1 { font-size: 1.8rem; }
  .landing-card { padding: 28px 22px; }
  .topbar { padding: 12px 16px; }
}
