:root {
  --bg: #0f1720;
  --panel: #18222e;
  --panel-2: #212e3d;
  --text: #e8eef5;
  --muted: #8fa1b3;
  --accent: #2fbf71;
  --accent-2: #25a05e;
  --danger: #ff6b6b;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
a { color: var(--accent); }

.screen { position: fixed; inset: 0; }
.card-screen { display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto;
  background: radial-gradient(circle at 30% 20%, #1d3a2e 0, var(--bg) 60%); }
.card { background: var(--panel); border-radius: 18px; padding: 28px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.card.wide { max-width: 560px; }
h1 { margin: 0 0 4px; font-size: 2rem; }
h2 { font-size: 1rem; margin: 22px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.error { color: var(--danger); margin: 12px 0 0; }

label { display: block; font-size: .9rem; color: var(--muted); margin: 16px 0 0; }
input, select { width: 100%; margin-top: 6px; padding: 12px; border-radius: 10px; border: 1px solid #2c3b4c;
  background: var(--panel-2); color: var(--text); font-size: 1rem; }
input:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
select:disabled { opacity: .7; }

button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 12px 18px;
  background: var(--panel-2); color: var(--text); font-weight: 600; }
button:hover:not(:disabled) { filter: brightness(1.15); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: #062312; width: 100%; margin-top: 18px; font-size: 1.05rem; }
button.ghost { background: transparent; border: 1px solid #2c3b4c; }
button.link { background: none; color: var(--muted); display: block; margin: 12px auto 0; font-weight: 400; text-decoration: underline; }

.row { display: flex; gap: 10px; margin-top: 12px; }
.row input { margin: 0; }
.row button { white-space: nowrap; }
.code-input { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-weight: 700; }
.sep { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 18px 0 6px; font-size: .85rem; }
.sep::before, .sep::after { content: ""; flex: 1; height: 1px; background: #2c3b4c; }

.lobby-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.big-code { font-size: 2.4rem; font-weight: 800; letter-spacing: .2em; color: var(--accent); }
.share { font-size: .85rem; color: var(--muted); }
.settings { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
.settings label { margin: 0; }
@media (max-width: 520px) { .settings { grid-template-columns: 1fr; } }

.players { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.players li { background: var(--panel-2); padding: 8px 12px; border-radius: 999px; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.players li.off { opacity: .45; }
.tag { font-size: .7rem; background: #3a4a5c; padding: 2px 6px; border-radius: 6px; color: var(--muted); }

.spinner { width: 44px; height: 44px; border: 4px solid #2c3b4c; border-top-color: var(--accent);
  border-radius: 50%; margin: 0 auto 12px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Manche */
#pano { position: absolute; inset: 0; }
.hud { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 18px;
  background: rgba(15,23,32,.85); padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 20;
  white-space: nowrap; }
.timer.low { color: var(--danger); }
.hud-players { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px;
  z-index: 20; flex-wrap: wrap; justify-content: center; max-width: 90vw; }
.hud-players span { background: rgba(15,23,32,.85); padding: 4px 10px; border-radius: 999px; font-size: .8rem;
  display: flex; align-items: center; gap: 6px; }
.hud-players span.done::after { content: "✓"; color: var(--accent); }

.guess-box { position: absolute; right: 16px; bottom: 36px; width: 320px; z-index: 30;
  transition: width .2s, height .2s; display: flex; flex-direction: column; }
#guess-map { height: 220px; border-radius: var(--radius); opacity: .75; transition: height .2s, opacity .2s;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.guess-box:hover #guess-map, .guess-box.big #guess-map { opacity: 1; }
@media (hover: hover) {
  .guess-box:hover { width: min(640px, 60vw); }
  .guess-box:hover #guess-map { height: min(440px, 55vh); }
}
.guess-box.big { width: min(640px, calc(100vw - 32px)); }
.guess-box.big #guess-map { height: min(440px, 55vh); }
.guess-box button.primary { margin-top: 8px; }
.map-toggle { position: absolute; top: 6px; left: 6px; z-index: 1000; padding: 4px 9px; background: rgba(15,23,32,.85); }
@media (max-width: 600px) {
  .guess-box { left: 16px; right: 16px; width: auto; bottom: 28px; }
  .guess-box.big { width: auto; }
  #guess-map { height: 160px; }
}
.force-end { position: absolute; left: 16px; bottom: 36px; z-index: 30; background: rgba(15,23,32,.85); }
.credit { position: absolute; left: 8px; bottom: 6px; font-size: .75rem; color: #cfd8e3; z-index: 20;
  text-shadow: 0 1px 2px #000; }

/* Résultats */
#results { display: flex; }
#result-map { flex: 1; min-width: 0; }
.result-panel { width: 400px; max-width: 100%; background: var(--panel); padding: 20px; overflow: auto; }
.result-panel h2 { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 1.3rem; margin-top: 0; }
@media (max-width: 760px) {
  #results { flex-direction: column; }
  #result-map { flex: none; height: 45vh; }
  .result-panel { width: 100%; flex: 1; }
}
.scores { width: 100%; border-collapse: collapse; font-size: .92rem; }
.scores th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 4px; border-bottom: 1px solid #2c3b4c; }
.scores td { padding: 8px 4px; border-bottom: 1px solid #222f3d; }
.scores td:nth-child(n+3), .scores th:nth-child(n+3) { text-align: right; font-variant-numeric: tabular-nums; }
.scores tr.me td { background: rgba(47,191,113,.08); }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 20px 0 8px; }
.podium div { background: var(--panel-2); border-radius: 10px 10px 0 0; width: 100px; text-align: center; padding: 10px 6px;
  display: flex; flex-direction: column; justify-content: flex-end; }
.podium .p1 { height: 150px; background: linear-gradient(#d4a72c33, var(--panel-2)); }
.podium .p2 { height: 115px; }
.podium .p3 { height: 90px; }
.podium b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .medal { font-size: 1.8rem; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel-2);
  padding: 10px 18px; border-radius: 999px; z-index: 2000; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.offline { position: fixed; top: 0; left: 0; right: 0; background: var(--danger); color: #fff; text-align: center;
  padding: 6px; z-index: 3000; font-weight: 600; }

.pin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.6); }
.flag-pin { font-size: 28px; line-height: 28px; }
.leaflet-container { background: #1b2733; }

/* Flèches de déplacement dans la vue 360° */
.nav-arrow { cursor: pointer; }
.nav-arrow svg { width: 100%; height: 100%; filter: drop-shadow(0 2px 6px rgba(0,0,0,.6)); transition: transform .15s; }
.nav-arrow circle { fill: rgba(15,23,32,.55); stroke: #fff; stroke-width: 3; }
.nav-arrow path { fill: none; stroke: #fff; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.nav-arrow:hover svg { transform: scale(1.15); }
.nav-arrow:hover circle { fill: rgba(47,191,113,.8); }
.back-start { position: absolute; top: 12px; left: 12px; z-index: 20; background: rgba(15,23,32,.85); padding: 8px 12px; }
@media (max-width: 600px) { .back-start { top: auto; bottom: 250px; } }
