:root {
  --ice-1: #38bdf8;
  --ice-2: #22d3ee;
  --fire-1: #fb923c;
  --fire-2: #f59e0b;
  --bg: #08090c;
  --card-bg: rgba(255, 255, 255, 0.055);
  --card-border: rgba(255, 255, 255, 0.12);
  --text-hi: #f4f6f8;
  --text-mid: rgba(244, 246, 248, 0.72);
  --text-lo: rgba(244, 246, 248, 0.45);
  --radius: 28px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text-hi);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
}

::selection { background: var(--fire-2); color: #08090c; }

/* ---------- Animated gradient mesh background ---------- */
.mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  will-change: transform;
}
.b1 {
  width: 55vw; height: 55vw;
  top: -18vw; left: -12vw;
  background: radial-gradient(circle at 30% 30%, var(--ice-1), transparent 70%);
  animation: float1 22s ease-in-out infinite;
}
.b2 {
  width: 45vw; height: 45vw;
  bottom: -15vw; right: -10vw;
  background: radial-gradient(circle at 60% 60%, var(--fire-1), transparent 70%);
  animation: float2 26s ease-in-out infinite;
}
.b3 {
  width: 35vw; height: 35vw;
  top: 30%; right: 15%;
  background: radial-gradient(circle at 50% 50%, var(--fire-2), transparent 70%);
  opacity: 0.28;
  animation: float3 30s ease-in-out infinite;
}
@keyframes float1 {
  0%, 100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(6vw, 8vw) scale(1.1); }
}
@keyframes float2 {
  0%, 100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(-5vw, -6vw) scale(1.08); }
}
@keyframes float3 {
  0%, 100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(-4vw, 5vw) scale(0.92); }
}
.grain {
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* ---------- Topbar ---------- */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(20px, 5vw, 56px) 0;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.02em; }
.brand-mark { font-size: 1.3rem; filter: saturate(1.3); }
.brand-name { font-size: 1.15rem; }
.present-btn, .tool-btn {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-hi);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: background .18s ease, transform .18s ease, border-color .18s ease;
}
.present-btn:hover, .tool-btn:hover { background: rgba(255,255,255,0.12); transform: translateY(-1px); }
.present-btn:active, .tool-btn:active { transform: translateY(0); }

