:root {
  --bg: #0f1a2b;
  --card: #17263d;
  --card2: #1f3150;
  --line: #2c4468;
  --text: #eef4ff;
  --dim: #9fb3d1;
  --accent: #ff7a3d;
  --accent2: #ffd23f;
  --ok: #5fd36a;
  --bad: #ff5a4e;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: Nunito, system-ui, sans-serif; }
body { background: var(--bg); }
[hidden] { display: none !important; }
.screen { min-height: 100vh; padding: 24px; }
.dim { color: var(--dim); }
h2 { margin: 0 0 14px; font-family: 'Russo One', sans-serif; font-weight: 400; font-size: 20px; }
h3 { margin: 22px 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.logo { font-family: 'Russo One', sans-serif; font-weight: 400; font-size: clamp(24px, 6.4vw, 34px); line-height: 1.1; margin: 0; letter-spacing: .01em; color: var(--accent2); }
.logo span { color: var(--accent); display: block; }
.logo.small span { display: inline; margin-left: 6px; }
.logo.small { font-size: 22px; }
.tag { color: var(--dim); margin: 6px 0 20px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.card.narrow { max-width: 460px; margin: 8vh auto 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 1100px; margin: 0 auto; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
.bar { display: flex; justify-content: space-between; align-items: center; max-width: 1100px; margin: 0 auto 20px; gap: 12px; flex-wrap: wrap; }
.who { display: flex; align-items: center; gap: 12px; }

label { display: block; font-size: 13px; color: var(--dim); margin-bottom: 12px; }
input, select { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card2); color: var(--text); font: inherit; font-size: 15px; }
input:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
select:disabled { opacity: .75; }
.row { display: flex; gap: 10px; }
.row input { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; margin-top: 12px; }

.btn { border: 1px solid var(--line); background: var(--card2); color: var(--text); padding: 10px 16px; border-radius: 10px; font: inherit; font-weight: 800; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: linear-gradient(180deg, #ff9156, #f0612a); border-color: #f0612a; color: #fff; }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; padding: 14px; font-size: 17px; margin-top: 14px; }
.btn:disabled { opacity: .5; cursor: default; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button { flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--dim); font: inherit; font-weight: 700; cursor: pointer; }
.tabs button.on { background: var(--card2); color: var(--text); }
.msg { min-height: 20px; color: var(--bad); font-weight: 700; margin: 12px 0 0; }
.hint { color: var(--dim); }

.rooms { display: grid; gap: 8px; }
.room-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); cursor: pointer; }
.room-item:hover { border-color: var(--accent); }
.room-item small { color: var(--dim); }
.pill { font-size: 12px; padding: 3px 8px; border-radius: 99px; background: #2a3f61; }
.pill.live { background: #6b2b1c; color: #ffb38f; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats div { background: var(--card2); border-radius: 12px; padding: 10px; text-align: center; }
.stats b { display: block; font-size: 22px; font-family: 'Russo One', sans-serif; font-weight: 400; color: var(--accent2); }
.stats span { font-size: 12px; color: var(--dim); }
.board { width: 100%; border-collapse: collapse; font-size: 14px; }
.board td, .board th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.board th { color: var(--dim); font-weight: 700; }

.players { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.players li { padding: 9px 12px; border-radius: 10px; background: var(--card2); display: flex; justify-content: space-between; }
.players li em { font-style: normal; color: var(--dim); font-size: 13px; }
.chat-log { height: 170px; overflow-y: auto; background: var(--card2); border-radius: 10px; padding: 10px; font-size: 14px; margin-bottom: 10px; }
.chat-log p { margin: 0 0 4px; }
#map-preview { width: 100%; border-radius: 12px; border: 1px solid var(--line); background: #0b1422; display: block; }

/* ============ PARTIE ============ */
#play { padding: 0; overflow: hidden; }
#game { position: fixed; inset: 0; }
#game canvas.view { position: absolute; inset: 0; display: block; cursor: crosshair; }
.quit { position: fixed; top: 12px; right: 12px; z-index: 5; background: rgba(15,26,43,.75); }
.hud-top { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; background: rgba(10,18,32,.8); border: 1px solid var(--line); padding: 8px 16px; border-radius: 14px; font-weight: 800; pointer-events: none; }
.turn-who i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.turn-who em { font-style: normal; color: var(--bad); margin-left: 6px; }
.turn-timer { font-family: 'Russo One', sans-serif; font-size: 26px; min-width: 34px; text-align: center; color: var(--accent2); }
.turn-timer.hurry { color: var(--bad); }
.turn-timer.retreat { color: var(--ok); }
.hud-notice { position: absolute; top: 118px; left: 50%; transform: translateX(-50%); background: rgba(255,122,61,.92); color: #fff; padding: 8px 18px; border-radius: 12px; font-weight: 800; pointer-events: none; }
.hud-teams { position: absolute; left: 12px; bottom: 12px; display: grid; gap: 4px; min-width: 220px; pointer-events: none; }
.tb { display: grid; grid-template-columns: 90px 1fr 34px; align-items: center; gap: 8px; background: rgba(10,18,32,.75); padding: 4px 8px; border-radius: 8px; font-size: 12px; font-weight: 800; }
.tb span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb i { height: 8px; border-radius: 4px; display: block; transition: width .4s; }
.tb b { text-align: right; }
.tb.out { opacity: .4; }
.hud-wind { position: absolute; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 8px; background: rgba(10,18,32,.8); padding: 6px 12px; border-radius: 10px; font-size: 12px; pointer-events: none; }
.hud-wind span { display: block; height: 10px; width: 0; transition: width .4s; background: repeating-linear-gradient(90deg, #8fd3ff 0 6px, transparent 6px 9px); }
.hud-wind .wl { transform: scaleX(-1); }
.hud-wind b { color: var(--dim); }
.hud-weapon { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); background: rgba(10,18,32,.85); border: 1px solid var(--line); padding: 8px 14px; border-radius: 12px; font-size: 14px; pointer-events: none; white-space: nowrap; }
.hud-feed { position: absolute; top: 12px; left: 12px; display: grid; gap: 4px; max-width: 380px; pointer-events: none; }
.hud-feed div { background: rgba(10,18,32,.75); padding: 5px 10px; border-radius: 8px; font-size: 13px; transition: opacity 1s; }
.hud-feed div.old { opacity: 0; }
.hud-help { position: absolute; top: 72px; left: 50%; transform: translateX(-50%); max-width: min(760px, 92vw); text-align: center; font-size: 12px; color: #fff; background: rgba(10,18,32,.6); padding: 6px 12px; border-radius: 10px; pointer-events: none; }
.hud-bag { position: absolute; right: 12px; bottom: 56px; font-size: 22px; width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: rgba(10,18,32,.8); cursor: pointer; }
.weapons { position: absolute; right: 12px; bottom: 110px; width: 360px; max-height: 70vh; overflow-y: auto; background: rgba(15,26,43,.96); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.weapons h3 { margin: 0 0 8px; }
.wgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.wgrid button { position: relative; padding: 8px 4px; border-radius: 10px; border: 1px solid var(--line); background: var(--card2); color: var(--text); cursor: pointer; display: grid; justify-items: center; gap: 2px; font: inherit; }
.wgrid button span { font-size: 22px; }
.wgrid button small { font-size: 10.5px; line-height: 1.15; text-align: center; }
.wgrid button em { position: absolute; top: 3px; right: 6px; font-style: normal; font-size: 11px; color: var(--accent2); }
.wgrid button.on { border-color: var(--accent); background: #3a2a22; }
.wgrid button:disabled { opacity: .3; cursor: default; }
.end { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(5,10,20,.55); }
.end-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 26px 30px; min-width: 420px; text-align: center; }
.end-card h2 { font-size: 30px; }
.end-card table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.end-card td, .end-card th { padding: 6px 10px; border-bottom: 1px solid var(--line); }
.end-card tr.w td { font-weight: 800; }
.ingame-chat { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); width: min(520px, 90vw); z-index: 6; }
.ingame-log { position: fixed; left: 12px; top: 50%; transform: translateY(-50%); display: grid; gap: 4px; max-width: 320px; pointer-events: none; z-index: 4; }
.ingame-log p { margin: 0; background: rgba(10,18,32,.7); padding: 4px 9px; border-radius: 8px; font-size: 13px; transition: opacity 1s; }
.ingame-log p.old { opacity: 0; }

.players li select { display: inline-block; width: auto; margin: 0; padding: 4px 8px; font-size: 13px; }
.players li .btn { padding: 4px 9px; }
#bot-add-row select { margin: 0; }

#intro { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
#intro-shade { position: fixed; inset: 0; z-index: 0; background: radial-gradient(ellipse at 50% 30%, rgba(10,18,32,.28) 0%, rgba(10,18,32,0) 55%); pointer-events: none; }
.screen { position: relative; z-index: 1; }
#play { z-index: 2; }
.card { background: rgba(23,38,61,.9); backdrop-filter: blur(4px); }

.check { display: flex; gap: 10px; align-items: center; margin-top: 14px; color: var(--text); }
.check input { width: auto; margin: 0; }

.keys { margin-top: 14px; background: var(--card2); border-radius: 12px; padding: 10px 12px; }
.keys summary { cursor: pointer; font-weight: 800; }
.keyrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.keybtn { min-width: 120px; padding: 6px 10px; }
.keybtn.wait { border-color: var(--accent); color: var(--accent2); }
#keys-reset { margin-top: 10px; }
