/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0f0e17;
  --bg-card: #1a1932;
  --bg-sidebar: #161528;
  --text: #fffffe;
  --text-muted: #a7a9be;
  --primary: #ff8906;
  --primary-hover: #e07800;
  --secondary: #e53170;
  --accent: #7f5af0;
  --success: #2cb67d;
  --border: #2e2c45;
  --radius: 12px;
}

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Landing Page ──────────────────────────────────────────────────────── */
.landing-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px;
  text-align: center;
}

.logo-section {
  margin-bottom: 40px;
}

.logo-wheel-mini {
  font-size: 64px;
  margin-bottom: 10px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.logo-section h1 {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-top: 8px;
}

.cards-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 48px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: left;
}

.card h2 {
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

textarea, input[type="text"] {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  margin-bottom: 16px;
}

textarea {
  min-height: 160px;
}

input[type="text"]:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 137, 6, 0.15);
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #000;
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--accent);
  color: var(--text);
}
.btn-secondary:hover {
  background: #6b4bd4;
  transform: translateY(-1px);
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
  width: auto;
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}
.btn-icon:hover {
  background: var(--border);
}

.btn-spin {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  font-size: 1.1rem;
  padding: 14px;
  letter-spacing: 1px;
}
.btn-spin:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(255, 137, 6, 0.3);
}
.btn-spin:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Features ──────────────────────────────────────────────────────────── */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.feature {
  text-align: center;
}
.feature span {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}
.feature strong {
  display: block;
  margin-bottom: 4px;
}
.feature p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ── Room Page Layout ──────────────────────────────────────────────────── */
.room-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  min-height: 100vh;
}

.wheel-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  position: relative;
}

.room-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}
.back-link:hover {
  color: var(--text);
}

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

.room-badge {
  background: var(--accent);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 2px;
}

.viewer-badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
}

/* ── Wheel ─────────────────────────────────────────────────────────────── */
.wheel-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  max-width: 600px;
  max-height: 600px;
  aspect-ratio: 1;
}

#wheel-canvas {
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.pointer {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-top: 36px solid var(--primary);
  z-index: 10;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.center-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a1932, #2e2c45);
  border: 3px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  transition: all 0.2s;
  box-shadow: 0 0 20px rgba(255, 137, 6, 0.2);
}
.center-btn:hover {
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 0 30px rgba(255, 137, 6, 0.4);
}
.center-btn span {
  color: var(--primary);
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 1px;
}

.spin-status {
  height: 30px;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 8px;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 100vh;
}

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

.sidebar-header h2 {
  font-size: 1.2rem;
}

.host-badge {
  background: var(--success);
  color: #000;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.segments-list {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 12px;
}

.segment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 4px;
  transition: background 0.2s;
}
.segment-item:hover {
  background: rgba(255,255,255,0.03);
}

.segment-color {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid rgba(255,255,255,0.1);
  cursor: pointer;
  flex-shrink: 0;
}

.segment-color input[type="color"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.segment-label {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 4px 8px;
  border-radius: 4px;
}
.segment-label:focus {
  border-color: var(--border);
  background: var(--bg);
  outline: none;
}
.segment-label[readonly] {
  cursor: default;
}

.segment-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.2s;
}
.segment-delete:hover {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
}

.host-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.sidebar-footer {
  margin-bottom: 16px;
}

/* ── History ────────────────────────────────────────────────────────────── */
.history {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.history h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.history ul {
  list-style: none;
}
.history li {
  padding: 6px 10px;
  font-size: 0.85rem;
  border-radius: 6px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.history-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden {
  display: none;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
}
.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  z-index: 1;
  min-width: 320px;
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-content h2 {
  font-size: 1.8rem;
  margin-bottom: 16px;
}

.result-label {
  font-size: 2rem;
  font-weight: 800;
  padding: 16px 32px;
  border-radius: 12px;
  margin-bottom: 24px;
  display: inline-block;
}

.modal-content .btn {
  width: auto;
  min-width: 120px;
}

/* ── Confetti ──────────────────────────────────────────────────────────── */
.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: 16px;
}
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confettiFall 2.5s ease-in forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(400px) rotate(720deg); opacity: 0; }
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .cards-row {
    grid-template-columns: 1fr;
  }

  .features {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .room-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: none;
  }

  .wheel-wrapper {
    max-width: 90vw;
    max-height: 90vw;
  }
}

/* ── Auth Section ──────────────────────────────────────────────────────── */
.auth-section {
  margin-bottom: 16px;
}

.auth-prompt {
  text-align: center;
  padding: 16px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.auth-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 14px;
}

.btn-twitch {
  background: #9146FF;
  color: #fff;
  margin-bottom: 8px;
}
.btn-twitch:hover {
  background: #7c3ae6;
  transform: translateY(-1px);
}

.btn-youtube {
  background: #FF0000;
  color: #fff;
}
.btn-youtube:hover {
  background: #d40000;
  transform: translateY(-1px);
}

.btn-twitch, .btn-youtube {
  text-decoration: none;
}

.btn-twitch svg, .btn-youtube svg {
  flex-shrink: 0;
}

.auth-status-box {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}

.auth-status-box.verified {
  border-color: var(--success);
}

.auth-status-box.unverified {
  border-color: #e67e22;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.auth-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.auth-platform {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 6px;
}
.auth-platform.twitch {
  background: #9146FF;
  color: #fff;
}
.auth-platform.youtube {
  background: #FF0000;
  color: #fff;
}

.auth-verified {
  color: var(--success);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.auth-warning {
  color: #e67e22;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.btn-recheck {
  background: var(--border);
  color: var(--text);
  margin-bottom: 6px;
  width: 100%;
}
.btn-recheck:hover {
  background: #3e3c55;
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 100%;
}
.btn-logout:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.admin-status {
  color: var(--success);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.hidden {
  display: none !important;
}