/* ---------- Stage / intro ---------- */
.stage {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 20px clamp(18px, 5vw, 40px) 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.intro { max-width: 620px; margin: 34px 0 30px; transition: opacity .4s ease, max-height .4s ease, margin .4s ease; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--text-lo);
  margin: 0 0 14px;
  font-weight: 600;
}
.headline {
  font-family: "Fraunces", serif;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  line-height: 1.05;
  margin: 0 0 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.headline em {
  font-style: italic;
  font-weight: 500;
  background: linear-gradient(100deg, var(--ice-2), var(--fire-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sub { color: var(--text-mid); font-size: 1rem; line-height: 1.6; margin: 0; }

body.presenting .intro { opacity: 0; max-height: 0; margin: 0; overflow: hidden; }

/* ---------- Session row / room banner ---------- */
.session-row {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
}
body.presenting .session-row { display: none; }

.room-banner {
  width: min(600px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 14px 20px;
  margin-bottom: 26px;
  backdrop-filter: blur(14px);
}
body.presenting .room-banner { opacity: 0.4; }
body.presenting .room-banner:hover { opacity: 1; }

.room-code-block { display: flex; align-items: center; gap: 10px; }
.room-code-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-lo);
  font-weight: 700;
}
.room-code {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: 0.08em;
  background: linear-gradient(100deg, var(--ice-2), var(--fire-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.mini-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--card-border);
  color: var(--text-mid);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s ease;
}
.mini-btn:hover { background: rgba(255,255,255,0.14); color: var(--text-hi); }

.room-meta { display: flex; align-items: center; gap: 14px; font-size: 0.8rem; color: var(--text-mid); font-weight: 600; }
.role-badge {
  background: rgba(251,146,60,0.18);
  border: 1px solid rgba(251,146,60,0.4);
  color: var(--fire-1);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.role-badge.guest { background: rgba(56,189,248,0.18); border-color: rgba(56,189,248,0.4); color: var(--ice-1); }
.leave-link { color: var(--text-lo); text-decoration: none; font-weight: 600; }
.leave-link:hover { color: var(--text-hi); }

.guest-note {
  width: min(600px, 100%);
  text-align: center;
  color: var(--text-lo);
  font-size: 0.85rem;
  margin: -12px 0 26px;
}

body.guest-mode .filters,
body.guest-mode .toolbar {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(0.4);
}
body.guest-mode .nav-arrow { opacity: 0.35; pointer-events: none; }

/* ---------- Join modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(4,5,7,0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  width: 100%;
  max-width: 360px;
  background: #101114;
  border: 1px solid var(--card-border);
  border-radius: 22px;
  padding: 28px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.7);
}
.modal h3 { margin: 0 0 8px; font-family: "Fraunces", serif; font-size: 1.3rem; font-weight: 600; }
.modal p { margin: 0 0 18px; color: var(--text-mid); font-size: 0.88rem; }
.modal input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--card-border);
  color: var(--text-hi);
  font-family: "Fraunces", serif;
  font-size: 1.4rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: center;
  padding: 14px;
  border-radius: 14px;
  outline: none;
  box-sizing: border-box;
}
.modal input:focus { border-color: var(--ice-1); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .tool-btn { flex: 1; justify-content: center; }

/* ---------- Filters ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 34px;
}
body.presenting .filters { display: none; }
.chip {
  border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.04);
  color: var(--text-mid);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
  white-space: nowrap;
}
.chip:hover { color: var(--text-hi); border-color: rgba(255,255,255,0.28); }
.chip.active {
  background: linear-gradient(100deg, var(--ice-2), var(--fire-2));
  color: #0a0a0a;
  border-color: transparent;
}

/* ---------- Deck ---------- */
.deck-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 3vw, 28px);
  width: 100%;
}
.nav-arrow {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.04);
  color: var(--text-hi);
  font-size: 1.4rem;
  cursor: pointer;
  transition: all .18s ease;
  display: flex; align-items: center; justify-content: center;
}
.nav-arrow:hover { background: rgba(255,255,255,0.12); transform: scale(1.06); }
.nav-arrow:active { transform: scale(0.96); }

.card-slot {
  perspective: 1600px;
  width: min(600px, 100%);
}
.card {
  position: relative;
  min-height: 320px;
  border-radius: var(--radius);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(20px);
  box-shadow: 0 30px 60px -30px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06);
  padding: clamp(28px, 5vw, 46px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.2,.9,.25,1), box-shadow .3s ease;
}
.card.flip { transform: rotateY(90deg) scale(0.94); }
.card.pop { animation: pop .38s cubic-bezier(.2,.9,.25,1.4); }
@keyframes pop {
  0% { transform: scale(0.97); }
  60% { transform: scale(1.015); }
  100% { transform: scale(1); }
}

.card-top { display: flex; gap: 8px; margin-bottom: 22px; }
.pill {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  border-radius: 999px;
}
.kind-pill { background: rgba(255,255,255,0.1); color: var(--text-mid); }
.cat-pill {
  background: linear-gradient(100deg, rgba(56,189,248,0.25), rgba(251,146,60,0.25));
  color: var(--text-hi);
  border: 1px solid rgba(255,255,255,0.1);
}
.card-text {
  font-family: "Fraunces", serif;
  font-size: clamp(1.35rem, 3.4vw, 1.85rem);
  line-height: 1.35;
  margin: 0;
  color: var(--text-hi);
  text-align: left;
}
.card-meta {
  margin-top: 22px;
  display: flex;
  gap: 14px;
  font-size: 0.8rem;
  color: var(--text-lo);
  font-weight: 600;
}
.card-meta span { display: flex; align-items: center; gap: 5px; }

/* ---------- Vote options ---------- */
.vote-options {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.vote-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--card-border);
  color: var(--text-hi);
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: 16px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.vote-btn:hover { border-color: rgba(255,255,255,0.28); }
.vote-btn:active { transform: scale(0.985); }
.vote-btn.selected {
  border-color: var(--ice-1);
  background: rgba(56,189,248,0.12);
}
.vote-btn.selected::after {
  content: "✓";
  color: var(--ice-1);
  font-weight: 800;
  margin-left: 8px;
}
.vote-label { position: relative; z-index: 1; }
.vote-bar {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 16px;
  overflow: hidden;
  pointer-events: none;
}
.vote-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(100deg, rgba(56,189,248,0.22), rgba(251,146,60,0.22));
  transition: width .4s cubic-bezier(.2,.9,.25,1);
}
.vote-count {
  position: relative;
  z-index: 1;
  font-size: 0.8rem;
  color: var(--text-mid);
  font-weight: 700;
  min-width: 1.4em;
  text-align: right;
}
.vote-status {
  margin: 12px 0 0;
  font-size: 0.78rem;
  color: var(--text-lo);
  font-weight: 600;
  text-align: center;
}

