:root {
  --red: #e1261c;
  --red-dark: #9e120c;
  --blue: #1d4fc4;
  --blue-dark: #0d2a78;
  --yellow: #ffd21a;
  --yellow-2: #ffb300;
  --green: #1fae3b;
  --grey: #c0c0c0;
  --ink: #1a1a2e;
  --comic: 'Comic Neue', 'Comic Sans MS', 'Chalkboard SE', cursive;
  --fat: 'Luckiest Guy', Impact, 'Arial Black', sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--comic);
  color: var(--ink);
  background: var(--yellow);
  overflow-x: hidden;
}

/* Fond "boîte de jeu" : rayons jaunes */
.sunburst {
  position: fixed; inset: -50%;
  z-index: -1;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,220,.9) 0, rgba(255,240,120,.35) 22%, transparent 55%),
    repeating-conic-gradient(from 0deg at 50% 50%, #ffd21a 0deg 9deg, #ffc400 9deg 18deg);
  animation: spin 120s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Barre du haut ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(#0000a8, #000070);
  color: #fff; font-family: 'Courier New', monospace; font-weight: bold;
  border-bottom: 3px ridge #8080ff;
  padding: 4px 8px;
}
.topbar marquee { flex: 1; color: #ffff66; }

.screen { display: none; padding: 16px; max-width: 1100px; margin: 0 auto; }
.screen.active { display: block; animation: pop .35s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.hidden { display: none !important; }

/* ---------- Logo ---------- */
.logo-wrap { text-align: center; margin-top: 8px; }
.logo { width: min(620px, 100%); height: auto; filter: drop-shadow(6px 8px 0 rgba(0,0,0,.35)); }
.logo text { font-family: var(--fat); stroke-linejoin: round; }
.logo-blue { fill: var(--blue); stroke: var(--blue); stroke-width: 34px; }
.logo-white { fill: #fff; stroke: #fff; stroke-width: 16px; }
.logo-red { fill: var(--red); stroke: var(--red-dark); stroke-width: 2px; }
.logo-wrap .logo { animation: wobble 3s ease-in-out infinite; }
@keyframes wobble { 50% { transform: rotate(1.5deg) scale(1.02); } }

.tagline {
  font-family: var(--fat); color: var(--blue); font-size: clamp(20px, 4vw, 34px);
  margin: -6px 0 18px; letter-spacing: 1px;
  text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff, 4px 5px 0 rgba(0,0,0,.25);
}

/* ---------- Boutons "bulle Photoshop" ---------- */
.bubble-btn {
  --c1: #ff6a5a; --c2: var(--red); --c3: var(--red-dark);
  position: relative;
  font-family: var(--fat); font-size: 22px; letter-spacing: 1px;
  color: #fff; text-shadow: 2px 2px 0 rgba(0,0,0,.45);
  padding: 14px 30px 12px;
  border: 4px outset var(--c1);
  border-radius: 40px;
  background: radial-gradient(ellipse at 50% 20%, var(--c1) 0, var(--c2) 55%, var(--c3) 100%);
  box-shadow: 0 6px 0 var(--c3), 0 10px 14px rgba(0,0,0,.4), inset 0 -6px 10px rgba(0,0,0,.25);
  cursor: pointer;
  transition: transform .08s;
}
.bubble-btn::before { /* reflet vitreux */
  content: ''; position: absolute; left: 12%; right: 12%; top: 4px; height: 42%;
  border-radius: 40px;
  background: linear-gradient(rgba(255,255,255,.85), rgba(255,255,255,.05));
  pointer-events: none;
}
.bubble-btn:hover { filter: brightness(1.1) saturate(1.2); }
.bubble-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--c3), 0 3px 6px rgba(0,0,0,.4); border-style: inset; }
.bubble-btn:disabled { filter: grayscale(1) opacity(.6); cursor: not-allowed; }
.bubble-btn.blue { --c1: #6a9bff; --c2: var(--blue); --c3: var(--blue-dark); }
.bubble-btn.big { font-size: clamp(26px, 5vw, 40px); padding: 20px 44px 16px; }

.mini-btn {
  font-family: 'MS Sans Serif', Tahoma, sans-serif; font-size: 13px;
  background: var(--grey); color: #000;
  border: 2px outset #fff; padding: 4px 10px; cursor: pointer;
}
.mini-btn:active { border-style: inset; }

.home-buttons { display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; margin: 12px 0 26px; }

/* ---------- Fenêtres Windows 95 ---------- */
.win95 {
  background: var(--grey);
  border: 3px outset #fff;
  box-shadow: 6px 6px 0 rgba(0,0,0,.35);
  max-width: 680px; margin: 0 auto;
}
.win-title {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(90deg, #000080, #1084d0);
  color: #fff; font-family: Tahoma, sans-serif; font-weight: bold; font-size: 14px;
  padding: 3px 4px 3px 8px;
}
.win-x { background: var(--grey); color: #000; border: 2px outset #fff; padding: 0 5px; font-size: 12px; cursor: pointer; }
.win-body { padding: 14px 18px; font-size: 17px; }
.win-body p { margin: 6px 0; }

blink, .blink { animation: blink 1s steps(1) infinite; color: var(--red); font-weight: bold; }
@keyframes blink { 50% { visibility: hidden; } }

.retro-footer {
  margin-top: 26px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-family: 'Times New Roman', serif; font-size: 14px;
}
.retro-footer a { color: #0000ee; }
.construction {
  background: repeating-linear-gradient(45deg, #000 0 12px, #ffd21a 12px 24px);
  color: #fff; font-weight: bold; padding: 4px 12px; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
}
.counter b {
  font-family: 'Courier New', monospace; background: #000; color: #39ff14;
  padding: 1px 6px; letter-spacing: 3px; border: 2px inset #666;
}

/* ---------- HUD ---------- */
.hud { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.hud-box {
  font-family: var(--fat); font-size: 20px; color: #fff;
  background: linear-gradient(var(--blue), var(--blue-dark));
  border: 3px outset #6a9bff; border-radius: 12px;
  padding: 8px 14px; white-space: nowrap; text-shadow: 2px 2px 0 #000;
}
.timer-wrap { flex: 1; display: flex; align-items: center; gap: 10px; }
.timer-bar {
  flex: 1; height: 26px; border: 3px inset #888; background: #222; border-radius: 14px; overflow: hidden;
}
#timer-fill {
  height: 100%; width: 100%;
  background: repeating-linear-gradient(45deg, #39d353 0 14px, #2ab443 14px 28px);
  transition: width .25s linear, background .3s;
}
#timer-fill.warn { background: repeating-linear-gradient(45deg, #ffb300 0 14px, #ff9000 14px 28px); }
#timer-fill.danger { background: repeating-linear-gradient(45deg, #ff3b30 0 14px, #c8160c 14px 28px); }
.timer-num {
  font-family: var(--fat); font-size: 34px; width: 64px; text-align: center; color: var(--red);
  text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff;
}
.timer-num.danger { animation: shake .3s infinite; }
@keyframes shake { 25% { transform: translate(-2px, 1px) rotate(-4deg); } 75% { transform: translate(2px, -1px) rotate(4deg); } }

/* ---------- Citation ---------- */
.quote-card {
  position: relative;
  background: #fff;
  border: 5px solid var(--blue);
  outline: 4px solid #fff;
  border-radius: 26px;
  box-shadow: 0 0 0 9px var(--red), 8px 12px 0 9px rgba(0,0,0,.3);
  padding: 20px 26px 16px 70px;
  margin: 10px 10px 26px;
  min-height: 110px;
}
.quote-mark {
  position: absolute; left: 12px; top: -8px;
  font-family: Georgia, serif; font-size: 110px; color: var(--red); line-height: 1;
}
.quote-lines { font-size: clamp(18px, 2.4vw, 24px); font-weight: bold; }
.q-line { margin: 4px 0; display: flex; gap: 10px; align-items: baseline; }
.q-who {
  flex-shrink: 0; font-family: var(--fat); font-weight: normal; font-size: .85em;
  background: var(--yellow); border: 2px solid var(--ink); border-radius: 8px; padding: 1px 8px;
}
.q-who.revealed { background: var(--green); color: #fff; }
.q-context { font-style: italic; font-weight: normal; color: #555; font-size: .8em; }
.quote-hint { margin-top: 8px; font-size: 15px; color: var(--blue); font-weight: bold; }

/* ---------- Plateau façon plastique ---------- */
.board {
  background: linear-gradient(#3d6fe0, var(--blue) 40%, var(--blue-dark));
  border-radius: 28px 28px 40px 40px;
  padding: 18px 16px 26px;
  border: 4px outset #6a9bff;
  box-shadow: inset 0 8px 16px rgba(255,255,255,.35), inset 0 -10px 18px rgba(0,0,0,.35), 0 14px 0 #0a1f5c, 0 20px 24px rgba(0,0,0,.4);
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px 12px; }

.card {
  position: relative; cursor: pointer; perspective: 600px;
  background: none; border: 0; padding: 0; font: inherit;
}
.card-inner {
  position: relative;
  background: #fff; border: 3px solid #fff; border-radius: 8px 8px 4px 4px;
  box-shadow: 0 6px 0 #0a1f5c, 0 0 0 2px #0a1f5c;
  overflow: hidden;
  transition: transform .35s, box-shadow .15s;
  transform-origin: bottom center;
}
.card .avatar-svg { display: block; width: 100%; height: auto; }
.card-name {
  display: block; background: #1f6f5c; color: #fff; text-align: center;
  font-family: var(--fat); font-size: 13px; letter-spacing: 0; padding: 4px 2px 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card:hover .card-inner { transform: translateY(-4px) rotate(-1deg); }
.card.selected .card-inner {
  box-shadow: 0 0 0 5px var(--yellow), 0 0 22px 8px #fff200, 0 6px 0 #0a1f5c;
  transform: translateY(-6px) scale(1.04);
}
.card.selected::after {
  content: '★'; position: absolute; top: -12px; right: -8px; z-index: 2;
  font-size: 34px; color: var(--yellow); -webkit-text-stroke: 2px var(--red);
}
.card.locked { cursor: default; }
.card.locked:hover .card-inner { transform: none; }

.card .stamp {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  font-family: var(--fat); font-size: 54px; color: #fff; text-shadow: 3px 3px 0 rgba(0,0,0,.4);
}
.card.good .card-inner { box-shadow: 0 0 0 6px var(--green), 0 0 24px 8px #7dff8e; }
.card.good .stamp { display: flex; background: rgba(31,174,59,.45); }
.card.bad .card-inner { box-shadow: 0 0 0 6px var(--red), 0 0 24px 8px #ff6a5a; }
.card.bad .stamp { display: flex; background: rgba(225,38,28,.55); }
.card.missed .card-inner { box-shadow: 0 0 0 6px var(--green); animation: pulse .7s ease-in-out 3; }
.card.missed .stamp { display: flex; background: rgba(31,174,59,.35); }
.card.dim .card-inner { transform: rotateX(70deg); filter: brightness(.6); }
@keyframes pulse { 50% { transform: scale(1.08); } }

.game-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 18px; margin: 28px 0 8px; }
.verdict { font-family: var(--fat); font-size: 30px; min-height: 36px; }
.verdict.ok { color: var(--green); text-shadow: 2px 2px 0 #fff; }
.verdict.ko { color: var(--red); text-shadow: 2px 2px 0 #fff; }
.verdict.mid { color: var(--blue); text-shadow: 2px 2px 0 #fff; }
.quit { display: block; margin: 16px auto 0; }

/* ---------- Écran de fin ---------- */
.end-win { max-width: 760px; }
.end-body { text-align: center; }
.final-score {
  font-family: var(--fat); font-size: 110px; line-height: 1; color: var(--red);
  text-shadow: 4px 4px 0 #fff, 8px 8px 0 var(--blue);
}
.final-score small { font-size: 46px; color: var(--blue); text-shadow: 3px 3px 0 #fff; }
.end-face { font-size: 70px; }
#end-title { font-family: var(--fat); font-weight: normal; font-size: 34px; margin: 6px 0; color: var(--blue); }
#end-text { font-size: 19px; }
.end-body.shame { animation: rage .12s infinite; background: repeating-linear-gradient(45deg, #ffdede 0 20px, #fff 20px 40px); }
.end-body.shame #end-title { color: var(--red); animation: blink .6s steps(1) infinite; }
@keyframes rage { 50% { transform: translateX(2px); } }
.end-recap { text-align: left; max-height: 260px; overflow: auto; background: #fff; border: 2px inset #fff; padding: 8px; font-size: 14px; margin: 12px 0; }
.end-recap div { padding: 3px 0; border-bottom: 1px dotted #aaa; }
.end-recap .r-ok { color: var(--green); font-weight: bold; }
.end-recap .r-ko { color: var(--red); font-weight: bold; }

/* ---------- Réglages ---------- */
.settings-win { max-width: 900px; }
.settings-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 10px; }
.settings-row label { font-weight: bold; }
.settings-row input[type=number] { width: 70px; font-size: 16px; border: 2px inset #fff; margin-left: 6px; }
.settings-row input[type=search] { flex: 1; min-width: 200px; font-size: 16px; padding: 4px; border: 2px inset #fff; }
.settings-count { font-weight: bold; color: var(--blue); }
.pie-box { border: 2px groove #fff; margin: 0 0 12px; padding: 8px 12px 12px; }
.pie-box legend { font-weight: bold; padding: 0 6px; }
.pie-wrap { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
.pie-svg { width: 230px; height: 230px; flex-shrink: 0; filter: drop-shadow(4px 5px 0 rgba(0,0,0,.3)); }
.pie-svg path { stroke: #fff; stroke-width: 2; cursor: default; transition: transform .15s; transform-origin: 100px 100px; }
.pie-svg path:hover { transform: scale(1.05); }
.pie-legend { flex: 1; min-width: 200px; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 3px 18px; font-size: 15px; }
.pie-legend .row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; }
.pie-legend .sw { width: 14px; height: 14px; border: 1px solid #000; }
.pie-legend .n { text-align: right; font-family: 'Courier New', monospace; }
.pie-legend .pc { text-align: right; font-weight: bold; font-family: 'Courier New', monospace; }
.pie-detail { flex-basis: 100%; font-size: 14px; }
.pie-detail table { border-collapse: collapse; background: #fff; border: 2px inset #fff; margin-top: 6px; }
.pie-detail td { padding: 2px 10px; border-bottom: 1px dotted #aaa; }
.pie-detail td:not(:first-child) { text-align: right; font-family: 'Courier New', monospace; }
.set-list { background: #fff; border: 2px inset #fff; max-height: 55vh; overflow: auto; }
.set-block { border-bottom: 1px dotted #999; }
.set-item { display: flex; gap: 10px; padding: 8px 10px; cursor: pointer; align-items: flex-start; }
.set-item:hover { background: #ffffcc; }
.set-item input { margin-top: 5px; transform: scale(1.3); }
.set-item.off { opacity: .45; text-decoration: line-through; }
.set-item .who { font-size: 13px; color: var(--blue); font-weight: bold; }
.set-item .txt { font-size: 15px; }
.editor { background: #ffffe0; border: 2px inset #fff; margin: 0 10px 10px 40px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.ed-line { display: flex; gap: 6px; flex-wrap: wrap; }
.ed-who { min-width: 150px; font-size: 15px; }
.ed-text, .ed-ctx { flex: 1; min-width: 0; width: 100%; font-size: 15px; padding: 3px; border: 2px inset #fff; box-sizing: border-box; }
.ed-text { width: auto; min-width: 200px; }
.ed-actions { display: flex; gap: 6px; }
.settings-footer { display: flex; gap: 14px; justify-content: flex-end; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.set-status { flex: 1; font-weight: bold; }

@media (max-width: 640px) {
  .screen { padding: 12px 16px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px 8px; }
  .card-name { font-size: 13px; }
  .quote-card { padding: 18px 16px 14px 46px; }
  .quote-mark { font-size: 76px; left: 6px; }
  .hud-box { font-size: 15px; padding: 6px 8px; }
  .timer-num { font-size: 26px; width: 44px; }
}
