:root {
  --gold: #d4a017;
  --gold-light: #e8c547;
  --gold-dark: #b8860b;
  --brown: #4a2c1a;
  --brown-light: #6b4226;
  --brown-dark: #2c1810;
  --cream: #f5f0e8;
  --white: #ffffff;
  --text-light: rgba(255,255,255,0.8);
  --text-muted: rgba(255,255,255,0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--brown-dark);
  color: var(--white);
  min-height: 100vh;
  overflow-x: hidden;
}

.app {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  min-height: 100vh;
  animation: fadeIn 0.4s ease;
}

.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Accueil */
#screen-home { justify-content: center; text-align: center; }

.logo { margin-bottom: 32px; }
.logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin: 0 auto 16px;
  box-shadow: 0 8px 24px rgba(212,160,23,0.3);
}
.logo h1 { font-size: 24px; font-weight: 700; letter-spacing: 1px; }
.subtitle { font-size: 13px; opacity: 0.7; margin-top: 4px; }

.qr-section { margin-bottom: 32px; }
.qr-placeholder {
  width: 180px; height: 180px;
  background: var(--white);
  border-radius: 20px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  margin: 0 auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.qr-placeholder span { font-size: 48px; margin-bottom: 8px; }
.qr-placeholder p { color: var(--brown); font-size: 12px; font-weight: 500; text-align: center; }

.btn-primary {
  width: 100%; max-width: 280px;
  height: 52px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border: none; border-radius: 14px;
  color: var(--white); font-size: 16px; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(212,160,23,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(212,160,23,0.5); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.pulse { animation: pulse 2s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(212,160,23,0.4); }
  50% { box-shadow: 0 6px 30px rgba(212,160,23,0.7); }
}

.footer-info { margin-top: 24px; font-size: 11px; opacity: 0.4; }

/* Formulaire */
#screen-form { padding-top: 40px; }
.form-header { text-align: center; margin-bottom: 24px; }
.form-header .logo-icon.small { width: 40px; height: 40px; font-size: 20px; border-radius: 10px; }
.form-header h2 { margin-top: 12px; font-size: 20px; }

form { width: 100%; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; opacity: 0.8; margin-bottom: 5px; }
.form-group input {
  width: 100%; height: 46px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 0 14px;
  color: var(--white); font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--gold); }
.form-group input::placeholder { color: rgba(255,255,255,0.25); }

/* Roue */
#screen-wheel { padding-top: 40px; text-align: center; }
#screen-wheel h2 { font-size: 22px; margin-bottom: 4px; }

.wheel-container {
  position: relative;
  width: 280px; height: 280px;
  margin: 24px auto;
}
.pointer {
  position: absolute;
  top: -14px; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 20px solid #ff4444;
  z-index: 10;
}
#wheel {
  width: 100%; height: 100%;
  border-radius: 50%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.wheel-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 52px; height: 52px;
  background: var(--white);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--brown-dark); font-weight: 700; font-size: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 5;
}

.wheel-legend { display: flex; gap: 8px; justify-content: center; margin-bottom: 24px; flex-wrap: wrap; }
.badge {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px; font-weight: 500;
}
.badge.gold { background: rgba(212,160,23,0.2); color: var(--gold-light); }
.badge.silver { background: rgba(196,148,21,0.15); color: var(--gold); }
.badge.bronze { background: rgba(139,69,19,0.2); color: #c49415; }

/* Résultats */
#screen-win, #screen-loss { justify-content: center; text-align: center; }

.result-icon {
  width: 90px; height: 90px;
  background: rgba(212,160,23,0.15);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 42px;
  margin-bottom: 20px;
}
.win-title { color: var(--gold); font-size: 26px; margin-bottom: 8px; }
.win-prize {
  width: 180px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-radius: 18px;
  padding: 20px;
  margin: 16px auto;
}
.win-number { display: block; font-size: 36px; font-weight: 800; }
.win-label { font-size: 13px; }

.instruction { font-size: 13px; opacity: 0.7; margin-top: 8px; }
.ref { font-size: 11px; opacity: 0.4; margin-top: 4px; }
.validation-qr { margin-top: 20px; }
.mini-qr {
  width: 120px; height: 120px;
  background: var(--white);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--brown); font-size: 13px; font-weight: 600;
  margin: 0 auto;
}