.ai-summary {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(100deg, rgba(56,189,248,0.1), rgba(251,146,60,0.1));
  border: 1px solid rgba(255,255,255,0.1);
  font-family: "Fraunces", serif;
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text-hi);
}
.ai-summary::before {
  content: "✨ ";
  font-style: normal;
}

.deck-progress {
  width: min(600px, 100%);
  margin: 20px 0 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
#progressLabel { font-size: 0.78rem; color: var(--text-lo); font-weight: 600; letter-spacing: 0.02em; }
.progress-track {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ice-2), var(--fire-2));
  border-radius: 999px;
  transition: width .35s ease;
}

/* ---------- Toolbar ---------- */
.toolbar {
  margin-top: 30px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.tool-btn.primary {
  background: linear-gradient(100deg, var(--ice-2), var(--fire-2));
  color: #0a0a0a;
  border-color: transparent;
}
.tool-btn.primary:hover { filter: brightness(1.08); }
.tool-btn svg { flex: 0 0 auto; }

.timer { position: relative; }
.timer-options {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  display: flex;
  gap: 6px;
  background: rgba(15,16,20,0.92);
  border: 1px solid var(--card-border);
  padding: 8px;
  border-radius: 16px;
  backdrop-filter: blur(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}
.timer:hover .timer-options,
.timer.open .timer-options {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.timer-options button {
  background: transparent;
  border: none;
  color: var(--text-mid);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.timer-options button:hover { background: rgba(255,255,255,0.08); color: var(--text-hi); }
.timer-options button.active { background: linear-gradient(100deg, var(--ice-2), var(--fire-2)); color: #0a0a0a; }
.timer.running #timerToggle { border-color: var(--fire-2); }
.timer.running #timerLabel { color: var(--fire-1); }

#favBtn.active { color: var(--fire-1); border-color: var(--fire-2); }
#favBtn.active svg path { fill: var(--fire-2); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20,20,24,0.92);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(16px);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all .28s cubic-bezier(.2,.9,.25,1.4);
  z-index: 10;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Presentation mode ---------- */
body.presenting .card-slot { width: min(760px, 92vw); }
body.presenting .card { min-height: 400px; }
body.presenting .card-text { font-size: clamp(1.8rem, 4.4vw, 2.6rem); }
body.presenting .topbar { opacity: 0.35; }
body.presenting .topbar:hover { opacity: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .nav-arrow { width: 38px; height: 38px; font-size: 1.2rem; }
  .card { min-height: 260px; padding: 26px 22px; }
  .toolbar { gap: 8px; }
  .tool-btn { padding: 9px 13px; font-size: 0.78rem; }
}

@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
  .card, .chip, .tool-btn, .present-btn { transition: none; }
}
