/* ============================================
   WHEEL TYCOON — Style principal
   Thème : coloré, fun, cartoon, responsive
   ============================================ */

:root {
  --bg: #020617;
  --surface: #0f172a;
  --surface2: #1e293b;
  --primary: #eab308;
  --primary-light: #fbbf24;
  --accent: #38bdf8;
  --accent2: #6366f1;
  --gold: #facc15;
  --green: #22c55e;
  --orange: #fb923c;
  --text: #f9fafb;
  --text-muted: #9ca3af;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.7);
  --shadow-hover: 0 22px 55px rgba(0, 0, 0, 0.85);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,215,0,0.08), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(56,189,248,0.08), transparent 45%),
    linear-gradient(135deg, #0f172a, #020617);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app-layout {
  display: flex;
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  gap: 20px;
}

.sidebar {
  width: 260px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(24px);
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  padding: 20px 18px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.sidebar-logo-mark {
  font-size: 1.7rem;
}

.sidebar-logo-text .title {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.sidebar-logo-text .subtitle {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.sidebar a {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 2px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
}

.sidebar a:hover {
  background: rgba(250, 204, 21, 0.12);
  transform: translateX(4px);
  color: var(--text);
}

.sidebar a.active {
  background: linear-gradient(135deg,#facc15,#fb923c);
  color: #111827;
  box-shadow: 0 12px 30px rgba(250, 204, 21, 0.35);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.view {
  display: none;
}

.view.view-active {
  display: block;
}

/* ----- Header / Dashboard ----- */
.header {
  background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.06), transparent 55%),
              linear-gradient(145deg, rgba(15, 23, 42, 0.96), rgba(15,23,42,0.9));
  border-radius: 24px;
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.header h1 {
  font-size: 1.4rem;
  margin-bottom: 1.1rem;
  color: var(--text);
}

.resources {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.resource {
  background: rgba(15, 23, 42, 0.8);
  padding: 12px 14px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  min-width: 140px;
  border: 1px solid rgba(148,163,184,0.25);
}

.resource .label {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.resource .value {
  color: var(--accent);
  font-size: 1.15rem;
}

.resource .sub,
.resource .rate {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.resource[data-resource="cash"] .value { color: var(--green); }
.resource[data-resource="reputation"] .value { color: var(--accent2); }
.resource[data-resource="hype"] .value { color: var(--orange); }

.multipliers {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 24px;
}

.multiplier-badge {
  background: rgba(99, 102, 241, 0.35);
  color: var(--text);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.85; transform: translateY(-1px); }
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stat-card {
  background: rgba(15,23,42,0.85);
  backdrop-filter: blur(15px);
  border-radius: 20px;
  padding: 20px 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(148,163,184,0.45);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.stat-card h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.stat-main {
  font-size: 1.6rem;
  font-weight: 700;
}

.stat-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ----- Sections communes ----- */
.section {
  background: radial-gradient(circle at 0 0, rgba(15,23,42,0.9), transparent 55%),
              linear-gradient(145deg, rgba(15,23,42,0.96), rgba(15,23,42,0.92));
  border-radius: 24px;
  padding: 18px 20px;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
}

.section h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--primary-light);
}

/* ----- Spin levels ----- */
.spin-levels {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.spin-level-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, background 0.2s, box-shadow 0.2s;
}

.spin-level-btn:hover {
  background: var(--surface2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.spin-level-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 16px rgba(250, 204, 21, 0.4);
}

.spin-level-btn.locked {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ----- Grille roues ----- */
.wheels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.wheel-card {
  background: rgba(15,23,42,0.9);
  border-radius: 20px;
  padding: 1rem;
  border: 1px solid rgba(148,163,184,0.4);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.wheel-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.wheel-card.unlocked {
  border-color: rgba(250, 204, 21, 0.6);
}

.wheel-card.locked {
  opacity: 0.92;
  border-color: rgba(255, 255, 255, 0.15);
}

.wheel-card .wheel-name {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.wheel-card-visual {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 0.75rem;
}

.wheel-card-canvas {
  display: block;
  width: 140px;
  height: 140px;
  max-width: 100%;
  border-radius: 50%;
  background: #2a2a4a;
}

.wheel-card-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 50%;
  pointer-events: none;
}

.wheel-card .wheel-cost {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.wheel-card .btn-spin {
  width: 100%;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
}

.wheel-card.unlocked .btn-spin {
  background: linear-gradient(145deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
}

.wheel-card.unlocked .btn-spin:hover:not(:disabled) {
  transform: scale(1.02);
  box-shadow: 0 6px 20px rgba(233, 69, 96, 0.4);
}

.wheel-card .btn-spin:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.wheel-card.locked .btn-spin:disabled {
  background: var(--surface2);
  color: var(--text-muted);
  cursor: not-allowed;
}

.wheel-card.locked .btn-spin:not(:disabled) {
  background: linear-gradient(145deg, var(--gold) 0%, var(--orange) 100%);
  color: #1a1a2e;
  cursor: pointer;
}

/* ----- Projets / Économie ----- */
.project-card {
  border-radius: 18px;
  background: rgba(15,23,42,0.9);
  padding: 20px;
  border: 1px solid rgba(148,163,184,0.35);
  transition: all 0.2s ease;
}

.project-card:hover {
  box-shadow: 0 15px 30px rgba(250,204,21,0.35);
}

.progress-bar {
  height: 8px;
  border-radius: 10px;
  background: rgba(148,163,184,0.25);
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg,#facc15,#fb923c);
  width: 0%;
  transition: width 0.5s ease;
}

.economy-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr);
  gap: 16px;
}

.economy-chart-card canvas {
  width: 100%;
  height: 260px;
}

.economy-metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.economy-metrics .metric {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.economy-metrics .metric .label {
  color: var(--text-muted);
}

.economy-metrics .metric .value {
  font-weight: 600;
}

.glow {
  animation: glowPulse 3s infinite;
}

@keyframes glowPulse {
  0%,100% { box-shadow: 0 0 10px rgba(250,204,21,0.25); }
  50% { box-shadow: 0 0 26px rgba(250,204,21,0.55); }
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(15,23,42,0.95);
  border-radius: 999px;
  border: 1px solid rgba(248,250,252,0.2);
  padding: 10px 16px;
  font-size: 0.85rem;
  color: var(--text);
  box-shadow: 0 18px 45px rgba(0,0,0,0.7);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.25s ease;
  z-index: 2000;
}

.toast.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.wheel-unlock {
  font-size: 0.85rem;
  color: var(--gold);
  margin-top: 0.5rem;
}

/* ----- Upgrades ----- */
.upgrades-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.tab-btn:hover {
  background: var(--surface2);
  transform: translateY(-1px);
}

.tab-btn.active {
  background: var(--accent2);
  color: white;
}

.upgrades-content {
  display: grid;
  gap: 0.75rem;
}

.upgrade-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent);
}

.upgrade-item.owned {
  border-left-color: var(--green);
  opacity: 0.85;
}

.upgrade-item .upgrade-info strong {
  display: block;
  margin-bottom: 0.25rem;
}

.upgrade-item .upgrade-info span {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.upgrade-item .btn-buy {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--green);
  color: #1a1a2e;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
}

.upgrade-item .btn-buy:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(107, 203, 119, 0.4);
}

.upgrade-item .btn-buy:disabled {
  background: var(--surface2);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ----- Événements ----- */
.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.event-card {
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius);
  padding: 1rem;
  border: 2px solid rgba(255, 217, 61, 0.3);
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.event-card:hover:not(.cooldown) .btn-event {
  transform: scale(1.05);
}

.event-card.cooldown {
  opacity: 0.6;
}

.event-card .event-name {
  font-weight: 800;
  margin-bottom: 0.35rem;
  color: var(--gold);
}

.event-card .event-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.event-card .event-cost {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.event-card .event-timer {
  font-size: 0.8rem;
  color: var(--accent);
  margin-top: 0.5rem;
}

.btn-event {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, var(--gold) 0%, var(--orange) 100%);
  color: #1a1a2e;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
}

.btn-event:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(255, 159, 67, 0.4);
}

.btn-event:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ----- Modal roue animée ----- */
.wheel-modal {
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease-out;
}

.wheel-modal.wheel-modal--open {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.85);
}

.wheel-modal .wheel-modal-content {
  background: linear-gradient(145deg, var(--surface) 0%, var(--surface2) 100%);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 2px solid var(--primary);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.wheel-modal #wheelCanvas {
  display: block;
  width: 280px;
  height: 280px;
  min-width: 280px;
  min-height: 280px;
  max-width: 95vw;
  border-radius: 50%;
  background: #2a2a4a;
}

.wheel-modal-label {
  font-weight: 700;
  color: var(--gold);
}

/* ----- Popup résultats ----- */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}

.popup-overlay[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
}

.popup {
  background: linear-gradient(145deg, var(--surface) 0%, var(--surface2) 100%);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 90vw;
  max-height: 85vh;
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  border: 2px solid var(--primary);
  animation: popIn 0.3s ease-out;
}

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

.popup h3 {
  margin-bottom: 1rem;
  color: var(--gold);
}

.popup-body {
  margin-bottom: 1rem;
  line-height: 1.7;
}

.popup-body .result-line {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.popup-body .mega-jackpot {
  background: linear-gradient(90deg, var(--gold), var(--orange));
  color: #1a1a2e;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 800;
  margin-top: 0.75rem;
  text-align: center;
}

.btn-close {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.btn-close:hover {
  background: var(--primary-light);
  transform: scale(1.02);
}

/* ----- Boutons génériques ----- */
.btn {
  font-family: inherit;
}

/* ----- Responsive ----- */
@media (max-width: 600px) {
  .app-layout {
    flex-direction: column;
    padding: 10px;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 18px;
  }

  .sidebar-nav {
    flex-direction: row;
    gap: 4px;
  }

  .sidebar a {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .resources {
    flex-direction: column;
  }

  .resource {
    min-width: 100%;
  }

  .wheels-grid {
    grid-template-columns: 1fr;
  }

  .section {
    padding: 1rem;
  }

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