/* Perdu */
#screen-loss h2 { font-size: 22px; margin-bottom: 4px; }
.draw-box {
  width: 220px;
  background: rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 18px;
  margin: 20px auto;
  border: 1px solid rgba(212,160,23,0.2);
}
.draw-box h3 { color: var(--gold); font-size: 15px; margin-bottom: 6px; }
.draw-box p { font-size: 12px; opacity: 0.8; }
.draw-info { font-size: 13px; opacity: 0.7; }
.draw-time { font-size: 12px; opacity: 0.5; margin-top: 4px; }
.footer-brand { margin-top: 32px; font-size: 11px; opacity: 0.3; }

/* Admin */
.admin-body { background: #f8f6f2; color: #333; }
.admin-header {
  background: linear-gradient(135deg, var(--brown-dark), var(--brown));
  color: var(--white);
  padding: 24px;
  border-radius: 0 0 20px 20px;
}
.admin-header h1 { font-size: 22px; margin-bottom: 4px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}
.stat-card {
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.stat-value { font-size: 24px; font-weight: 700; color: var(--gold-light); }
.stat-label { font-size: 11px; opacity: 0.7; margin-top: 4px; }

.admin-content { padding: 20px; }
.section-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; color: var(--brown-dark); }
.participants-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.participants-table th, .participants-table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid #e8e4dc; }
.participants-table th { font-weight: 600; color: var(--brown); font-size: 12px; }
.participants-table tr:hover { background: #f0ede6; }
.badge-admin { padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 500; }
.badge-admin.win { background: #d4edda; color: #155724; }
.badge-admin.draw { background: #fff3cd; color: #856404; }

.draw-section { margin-top: 24px; }
.draw-btn {
  width: 100%; height: 48px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border: none; border-radius: 12px;
  color: var(--white); font-size: 15px; font-weight: 600;
  cursor: pointer;
  margin-bottom: 16px;
}
.draw-winner {
  background: var(--white);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.draw-winner h3 { color: var(--gold); font-size: 18px; margin-bottom: 8px; }
.draw-winner p { font-size: 14px; margin-bottom: 4px; }

/* Login */
.login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, var(--brown-dark) 0%, var(--brown) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.login-box {
  background: var(--white);
  color: var(--brown-dark);
  border-radius: 20px;
  padding: 36px 28px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-box h2 { font-size: 20px; margin-bottom: 4px; }
.login-box .subtitle { font-size: 13px; color: #888; margin-bottom: 20px; }
.login-box input {
  width: 100%; height: 46px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 0 14px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.login-box input:focus { border-color: var(--gold); }

/* Winner QR on game */
.winner-qr-section { margin: 20px 0; text-align: center; }
.winner-qr-section .qr-instruction { font-size: 13px; color: #666; margin-bottom: 12px; }
.winner-qr { display: inline-block; padding: 12px; background: #fff; border-radius: 16px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); }

/* Admin tabs */
.admin-tabs { display: flex; gap: 8px; padding: 16px 20px 0; background: #f5f0e8; border-bottom: 1px solid #e0dcd4; }
.tab-btn {
  padding: 10px 16px; border: none; background: transparent;
  color: #888; font-size: 13px; font-weight: 500; cursor: pointer;
  border-radius: 8px 8px 0 0; border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab-btn.active { color: var(--brown-dark); border-bottom-color: var(--gold); background: var(--white); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* QR Scanner */
.qr-scan-section { text-align: center; margin-bottom: 32px; }
.qr-hint { font-size: 13px; color: #888; margin-bottom: 12px; }
.scanner-container {
  position: relative; max-width: 400px; margin: 0 auto;
  background: #000; border-radius: 16px; overflow: hidden;
}
.scanner-container video { width: 100%; height: auto; display: block; }
.scanner-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.scanner-frame {
  width: 200px; height: 200px;
  border: 3px solid var(--gold); border-radius: 12px;
  box-shadow: 0 0 0 999px rgba(0,0,0,0.5);
}
.scanner-controls { margin-top: 16px; }
.manual-validation { margin-top: 32px; padding-top: 24px; border-top: 1px solid #e0dcd4; }

/* Validation results */
.qr-result { margin-top: 20px; }
.validation-success {
  background: #d4edda; color: #155724; border-radius: 14px;
  padding: 24px; text-align: center;
}
.validation-error {
  background: #f8d7da; color: #721c24; border-radius: 14px;
  padding: 24px; text-align: center;
}
.validation-icon { font-size: 36px; margin-bottom: 8px; }
.validation-success h3, .validation-error h3 { font-size: 16px; margin-bottom: 8px; }
.validation-prize {
  display: inline-block; margin-top: 12px;
  background: var(--gold); color: #fff;
  padding: 8px 20px; border-radius: 20px;
  font-size: 16px; font-weight: 600;
}
