:root {
  --bg-start: #0F0F1A;
  --bg-end: #1A1A2E;
  --gold: #FFD700;
  --gold-soft: #FFF3C4;
  --white: #FFFFFF;
  --text-muted: rgba(255, 255, 255, 0.65);
  --glass: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 215, 0, 0.25);
  --green-1: #00E676;
  --green-2: #00C853;
  --red-1: #FF1744;
  --red-2: #D50000;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(160deg, var(--bg-start), var(--bg-end));
  color: var(--white);
}

body {
  background-attachment: fixed;
}

h1, h2, h3 {
  margin: 0;
}

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

.hidden {
  display: none !important;
}

/* ---------- Header ---------- */

.app-header {
  text-align: center;
  padding: 24px 16px 12px;
}

.app-header h1 {
  font-size: 1.4rem;
  letter-spacing: 0.5px;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.35);
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.tab {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--white);
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.25s ease;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.tab:hover {
  border-color: var(--gold);
}

.tab.is-active {
  background: linear-gradient(135deg, var(--gold), #FFB300);
  color: #1a1400;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.45);
}

.stats {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.btn-sound {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  font-size: 1.1rem;
  line-height: 1;
  transition: border-color 0.2s ease;
}

.btn-sound:hover {
  border-color: var(--gold);
}

.btn-sound.is-muted {
  opacity: 0.55;
}

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  max-width: min(96vw, 2200px);
  margin: 0 auto;
  padding: 16px 24px 48px;
}

.wheel-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.controls {
  display: flex;
  justify-content: center;
}

.last-winner {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}

/* ---------- Buttons ---------- */

.btn-spin {
  background: linear-gradient(135deg, var(--gold), #FFB300);
  color: #1a1400;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 16px 40px;
  border-radius: 999px;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
  transition: transform 0.15s ease;
}

.btn-spin:hover {
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--white);
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
}

.btn-secondary:hover {
  border-color: var(--gold);
}

/* ---------- Sidebar ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 16px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.panel h3 {
  font-size: 0.95rem;
  color: var(--gold);
  margin-bottom: 10px;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-list li {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  border-left: 3px solid var(--gold);
}

.history-list li.empty {
  border-left-color: transparent;
  color: var(--text-muted);
  text-align: center;
}

.panel.actions {
  display: flex;
  justify-content: center;
}

/* ---------- Overlays (loading / setup) ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(15, 15, 26, 0.92);
  text-align: center;
  padding: 24px;
}

.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid rgba(255, 215, 0, 0.2);
  border-top-color: var(--gold);
  animation: spin-loader 0.9s linear infinite;
}

@keyframes spin-loader {
  to { transform: rotate(360deg); }
}

.setup-card {
  max-width: 440px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 28px;
  text-align: left;
}

.setup-card h2 {
  color: var(--gold);
  margin-bottom: 10px;
}

.login-card {
  width: min(90vw, 340px);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h2 {
  color: var(--gold);
}

.login-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: -6px 0 4px;
}

.login-card input {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--white);
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
}

.login-card input:focus {
  outline: none;
  border-color: var(--gold);
}

.login-error {
  color: #FF8A5C;
  font-size: 0.85rem;
  margin: -6px 0 0;
}

.header-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.setup-card code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.setup-card ol {
  padding-left: 20px;
  line-height: 1.6;
}

/* ---------- Toast ---------- */

#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: rgba(20, 20, 34, 0.95);
  border: 1px solid var(--glass-border);
  border-left: 4px solid var(--gold);
  color: var(--white);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  max-width: 320px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.25s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast--success { border-left-color: var(--green-1); }
.toast--error { border-left-color: var(--red-1); }
.toast--warning { border-left-color: #FF8A5C; }
