:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --border: #e5e7eb;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

header.topbar a.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

header.topbar nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.9rem;
}

header.topbar nav span.pseudo {
  color: var(--muted);
}

.nav-menu {
  position: relative;
}
.nav-menu summary {
  list-style: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
}
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu summary:hover { background: var(--bg); }
.nav-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 10;
}
.nav-menu-dropdown a,
.nav-menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  background: none;
  margin: 0;
  font-size: 0.9rem;
  font-weight: 400;
}
.nav-menu-dropdown a:hover,
.nav-menu-dropdown button:hover {
  background: var(--bg);
}

main {
  max-width: 1000px;
  margin: 32px auto;
  padding: 0 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

h1 { font-size: 1.5rem; margin-top: 0; }
h2 { font-size: 1.15rem; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  margin-top: 12px;
}

input[type="text"], input[type="email"], input[type="password"], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}

textarea { resize: vertical; min-height: 120px; }

button, .btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  margin-top: 14px;
}

button:hover, .btn:hover { background: var(--primary-dark); }

button.danger, .btn.danger { background: var(--danger); }
button.danger:hover, .btn.danger:hover { background: #b91c1c; }

button.secondary, .btn.secondary { background: #e5e7eb; color: var(--text); }
button.secondary:hover, .btn.secondary:hover { background: #d1d5db; }

.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--muted); font-weight: 600; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.list-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-item .actions form { display: inline; }
.list-item .actions button { margin-top: 0; padding: 6px 12px; font-size: 0.8rem; }

.muted { color: var(--muted); font-size: 0.85rem; }

form.inline { display: inline-flex; gap: 6px; align-items: center; }

.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }

.class-tile {
  position: relative;
  background: var(--tile-bg, var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow 150ms ease, transform 150ms ease, opacity 150ms ease;
  cursor: grab;
}
.class-tile:hover { box-shadow: 0 8px 20px rgba(15, 23, 42, 0.1); transform: translateY(-2px); }
.class-tile.dragging { opacity: 0.4; cursor: grabbing; }

.class-tile-toolbar {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  z-index: 1;
}
.class-tile-handle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  font-size: 0.9rem;
}

.class-tile-link {
  display: block;
  padding: 40px 18px 20px;
  color: inherit;
  text-decoration: none;
}
.class-tile-link h3 { margin: 0 0 4px; }

.class-tile-gear {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
}
.class-tile-gear:hover { background: var(--bg); color: var(--text); }

.create-class { margin-bottom: 18px; }
.create-class summary {
  display: inline-block;
  cursor: pointer;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  list-style: none;
}
.create-class summary::-webkit-details-marker { display: none; }
.create-class summary:hover { text-decoration: underline; }
.create-class[open] summary { margin-bottom: 10px; }
.create-class form {
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: 320px;
}
.create-class form input { margin: 0; }
.create-class form button { margin: 0; padding: 10px 16px; }

/* Sélecteur de classes (page roue) */
.class-switcher {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.class-pill {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}
.class-pill:hover { border-color: var(--primary); }
.class-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Roue */
.roue-wrap { display: flex; flex-direction: column; align-items: center; gap: 28px; }

.roue-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 44px;
  flex-wrap: wrap;
  width: 100%;
  align-self: stretch;
}

.roue-stage {
  position: relative;
  width: min(560px, 88vw);
  aspect-ratio: 1 / 1;
}

.roue-3d {
  position: relative;
  width: 100%;
  height: 100%;
}

.roue-shadow {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: -16px;
  height: 26px;
  background: radial-gradient(ellipse at center, rgba(15, 23, 42, 0.45) 0%, rgba(15, 23, 42, 0) 70%);
  filter: blur(2px);
}

#roueCanvas {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  filter: drop-shadow(0 22px 24px rgba(15, 23, 42, 0.35));
}

.roue-shine {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(ellipse at 32% 22%, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.14) 28%, rgba(255, 255, 255, 0) 55%);
  pointer-events: none;
}

.roue-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15%;
  height: 15%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #cbd5e1 45%, #64748b 100%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), inset 0 -2px 4px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.pointer-3d {
  position: absolute;
  top: 50%;
  right: -14px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 16px solid transparent;
  border-bottom: 16px solid transparent;
  border-right: 28px solid #facc15;
  filter: drop-shadow(2px 3px 4px rgba(0, 0, 0, 0.45));
  z-index: 2;
}

.roue-side {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: min(320px, 100%);
  position: sticky;
  top: 20px;
  align-self: flex-start;
}

.resultat-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 28px 26px;
  border-radius: 16px;
  background: linear-gradient(155deg, var(--card), #f1f5f9);
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  opacity: 0;
  transform: translateX(36px) scale(0.92);
  transition: opacity 320ms ease, transform 320ms ease;
}

.resultat-panel.reveal {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.resultat-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.resultat-name {
  display: inline-block;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  line-height: 1.15;
  min-height: 1.3em;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.resultat-panel.reveal .resultat-name {
  animation: resultat-pop 550ms cubic-bezier(0.22, 0.8, 0.28, 1) both;
}

@keyframes resultat-pop {
  0%   { opacity: 0; transform: translateY(10px) scale(0.85); }
  60%  { opacity: 1; transform: translateY(-4px) scale(1.06); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.classement-panel {
  padding: 18px 20px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.classement-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.classement-scroll {
  max-height: 380px;
  overflow-y: auto;
}

.classement-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.classement-table thead th {
  position: sticky;
  top: 0;
  background: var(--card);
}
.classement-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 4px 8px;
  border-bottom: 1px solid var(--border);
}
.classement-table td {
  padding: 7px 4px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.classement-table tbody tr:last-child td { border-bottom: none; }
.classement-table tbody tr.classement-updated { animation: classement-flash 900ms ease; }

@keyframes classement-flash {
  0%   { background: rgba(37, 99, 235, 0.18); }
  100% { background: transparent; }
}

.classement-rank { color: var(--muted); width: 1.6em; }
.classement-name { font-weight: 600; }
.classement-count { text-align: center; font-weight: 700; width: 2.4em; }

.classement-actions { display: flex; gap: 4px; white-space: nowrap; }
.classement-actions form { display: inline; }
.classement-actions button {
  margin: 0;
  padding: 0;
  width: 22px;
  height: 22px;
  line-height: 1;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
}
.classement-actions button:hover { background: var(--border); }

.roue-controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

@media (max-width: 720px) {
  .roue-layout { flex-direction: column; }
  .roue-side { width: 100%; max-width: 420px; }
  .resultat-panel { align-items: center; text-align: center; }
}
