/* Thème minimal. Pour ajouter une photo de décor en fond de page :
   déposer static/img/decor/fond.jpg puis remplacer `none` ci-dessous par
   url("../img/decor/fond.jpg"). */
:root {
  --decor: none;
  --bg: #e9eef1;
  --card: #ffffff;
  --ink: #1d2a33;
  --muted: #5f6f7a;
  --line: #d3dce2;
  --accent: #e5652e;      /* orange OP */
  --accent-ink: #ffffff;
  --sea: #1f4e6b;
  --ok: #2e7d4f;
  --err: #b3261e;
  --gold: #d4a017;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg) var(--decor) center / cover fixed;
}
main { max-width: 760px; margin: 0 auto; padding: 12px 16px 48px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h2 { font-size: 1.2rem; display: flex; align-items: baseline; gap: .5em; flex-wrap: wrap; }
h3 { font-size: 1.05rem; }
p { margin: .4em 0; }
a { color: var(--sea); }
code { background: #eef2f4; padding: 0 .3em; border-radius: 4px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.error { color: var(--err); font-weight: 600; }

/* --- barre du haut --- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  padding: 8px 16px; background: var(--sea); color: #fff;
}
.topbar a { color: #fff; text-decoration: none; }
.brand { font-weight: 700; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; order: 3; width: 100%; }
.topbar nav a { padding: 4px 10px; border-radius: 999px; font-size: .9rem; opacity: .85; }
.topbar nav a.on { background: rgba(255, 255, 255, .18); opacity: 1; }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: #fff; }
.avatar.initial { display: inline-grid; place-items: center; color: var(--sea); font-weight: 700; }
.muesli { background: rgba(255, 255, 255, .15); padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.logout { margin: 0; }
button.link { background: none; border: 0; color: #fff; font-size: 1.1rem; cursor: pointer; padding: 4px; }
@media (min-width: 700px) {
  .topbar nav { order: 0; width: auto; }
}

/* --- cartes --- */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin: 12px 0; box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
.login { max-width: 380px; margin: 12vh auto 0; }
.login form { display: grid; gap: 12px; margin-top: 16px; }
label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }

input, select, button {
  font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--sea); outline-offset: 1px; }
button { cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.big { width: 100%; padding: 14px; font-size: 1.05rem; margin-top: 8px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.mini { padding: 2px 10px; }
form.inline { display: flex; gap: 8px; }
form.inline input { flex: 1; min-width: 0; }
form.inline.wrap { flex-wrap: wrap; margin-top: 12px; }

.tag { display: inline-block; font-size: .8rem; padding: 2px 8px; border-radius: 999px; background: #eef2f4; color: var(--muted); }
.tag.ok { background: #e3f3e9; color: var(--ok); }

/* --- accueil --- */
.scores { display: flex; gap: 8px; flex-wrap: wrap; }
.score-pill { padding: 6px 12px; border-radius: 999px; background: #eef2f4; text-decoration: none; color: var(--ink); font-size: .92rem; }
.score-pill.mine { background: #fde7dc; }
.event { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.event-img { width: 100%; border-radius: 8px; margin: 4px 0 8px; }
.question { font-weight: 600; margin-top: .8em; }
.answer { display: grid; gap: 8px; margin-top: 8px; }
.option { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-size: 1rem; cursor: pointer; }
.option:has(input:checked) { border-color: var(--accent); background: #fff5f0; }
.order { padding-left: 1.6em; margin: 0; display: grid; gap: 6px; }
.order li { padding: 6px 0; }
.order li span { margin-right: 8px; }
.order li button { margin-left: 4px; }
.result { background: #f2f7f4; border-radius: 8px; padding: 10px 12px; margin-top: 8px; }
.gain { font-weight: 700; color: var(--ok); }
.done { color: var(--ok); font-weight: 600; }
#mesabs-gain { font-size: 1.4rem; color: var(--accent); }
.ranking li { padding: 4px 0; }
.ranking li.winner { font-weight: 700; }

.journal { list-style: none; margin: 0; padding: 0; font-size: .92rem; }
.journal li { padding: 6px 0; border-bottom: 1px solid #eef2f4; }
.journal li.mine { color: var(--muted); }
.journal .when { color: var(--muted); font-size: .8rem; margin-right: 4px; white-space: nowrap; }

/* --- cabane --- */
.score { font-size: .95rem; color: var(--accent); font-weight: 700; }
.scene { position: relative; isolation: isolate; width: 100%; aspect-ratio: 8 / 6; border-radius: 8px; overflow: hidden; background: #cfdbe2; }
.scene .layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.shop-cat { margin-top: 12px; }
.shop-item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid #eef2f4; }
.shop-item .info { flex: 1; }
.shop-item .title { font-weight: 600; }
.shop-item .icon { width: 48px; height: 48px; object-fit: contain; }
.shop-item.owned { opacity: .6; }
.shop-item.graal { background: linear-gradient(90deg, #fff8e1, transparent); border-left: 3px solid var(--gold); padding-left: 8px; }

.gain.loss { color: var(--err); }

/* --- mini-jeux --- */
.minigame { margin-top: 8px; }
.countdown { font-weight: 700; font-size: 1.1rem; color: var(--accent); text-align: center; margin: 6px 0; }
.count-img { width: 100%; border-radius: 8px; display: block; user-select: none; -webkit-user-select: none; pointer-events: none; }

.touque-board {
  position: relative; width: 100%; max-width: 440px; margin: 0 auto; aspect-ratio: 1 / 1;
  background: #8a8277; border-radius: 10px; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.touque {
  position: absolute; left: 12%; top: 12%; width: 76%; height: 76%; border-radius: 50%;
  background: radial-gradient(circle, #24323b 0%, #2f4552 70%, #3d5866 100%);
  box-shadow: 0 0 0 7px #4f7183, inset 0 0 24px rgba(0, 0, 0, .6);
}
.titem {
  position: absolute; transform: translate(-50%, -50%);
  display: grid; place-items: center; text-align: center;
  font-size: .72rem; font-weight: 700; line-height: 1.1; padding: 2px;
  border-radius: 6px; box-shadow: 0 2px 5px rgba(0, 0, 0, .45);
  cursor: grab; touch-action: none; overflow: hidden;
}
.titem img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.titem.drag { cursor: grabbing; box-shadow: 0 8px 16px rgba(0, 0, 0, .5); }
.titem.target { border: 2px dashed #b9a982; }
.titem.found { outline: 3px solid var(--ok); }

/* --- radio --- */
.badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: .75rem; text-align: center; }
.vhf {
  background: #2a2f33; color: #c8f7c5; border-radius: 14px; padding: 16px; text-align: center;
  box-shadow: inset 0 0 0 3px #15191c;
}
.vhf .lcd { font-family: ui-monospace, Menlo, monospace; background: #1b261b; border-radius: 6px; padding: 8px; margin-bottom: 12px;
  letter-spacing: .05em; }
.vhf .lcd b { font-size: 1.6rem; }
.ptt {
  width: 140px; height: 140px; border-radius: 50%; border: 0; margin: 8px auto; display: grid; place-items: center;
  background: #c0392b; color: #fff; font-weight: 700; font-size: 1rem; box-shadow: 0 6px 0 #7d241b;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.ptt.rec { transform: translateY(4px); box-shadow: 0 2px 0 #7d241b; background: #e74c3c; }
.ptt:disabled { background: #555; box-shadow: 0 6px 0 #333; }
.vhf .hint { color: #8fb08c; font-size: .85rem; }
.vhf button.secondary { background: #3b4348; color: #fff; border-color: #3b4348; }
.msgs { list-style: none; margin: 0; padding: 0; }
.msgs li { padding: 10px 0; border-bottom: 1px solid #eef2f4; display: grid; gap: 4px; }
.msgs li.new { background: #fff5f0; }
.msgs .meta { font-size: .88rem; display: flex; gap: 8px; align-items: center; }
.msgs audio { width: 100%; height: 36px; }
.msgs button.link { color: var(--err); font-size: .8rem; margin-left: auto; }

/* --- icônes, photo, classement, sorts --- */
img.flag { height: 1em; width: auto; vertical-align: -0.12em; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .35); }
.journal img.flag, .toast img.flag { box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }
.scene.shake { animation: shake .8s; }
@keyframes shake {
  0%, 100% { transform: none; }
  15% { transform: translateX(-6px) rotate(-.6deg); } 30% { transform: translateX(6px) rotate(.6deg); }
  45% { transform: translateX(-4px); } 60% { transform: translateX(4px); } 75% { transform: translateX(-2px); }
}
.rank-card.first { box-shadow: 0 0 0 2px var(--gold), 0 1px 3px rgba(0, 0, 0, .08); }
.rank-head { display: flex; align-items: center; gap: 12px; }
.rank-pos { font-size: 1.6rem; font-weight: 800; color: var(--muted); width: 1.4em; text-align: center; }
.rank-card.first .rank-pos { color: var(--gold); }
.avatar.big { width: 52px; height: 52px; font-size: 1.3rem; background: #eef2f4; }
.rank-name { flex: 1; display: grid; gap: 4px; }
.rank-name a { font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.rank-score { text-align: right; line-height: 1; }
.rank-score b { font-size: 1.8rem; color: var(--accent); display: block; }
.rank-score span { font-size: .8rem; color: var(--muted); }
.graal-tag { background: #fff8e1; color: #8a6d00; justify-self: start; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 16px; margin: 14px 0 0; }
.stats div { display: flex; justify-content: space-between; border-bottom: 1px solid #eef2f4; padding: 4px 0; font-size: .9rem; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-weight: 600; }
.stats small { color: var(--muted); font-weight: 400; }
@media (max-width: 420px) { .stats { grid-template-columns: 1fr; } }

/* --- ordre de mission --- */
.mission { border-top: 4px solid var(--sea); }
.mission summary { cursor: pointer; list-style: none; display: grid; gap: 2px; }
.mission summary::-webkit-details-marker { display: none; }
.mission summary::after { content: "Relire l'ordre de mission ▾"; font-size: .85rem; color: var(--sea); margin-top: 4px; }
.mission details[open] summary::after { content: "Replier ▴"; }
.mission.before details summary::after { content: none; }
.mission-kicker { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.mission-title { font-size: 1.4rem; font-weight: 800; color: var(--sea); }
.mission-body { margin-top: 10px; }
.mission-body p { margin: .7em 0; }
.mission-order { background: #eef4f8; border-left: 4px solid var(--accent); padding: 10px 12px; border-radius: 6px; }
.mission-list { padding-left: 1.2em; margin: .4em 0; }
.mission-list li { margin: .5em 0; }
.mission-start { font-weight: 700; color: var(--accent); }
.mission-sign { text-align: right; font-style: italic; color: var(--muted); font-size: .9rem; }

/* --- photo d'événement --- */
.event-photo { margin: 6px 0 10px; }
.event-photo figcaption { margin-top: 4px; text-align: center; }
.event-img.zoomable { cursor: zoom-in; }
.lightbox {
  position: fixed; inset: 0; z-index: 300; background: rgba(10, 18, 24, .92);
  display: grid; place-items: center; align-content: center; gap: 10px; padding: 16px; cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 85vh; border-radius: 6px; }
.lightbox p { color: #fff; margin: 0; text-align: center; }

/* --- admin --- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 6px 4px; border-bottom: 1px solid #eef2f4; }

/* --- notifications --- */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 200; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, .2); transition: opacity .6s; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }
.toast.info { background: var(--sea); }
.toast.out { opacity: 0; }

/* --- mini-jeu câbles --- */
.wires-board { position: relative; max-width: 420px; margin: 8px auto 0; background: #2a2f33; border-radius: 12px; padding: 6px; }
.wires-svg { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; }
.wires-head { fill: #8fb08c; font: 600 13px system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase; }
.wires-label { fill: #e8eef1; font: 12px system-ui, sans-serif; }
.wires-cable, .wires-plug { cursor: pointer; }
.wires-cable.on, .wires-plug.on { cursor: default; }
.wires-ring { fill: none; stroke: #f5d76e; stroke-width: 3; }
.wires-socket { fill: #4a5257; stroke: #15191c; stroke-width: 2; }
.wires-plug.ready .wires-socket { stroke: #f5d76e; }
.wires-hole { fill: #15191c; }
.wire { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .5)); }
.wires-info { text-align: center; margin-top: 8px; }
.wires-board.on-fire { animation: shake .8s, burn 1.4s; }
@keyframes burn { 0% { background: #2a2f33; } 15% { background: #c0392b; } 40% { background: #e67e22; } 100% { background: #2a2f33; } }
.fire-overlay { position: absolute; inset: 0; display: grid; place-items: center; font: 900 clamp(1.4rem, 8vw, 2.2rem) system-ui, sans-serif; letter-spacing: .06em;
  color: #fff3c4; text-shadow: 0 0 12px #ff7a1a, 0 0 28px #e0301e; pointer-events: none;
  animation: flame 1.4s ease-out forwards; }
@keyframes flame { 0% { opacity: 0; transform: scale(.6); } 20% { opacity: 1; transform: scale(1.08); } 100% { opacity: 0; transform: scale(1.12) translateY(-16px); } }

/* --- séismes --- */
.seisme-scores { display: flex; gap: 10px; }
.seisme-me, .seisme-other { flex: 1; display: grid; justify-items: center; background: #f4f7f9; border-radius: 8px; padding: 8px; }
.seisme-others { flex: 1; display: flex; gap: 10px; }
.seisme-me { background: #fde7dc; }
.seisme-scores b { font-size: 1.8rem; line-height: 1.1; }
.seisme-btn { touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.seisme-btn.bump { animation: bump .15s; }
@keyframes bump { 50% { transform: scale(.97); } }
.seisme-lead { font-weight: 600; margin-top: 10px; }

/* --- bouton de déconnexion --- */
.logout-btn { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 50%; }
.logout-btn:hover, .logout-btn:focus-visible { background: rgba(255, 255, 255, .15); }
.shop-item .title .graal-tag { margin-left: 6px; font-weight: 600; }

/* --- popup de bonus --- */
.bonus-backdrop { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; padding: 16px;
  background: rgba(10, 18, 24, .7); animation: fadein .2s; }
.bonus-backdrop.out { opacity: 0; transition: opacity .25s; }
.bonus-pop { position: relative; overflow: hidden; width: min(100%, 380px); text-align: center; background: #fff;
  border-radius: 16px; padding: 28px 20px 20px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); animation: popin .45s cubic-bezier(.2, 1.4, .4, 1); }
.bonus-burst { position: absolute; left: 50%; top: -120px; width: 360px; height: 360px; margin-left: -180px; pointer-events: none;
  background: repeating-conic-gradient(rgba(229, 101, 46, .16) 0 10deg, transparent 10deg 20deg); border-radius: 50%;
  animation: spin 12s linear infinite; }
.bonus-pop > *:not(.bonus-burst) { position: relative; }
.bonus-kicker { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin: 0; }
.bonus-title { justify-content: center; font-size: 1.6rem; margin: 6px 0 10px; color: var(--sea); }
.bonus-msg { margin: 0 0 10px; }
.bonus-effect { display: inline-block; font-weight: 800; font-size: 1.15rem; color: var(--ok); background: #e3f3e9;
  border-radius: 999px; padding: 6px 16px; margin: 4px 0 16px; }
.bonus-pop.storm { background: #1f2a33; color: #e8eef1; }
.bonus-pop.storm .bonus-burst { background: repeating-conic-gradient(rgba(120, 170, 210, .14) 0 6deg, transparent 6deg 18deg); animation-duration: 3s; }
.bonus-pop.storm .bonus-title { color: #9fd3ff; }
.bonus-pop.storm .bonus-effect { color: #fff; background: #b3261e; }
@keyframes popin { 0% { transform: scale(.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
.mission-warning { border: 1px dashed var(--err); border-radius: 6px; padding: 10px 12px; font-size: .95rem; }

/* --- variantes de la fenêtre : coups du sort --- */
.bonus-pop.hit { background: #2a1f3a; color: #ece6f6; }
.bonus-pop.hit .bonus-burst { background: repeating-conic-gradient(rgba(170, 120, 230, .18) 0 8deg, transparent 8deg 20deg); animation-duration: 5s; }
.bonus-pop.hit .bonus-kicker { color: #f5a623; }
.bonus-pop.hit .bonus-title { color: #d3b8ff; }
.bonus-pop.hit .bonus-effect { color: #fff; background: #7d4fb0; }
.bonus-pop.miss { background: #e9eef1; }
.bonus-pop.miss .bonus-burst { background: repeating-conic-gradient(rgba(95, 111, 122, .12) 0 10deg, transparent 10deg 20deg); animation-duration: 30s; }
.bonus-pop.miss .bonus-kicker { color: var(--muted); }
.bonus-pop.miss .bonus-title { color: var(--ink); }
.bonus-pop.miss .bonus-effect { color: var(--muted); background: #dbe3e8; }
.bonus-pop.backfire { animation: popin .45s cubic-bezier(.2, 1.4, .4, 1), shake .6s .45s; }
.bonus-pop.backfire .bonus-burst { background: repeating-conic-gradient(rgba(179, 38, 30, .16) 0 10deg, transparent 10deg 20deg); }
.bonus-pop.backfire .bonus-kicker { color: var(--err); }
.bonus-pop.backfire .bonus-title { color: var(--err); }
.bonus-pop.backfire .bonus-effect { color: #fff; background: var(--err); }
