:root {
  --bg: #333333;
  --surface: #3d3d3d;
  --text: #ffffff;
  --muted: #ffffff;
  --accent: #38bdf8;
  --accent-2: #38bdf8;
  --border: #4a4a4a;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

#app { max-width: 1280px; margin: 0 auto; padding: 16px; }

.panel {
  background: var(--surface); border-radius: var(--radius); padding: 16px 20px;
  border: 1px solid var(--border); margin-bottom: 16px;
}
.panel h2 { margin-top: 0; font-size: 1.1rem; color: var(--accent); }

.hint { color: var(--muted); font-size: 0.85rem; opacity: .7; }
.rules { padding-left: 18px; font-size: 0.92rem; line-height: 1.5; }

/* ===== Splash studio Edukisto ===== */
#studio-splash {
  position: fixed;
  inset: 0;
  background: #333333;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: splash-bg 2.6s ease forwards;
  pointer-events: none;
}
.splash-inner { text-align: center; }
.splash-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  font-size: 54px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #ffffff;
  animation: splash-logo 2.6s ease forwards;
  font-family: inherit;
}
.splash-star { width: 56px; height: 56px; filter: drop-shadow(0 0 14px rgba(56, 189, 248, 0.7)); }
.splash-sub {
  margin-top: 14px;
  font-size: 16px;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: #38bdf8;
  animation: splash-sub 2.6s ease forwards;
}
@keyframes splash-logo {
  0% { opacity: 0; transform: scale(0.86); letter-spacing: 24px; }
  25% { opacity: 1; transform: scale(1); letter-spacing: 14px; }
  75% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.05); }
}
@keyframes splash-sub {
  0%, 15% { opacity: 0; }
  35% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes splash-bg {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

/* ===== Header application (charte edukisto) ===== */
.app-header {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: #1c1c1c; color: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 18px; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.app-header .brand { display: flex; align-items: center; gap: 10px; font-size: 1.2em; font-weight: 800; }
.app-header .brand-logo svg { width: 26px; height: 26px; display: block; }
.app-header .brand-logo:hover svg { filter: drop-shadow(0 0 8px rgba(56,189,248,.5)); }
.brand-name span { color: var(--accent); }
.app-nav { margin-left: auto; display: flex; gap: 14px; }
.app-nav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem; }
.app-nav a:hover { color: var(--accent); }
.app-version { font-size: .72rem; opacity: .55; white-space: nowrap; }

/* ===== Footer (charte edukisto) ===== */
footer {
  text-align: center; padding: 1.6rem; margin-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: .9rem;
}
footer .small { font-size: .75rem; opacity: .7; margin-top: 6px; }
.credits .sig-line { opacity: .5; letter-spacing: -2px; vertical-align: middle; }

/* Setup */
.add-player { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.add-player input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font-size: 1rem;
}
#new-player-name { flex: 2; min-width: 140px; }
#new-player-age { flex: 1; min-width: 70px; }

button {
  padding: 8px 14px; border: none; border-radius: var(--radius);
  background: var(--accent); color: #0f172a; font-size: 1rem; cursor: pointer;
  font-weight: 600;
}
button:hover { filter: brightness(1.1); }
button:disabled { background: var(--border); color: #888; cursor: not-allowed; }
button.primary { font-size: 1.05rem; padding: 10px 18px; }

.player-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius);
}
.player-row.active { background: rgba(56, 189, 248, 0.12); }
.player-row .remove { background: none; color: #f87171; font-size: 1rem; padding: 0 4px; }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 1px solid var(--border); }
.group-tag { font-size: 0.78rem; background: var(--bg); padding: 2px 8px; border-radius: 999px; color: var(--muted); border: 1px solid var(--border); }

.theme-option { padding: 4px 0; }
.theme-option input { accent-color: var(--accent); }

/* Game layout */
#game-screen { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
#left-col { flex: 0 0 230px; min-width: 200px; max-width: 260px; order: 0; }
#board-wrap { flex: 2 1 380px; min-width: 340px; order: 1; }
#sidebar { flex: 0 0 320px; min-width: 300px; max-width: 360px; order: 2; }

#board { width: 100%; height: auto; border-radius: var(--radius); }
.cell { cursor: default; }
.cell.reachable { cursor: pointer; stroke: #fff !important; stroke-width: 3 !important; }
.cell.reachable { animation: pulse 1s infinite alternate; }
@keyframes pulse {
  from { opacity: 0.75; }
  to { opacity: 1; }
}
.wedge-cell polygon { stroke-width: 3; }
.cell-icon { font-size: 13px; pointer-events: none; user-select: none; }
.center-label { font-weight: bold; font-size: 14px; fill: #3a2c05; }
.center-sub { font-size: 10px; fill: #6b5312; }
.pawn-label { font-size: 9px; fill: #fff; font-weight: bold; pointer-events: none; }

/* Légende (colonne de gauche) — même corps que les questions */
#legend { font-size: 1.1rem; line-height: 1.5; }
#legend .legend-grid { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.legend-item .dot { width: 15px; height: 15px; }
#legend b { display: block; margin-top: 6px; color: var(--accent); font-size: 1.05rem; }

/* Camembert volant (du plateau vers l'emplacement du joueur) */
.flying-wedge {
  position: fixed;
  width: 30px; height: 30px;
  clip-path: polygon(50% 0, 100% 15%, 100% 85%, 50% 100%, 0 85%, 0 15%);
  z-index: 9998;
  pointer-events: none;
  box-shadow: 0 4px 10px rgba(0,0,0,.4);
}

/* Camembert display */
.camembert { display: flex; gap: 6px; margin: 10px 0; }
.wedge {
  width: 26px; height: 26px; display: inline-block;
  clip-path: polygon(50% 0, 100% 15%, 100% 85%, 50% 100%, 0 85%, 0 15%);
  border: 1px solid var(--border);
}

/* Questions */
#question-cat { margin-bottom: 6px; }
#question-text { font-size: 1.1rem; margin: 8px 0 14px; }
#answers { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.answer {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  text-align: left; line-height: 1.3; font-weight: 400;
}
.answer:hover:not(:disabled) { border-color: var(--accent); }
.answer.correct { background: #2a9d8f; color: #fff; border-color: #1f7d70; }
.answer.wrong { background: #e63946; color: #fff; border-color: #b02a35; }
.answer:disabled { cursor: default; }
#answer-feedback { font-weight: 600; min-height: 1.2em; margin-top: 10px; }

#dice-result { font-size: 1.05rem; font-weight: 600; margin-top: 10px; min-height: 1.4em; }

/* ===== Dé géant animé (points espacés) ===== */
.die { display: inline-block; vertical-align: middle; margin-right: 10px; }
.die-face {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 7px;
  width: 84px; height: 84px;
  padding: 13px;
  background: linear-gradient(145deg, #ffffff, #d8dde6);
  border-radius: 16px;
  border: 2px solid #9aa3b0;
  box-shadow: 0 5px 14px rgba(0,0,0,.4), inset 0 -4px 8px rgba(0,0,0,.12), inset 0 3px 6px #ffffff88;
}
.pip-slot { display: flex; align-items: center; justify-content: center; }
.pip {
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4a4f58, #14161a 70%);
  box-shadow: inset 0 -2px 3px rgba(0,0,0,.5), 0 1px 1px #ffffff55;
}
.die-tumble { animation: dice-tumble 0.45s linear infinite; display: grid; }
@keyframes dice-tumble {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(90deg) scale(1.12); }
  50% { transform: rotate(180deg) scale(0.96); }
  75% { transform: rotate(270deg) scale(1.08); }
  100% { transform: rotate(360deg) scale(1); }
}
.die-land { animation: dice-land 0.4s cubic-bezier(.2,1.4,.4,1); display: grid; }
@keyframes dice-land {
  0% { transform: scale(1.45) rotate(15deg); }
  55% { transform: scale(0.94) rotate(-4deg); }
  100% { transform: scale(1) rotate(0); }
}
.dice-info { font-size: 0.95rem; font-weight: 600; margin-left: 6px; vertical-align: middle; }
#dice-result { margin-top: 10px; min-height: 92px; display: flex; align-items: center; }

/* ===== Pions ===== */
.pawn-group { transition: transform 0.2s ease; }
.pawn-moving circle, .pawn-moving .pawn-emoji { animation: pawn-hop 0.3s ease; }
@keyframes pawn-hop {
  0% { transform: translateY(0); }
  45% { transform: translateY(-9px); }
  100% { transform: translateY(0); }
}
.pawn-emoji { font-size: 15px; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); }

/* Sélecteur de pion */
.pawn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin: 10px 0 6px; }
.pawn-choice {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 6px; border: 2px solid var(--border); border-radius: var(--radius);
  cursor: pointer; background: var(--bg); transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.pawn-choice:hover:not(.taken) { transform: translateY(-3px); border-color: var(--accent); }
.pawn-choice.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56,189,248,.25); }
.pawn-choice.taken { opacity: .38; cursor: not-allowed; filter: grayscale(.6); }
.pawn-choice-name { font-size: .72rem; text-align: center; }
.pawn-taken-label { font-size: .62rem; color: #f87171; }

/* Pion 2.5D du sélecteur : sphère avec reflet */
.pawn-mini {
  width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ffffffcc 0%, var(--pc) 55%, color-mix(in srgb, var(--pc) 60%, #000) 100%);
  border: 2px solid #1d1d1d;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 19px;
  box-shadow: 0 4px 8px rgba(0,0,0,.35), inset 0 -4px 8px rgba(0,0,0,.25);
}
.pawn-mini-inline { font-size: 1.05rem; margin-right: 2px; }
.pawn-tag { font-size: 0.74rem; background: var(--bg); padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--accent); }

.hidden { display: none !important; }

/* Win */
#win-screen .panel { text-align: center; padding: 40px 20px; }
#winner-name { font-size: 1.6rem; }

@media (max-width: 800px) {
  #answers { grid-template-columns: 1fr; }
}
