:root {
  color-scheme: light;
  --bg: #f6efe7;
  --panel: #fffaf4;
  --panel-border: #d9c8b8;
  --text: #1f1a16;
  --muted: #6f6257;
  --accent: #c8553d;
  --accent-soft: #f1d4cb;
  --secondary: #efe5da;
  --success: #2d6a4f;
  --danger: #9f2d2d;
  --shadow: 0 18px 45px rgba(84, 54, 33, 0.12);
  --surface: rgba(255, 255, 255, 0.72);
  --input-bg: #fff;
  --bg-top-glow: rgba(200, 85, 61, 0.18);
  --bg-bottom-glow: rgba(89, 132, 116, 0.15);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171411;
  --panel: #221c17;
  --panel-border: #4b3d32;
  --text: #f5eadf;
  --muted: #c0ad9c;
  --accent: #ef7b5d;
  --accent-soft: #503025;
  --secondary: #342b25;
  --success: #79c59b;
  --danger: #f18b8b;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --surface: rgba(44, 37, 31, 0.88);
  --input-bg: #2c241e;
  --bg-top-glow: rgba(239, 123, 93, 0.16);
  --bg-bottom-glow: rgba(121, 197, 155, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, var(--bg-top-glow), transparent 28%),
    radial-gradient(circle at bottom right, var(--bg-bottom-glow), transparent 32%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.panel {
  width: min(920px, 100%);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px;
  position: relative;
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.theme-toggle {
  min-width: 120px;
}

.hero h1,
.section-header h2 {
  margin: 0;
}

.eyebrow,
.muted,
.subtle {
  color: var(--muted);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gap-lg {
  gap: 24px;
}

form {
  max-width: 360px;
}

.startup-stat {
  margin: 4px 0 0;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

.author-note {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  text-align: right;
}

.author-note a {
  text-decoration: none;
}

.author-note a:hover {
  text-decoration: underline;
}

input,
select {
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--input-bg);
  color: var(--text);
}

.deck-hint {
  margin: -2px 0 2px;
  font-size: 0.9rem;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

button.secondary {
  background: var(--secondary);
  color: var(--text);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.hidden {
  display: none !important;
}

.room-topbar,
.section-header,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.room-link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.copy-link-button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.copy-link-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.actions {
  justify-content: flex-start;
}

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.88rem;
}

.participants {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.participant-card,
.stats article {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--surface);
}

.flip-card {
  overflow: hidden;
  border-radius: 16px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 92px;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.08));
}

.flip-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  font-size: 2rem;
  font-weight: 700;
  transition:
    opacity 0.42s ease,
    transform 0.52s cubic-bezier(0.2, 0.8, 0.2, 1);
  transition-delay: var(--flip-delay, 0ms);
}

.flip-front {
  background:
    linear-gradient(135deg, var(--accent-soft), transparent),
    var(--input-bg);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  opacity: 1;
  transform: scale(1) translateY(0);
}

.flip-back {
  background: var(--accent);
  color: #fff;
  opacity: 0;
  transform: scale(0.92) translateY(8px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.16);
}

.participant-card.revealed .flip-front {
  opacity: 0;
  transform: scale(0.9) translateY(-10px);
}

.participant-card.revealed .flip-back {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.vote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 10px;
}

.vote-card {
  min-height: 72px;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--panel-border);
}

.vote-card.selected {
  background: var(--accent);
  color: #fff;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.stats strong {
  font-size: 1.4rem;
}

.message {
  margin: 0;
  color: var(--success);
}

.message.error {
  color: var(--danger);
}

.confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  opacity: 0;
  transform-origin: center;
  animation-name: confetti-pop;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
  animation-fill-mode: forwards;
}

.confetti-piece.from-left {
  box-shadow: -10px 0 18px rgba(239, 123, 93, 0.12);
}

.confetti-piece.from-right {
  box-shadow: 10px 0 18px rgba(93, 139, 239, 0.12);
}

@keyframes confetti-pop {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.9);
  }

  8% {
    opacity: 1;
  }

  55% {
    opacity: 1;
    transform: translate3d(var(--confetti-x), calc(var(--confetti-y) * 0.92), 0)
      rotate(calc(var(--confetti-rotate) * 0.72)) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate3d(
      calc(var(--confetti-x) * 1.2),
      calc(var(--confetti-y) + 80px),
      0
    ) rotate(var(--confetti-rotate)) scale(0.96);
  }
}

a {
  color: var(--accent);
}

@media (max-width: 640px) {
  .panel {
    padding: 20px;
    border-radius: 20px;
  }
}
