/* ==========================================================================
   Planning Poker — dark theme, responsive circular table
   ========================================================================== */

:root {
  --bg: #0f1117;
  --bg-elev: #171a24;
  --bg-elev-2: #1f2330;
  --border: #2a2f3d;
  --text: #eef0f5;
  --text-dim: #9aa1b2;
  --accent: #6c8cff;
  --accent-2: #7ee0c1;
  --danger: #ff6b7a;
  --warn: #ffb85c;
  --shadow: 0 8px 30px rgba(0,0,0,0.45);
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(1200px 800px at 50% -10%, #1a1f2e 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  padding: 0.55em 1em;
  border-radius: 10px;
  font-size: 0.95rem;
  transition: transform 0.08s ease, background 0.15s ease, border-color .15s ease;
}
.btn:hover:not(:disabled) { background: #262b3a; border-color: #3a4155; }
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #4d6bde); border-color: transparent; color: white; font-weight: 600; }
.btn-secondary { background: linear-gradient(135deg, #384057, #2a3145); }
.btn-ghost { background: transparent; }
.btn-lg { padding: 0.8em 1.6em; font-size: 1.05rem; }

/* ---------------------------------------------------------------- status pill */
.status-pill {
  position: fixed;
  top: 10px; right: 10px;
  z-index: 500;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-dim);
  box-shadow: var(--shadow);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.status-pill[data-state="host"] .dot { background: var(--accent-2); }
.status-pill[data-state="connected"] .dot { background: var(--accent-2); }
.status-pill[data-state="reconnecting"] .dot { background: var(--danger); animation: pulse 1s infinite; }
.status-pill[data-state="connecting"] .dot { background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ---------------------------------------------------------------- screens */
.screen { min-height: 100vh; display: flex; flex-direction: column; }

.landing { align-items: center; justify-content: center; padding: 20px; }
.landing-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.landing-card h1 { margin-top: 0; font-size: 2rem; }
.landing-card p { color: var(--text-dim); }
.landing-card .hint { font-size: 0.85rem; margin-top: 16px; }

/* ---------------------------------------------------------------- room header */
.room-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(23,26,36,0.6);
  backdrop-filter: blur(6px);
}
.topic-wrap { flex: 1; min-width: 200px; }
.topic-display { margin: 0; font-size: 1.15rem; font-weight: 600; cursor: pointer; }
.topic-display.editable:hover { color: var(--accent); }
.topic-input {
  width: 100%; max-width: 420px;
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 10px; border-radius: 8px; font-size: 1rem;
}
.room-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- table */
.table-wrap { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; min-height: 420px; }

.table {
  position: relative;
  width: min(680px, 92vw);
  height: min(420px, 60vh);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #1c2436, #12151d 75%);
  border: 2px solid var(--border);
  box-shadow: inset 0 0 60px rgba(0,0,0,0.5), var(--shadow);
}

.table-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 10px;
}

.stats { display: flex; gap: 16px; font-size: 0.85rem; color: var(--text-dim); }
.stats > div { display: flex; flex-direction: column; align-items: center; }
.stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }
.stats span:last-child { font-size: 1.3rem; color: var(--text); font-weight: 700; }

.consensus-banner {
  font-size: 1.4rem; font-weight: 800;
  color: var(--accent-2);
  animation: bounce-in 0.5s ease;
}
@keyframes bounce-in {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

/* seats positioned via JS with left/top percentages (circle math) */
.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center;
  width: 92px;
  cursor: pointer;
  user-select: none;
}
.seat .card {
  width: 56px; height: 78px;
  border-radius: 8px;
  background: var(--bg-elev-2);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 800;
  box-shadow: var(--shadow);
  position: relative;
  perspective: 400px;
}
.seat .card-inner {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.5s;
  transform-style: preserve-3d;
  position: relative;
}
.seat.revealed .card-inner { transform: rotateY(180deg); }
.card-face { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; backface-visibility: hidden; border-radius: 6px; }
.card-face.front { background: var(--bg-elev-2); color: var(--text-dim); font-size: 1.5rem; }
.card-face.back { background: linear-gradient(135deg, var(--accent), #4d6bde); color: white; transform: rotateY(180deg); }

.seat.voted .card { border-color: var(--accent-2); }
.seat.leader .name::before { content: "👑 "; }
.seat.me .name { color: var(--accent); }
.seat.empty-vote .card { opacity: 0.5; }

.seat .name {
  margin-top: 6px; font-size: 0.85rem; font-weight: 600;
  max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seat .sub { font-size: 0.7rem; color: var(--text-dim); }

.seat .speech-bubble {
  position: absolute;
  bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 0.75rem;
  max-width: 160px;
  white-space: normal;
  word-break: break-word;
  box-shadow: var(--shadow);
  animation: pop-in 0.2s ease;
  z-index: 5;
}
@keyframes pop-in { from { transform: translateX(-50%) scale(0.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

/* countdown overlay */
.countdown-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 50; pointer-events: none;
}
.countdown-number {
  font-size: 8rem; font-weight: 900; color: var(--accent-2);
  text-shadow: 0 0 40px rgba(126,224,193,0.6);
  animation: countdown-pop 1s ease;
}
@keyframes countdown-pop {
  0% { transform: scale(2); opacity: 0; }
  30% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.8); opacity: 0; }
}

/* flying emoji / confetti layer */
.fx-layer { position: absolute; inset: 0; overflow: visible; pointer-events: none; z-index: 40; }
.flying-emoji { position: absolute; font-size: 2rem; transition: left 0.6s cubic-bezier(.2,.8,.3,1.2), top 0.6s cubic-bezier(.2,.8,.3,1.2); }
.impact { animation: impact-pop 0.4s ease; }
@keyframes impact-pop { 0% { transform: scale(1); } 50% { transform: scale(1.8); } 100% { transform: scale(1); } }

.confetti-piece {
  position: absolute; top: -10px;
  width: 8px; height: 14px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(480px) rotate(720deg); opacity: 0.2; }
}

/* ---------------------------------------------------------------- deck */
.deck {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  padding: 16px;
}
.deck-card {
  width: 56px; height: 78px;
  border-radius: 8px;
  background: var(--bg-elev-2);
  border: 2px solid var(--border);
  color: var(--text);
  font-size: 1.2rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.deck-card:hover { transform: translateY(-6px); border-color: var(--accent); }
.deck-card.selected { border-color: var(--accent-2); background: linear-gradient(135deg, #24513f, #1c2436); transform: translateY(-6px); }

/* ---------------------------------------------------------------- soundboard */
.soundboard {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  padding: 0 16px 16px;
}
.soundboard button { font-size: 0.85rem; }

/* ---------------------------------------------------------------- shout box */
.shout-wrap {
  padding: 0 16px 20px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}
.shout-form { display: flex; gap: 8px; margin-bottom: 8px; }
.shout-form input {
  flex: 1;
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 10px; border-radius: 8px;
}
.shout-log {
  max-height: 120px; overflow-y: auto;
  font-size: 0.8rem; color: var(--text-dim);
  display: flex; flex-direction: column; gap: 4px;
}
.shout-log .entry b { color: var(--text); }

/* ---------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; width: min(360px, 90vw);
  box-shadow: var(--shadow);
}
.modal h3 { margin-top: 0; }
.modal input {
  width: 100%; padding: 10px; border-radius: 8px;
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text);
  font-size: 1rem; margin-bottom: 14px;
}
.modal-actions { display: flex; justify-content: flex-end; }

/* ---------------------------------------------------------------- emoji picker */
.emoji-picker {
  position: fixed;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px; box-shadow: var(--shadow); z-index: 900;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
}
.emoji-picker button { font-size: 1.3rem; background: transparent; border: none; padding: 6px; border-radius: 6px; }
.emoji-picker button:hover { background: var(--bg-elev-2); }

/* ---------------------------------------------------------------- responsive: small screens fall back to grid */
@media (max-width: 560px) {
  .table {
    width: 100%; height: auto; border-radius: 16px;
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 12px; padding: 16px 10px 130px;
    background: var(--bg-elev);
  }
  .table-center {
    position: static;
    grid-column: 1 / -1;
    order: -1;
  }
  .seat { position: static; transform: none; width: auto; }
  .countdown-overlay, .fx-layer { position: fixed; }
  .room-header { flex-direction: column; align-items: stretch; }
  .room-actions { justify-content: center; }
}
