:root {
  --text: #e9eef6;
  --muted: #8f9bb0;
  --panel: rgba(13, 17, 26, 0.78);
  --panel-line: rgba(255, 255, 255, 0.09);
  --field: rgba(255, 255, 255, 0.06);
  --accent: #22d3ee;
  --accent-2: #3b82f6;
  --hot: #f43f5e;
  --gold: #fbbf24;
  --display: 'Exo 2', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1119; font-family: 'Inter', system-ui, sans-serif; color: var(--text); }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
/* vignette légère par-dessus le rendu */
body::after { content: ''; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(5, 10, 20, 0.45) 100%); }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(180deg, rgba(5, 10, 20, 0.15), rgba(5, 10, 20, 0.55)); z-index: 2; }
.panel { background: var(--panel); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); border: 1px solid var(--panel-line); border-radius: 18px; padding: 28px 30px; width: min(460px, 100%); max-height: 100%; overflow-y: auto; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45); text-align: center; }
h1 { font-family: var(--display); font-weight: 800; font-style: italic; font-size: 54px; margin: 0; letter-spacing: 2px; line-height: 0.95; color: #fff; text-transform: uppercase; }
h1 span { display: block; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { font-family: var(--display); font-weight: 800; font-style: italic; font-size: 38px; margin: 0 0 6px; text-transform: uppercase; }
.tagline { color: var(--muted); margin: 12px 0 20px; font-size: 14px; }
label { display: block; text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin: 12px 0 6px; }
label.inline { display: inline-flex; flex-direction: column; margin: 0; }
.label { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin: 14px 0 8px; }
input, select { font: inherit; font-weight: 600; font-size: 15px; letter-spacing: 0; text-transform: none; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--panel-line); width: 100%; background: var(--field); color: var(--text); margin-top: 6px; }
select option { background: #151a25; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2); }
label.inline input, label.inline select { width: 130px; padding: 8px 10px; }
.row { display: flex; gap: 10px; margin-top: 12px; align-items: flex-end; justify-content: center; }
.code-input { text-transform: uppercase; text-align: center; letter-spacing: 6px; width: 140px; flex: none; margin-top: 0; }

button { font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: 1px; text-transform: uppercase; border: 1px solid transparent; border-radius: 10px; padding: 11px 18px; cursor: pointer; color: #fff; background: linear-gradient(135deg, var(--accent-2), #2563eb); box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3); transition: transform 0.08s, filter 0.15s; }
button:hover { filter: brightness(1.12); }
button:active { transform: translateY(1px) scale(0.99); }
button.big { width: 100%; font-size: 21px; padding: 15px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 10px 30px rgba(34, 211, 238, 0.3); }
button.secondary { background: rgba(255, 255, 255, 0.06); border-color: var(--panel-line); color: var(--text); box-shadow: none; }
button.small { font-size: 13px; padding: 8px 12px; }
button:disabled { opacity: 0.4; cursor: default; filter: none; }

.colors { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.colors button { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.15); }
.colors button.selected { border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25) !important; }
.error { color: var(--hot); font-weight: 600; min-height: 1.2em; font-size: 14px; }
.muted { color: var(--muted); }
.controls { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--panel-line); font-size: 12px; color: var(--muted); line-height: 1.8; }
.controls b { color: var(--text); font-weight: 600; }

.lobby-panel { width: min(520px, 100%); }
.lobby-head { display: flex; justify-content: space-between; align-items: center; }
.room-code { font-family: var(--display); font-weight: 800; font-style: italic; font-size: 48px; letter-spacing: 8px; color: var(--accent); text-align: left; line-height: 1; text-shadow: 0 0 24px rgba(34, 211, 238, 0.45); }
.players { list-style: none; padding: 0; margin: 0; text-align: left; }
.players li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--field); border: 1px solid var(--panel-line); margin-bottom: 6px; font-weight: 600; }
.players .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 10px currentColor; }
.players .tag { margin-left: auto; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
#btn-leave { margin-top: 16px; }
#host-controls { margin-top: 10px; }
#host-controls .row { margin-bottom: 14px; }

.results { background: rgba(251, 191, 36, 0.08); border: 1px solid rgba(251, 191, 36, 0.3); border-radius: 12px; padding: 14px 16px; margin: 14px 0 4px; text-align: left; }
.results h3 { font-family: var(--display); font-weight: 800; font-style: italic; text-transform: uppercase; margin: 0 0 8px; font-size: 20px; color: var(--gold); letter-spacing: 1px; }
.results ol { margin: 0; padding-left: 24px; font-weight: 600; }
.results li { padding: 3px 0; }
.results li span { float: right; font-variant-numeric: tabular-nums; }
.big-time { font-family: var(--display); font-weight: 800; font-size: 52px; margin: 4px 0; font-variant-numeric: tabular-nums; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
.hud-box { position: absolute; background: rgba(10, 14, 22, 0.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--panel-line); color: #fff; border-radius: 10px; padding: 8px 14px; font-family: var(--display); font-weight: 700; font-size: 26px; font-variant-numeric: tabular-nums; }
#hud-time { top: 16px; left: 16px; font-style: italic; }
#hud-cp { top: 68px; left: 16px; font-size: 14px; letter-spacing: 1px; color: var(--muted); }
.rank { top: 16px; right: 16px; margin: 0; padding: 10px 16px 10px 34px; font-size: 15px; font-weight: 600; min-width: 180px; }
.rank li { padding: 2px 0; }
.rank li.me { color: var(--accent); }
.speed { bottom: 16px; right: 16px; font-size: 38px; font-style: italic; }
.speed small { font-size: 14px; color: var(--muted); font-style: normal; }
#hud-center { position: absolute; top: 32%; left: 0; right: 0; text-align: center; font-family: var(--display); font-weight: 800; font-style: italic; font-size: 110px; color: #fff; text-transform: uppercase; text-shadow: 0 0 40px rgba(34, 211, 238, 0.6), 0 6px 20px rgba(0, 0, 0, 0.5); }
#hud-center.medium { font-size: 58px; }
#hud-hint { position: absolute; bottom: 18px; left: 16px; color: rgba(255, 255, 255, 0.75); font-size: 12px; letter-spacing: 0.5px; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7); }
#btn-abort { position: absolute; top: 108px; left: 16px; pointer-events: auto; }

#reticle { position: fixed; width: 32px; height: 32px; margin: -16px 0 0 -16px; border: 2px solid rgba(255, 255, 255, 0.95); border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 12px rgba(255, 255, 255, 0.25); pointer-events: none; z-index: 1; transition: width 0.08s, height 0.08s, margin 0.08s, border-color 0.08s; }
#reticle::after { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: #fff; }
#reticle.orb, #reticle.target, #reticle.player { width: 52px; height: 52px; margin: -26px 0 0 -26px; border-width: 3px; }
#reticle.orb { border-color: var(--accent); box-shadow: 0 0 16px rgba(34, 211, 238, 0.7); }
#reticle.target { border-color: var(--hot); box-shadow: 0 0 16px rgba(244, 63, 94, 0.7); }
#reticle.player { border-color: var(--gold); box-shadow: 0 0 16px rgba(251, 191, 36, 0.7); }
#reticle.far { opacity: 0.4; border-style: dashed; }
#reticle.locked { border-color: #34d399; box-shadow: 0 0 16px rgba(52, 211, 153, 0.7); }
body.aiming #game { cursor: none; }

#toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; z-index: 3; }
.toast { background: rgba(10, 14, 22, 0.75); backdrop-filter: blur(8px); border: 1px solid var(--panel-line); color: #fff; padding: 8px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; animation: toast 3s forwards; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ---------- mobile ---------- */
html, body { overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#game { touch-action: none; }
button { touch-action: manipulation; }
input { -webkit-user-select: text; user-select: text; }
body.touch .desktop-only, body:not(.touch) .touch-only, body:not(.touch) #touch-controls { display: none; }
#touch-controls { position: absolute; inset: 0; pointer-events: none; }
#joystick { position: absolute; left: max(28px, env(safe-area-inset-left)); bottom: max(28px, env(safe-area-inset-bottom)); width: 140px; height: 140px; border-radius: 50%; background: rgba(10, 14, 22, 0.35); border: 2px solid rgba(255, 255, 255, 0.2); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); pointer-events: auto; touch-action: none; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 62px; height: 62px; margin: -31px; border-radius: 50%; background: rgba(255, 255, 255, 0.85); box-shadow: 0 0 20px rgba(34, 211, 238, 0.5); pointer-events: none; }
.touch-btn { position: absolute; pointer-events: auto; touch-action: none; border-radius: 50%; padding: 0; display: flex; align-items: center; justify-content: center; }
#btn-jump { right: max(28px, env(safe-area-inset-right)); bottom: max(34px, env(safe-area-inset-bottom)); width: 100px; height: 100px; font-size: 17px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
#btn-respawn-touch { right: max(146px, calc(env(safe-area-inset-right) + 118px)); bottom: max(40px, env(safe-area-inset-bottom)); width: 56px; height: 56px; font-size: 24px; background: rgba(10, 14, 22, 0.5); border-color: var(--panel-line); box-shadow: none; }
#rotate-hint { display: none; }
body.touch .speed { bottom: auto; top: 12px; right: auto; left: 50%; transform: translateX(-50%); font-size: 22px; padding: 6px 12px; }
body.touch #hud-hint { display: none; }
body.touch #hud-time { top: 12px; left: max(12px, env(safe-area-inset-left)); font-size: 20px; }
body.touch #hud-cp { top: 54px; left: max(12px, env(safe-area-inset-left)); font-size: 12px; }
body.touch .rank { top: 12px; right: max(12px, env(safe-area-inset-right)); font-size: 12px; min-width: 120px; padding: 6px 10px 6px 28px; }
body.touch #btn-abort { top: 88px; left: max(12px, env(safe-area-inset-left)); }
body.touch #hud-center { font-size: 72px; }
body.touch #hud-center.medium { font-size: 40px; }
@media (orientation: portrait) {
  body.touch #rotate-hint { display: flex; position: fixed; inset: 0; z-index: 5; align-items: center; justify-content: center; text-align: center; background: rgba(8, 12, 20, 0.94); font-family: var(--display); font-weight: 700; font-size: 22px; line-height: 1.5; padding: 30px; pointer-events: auto; }
}
/* écrans peu hauts (téléphone en paysage) : panneaux compacts */
@media (max-height: 520px) {
  .screen { align-items: flex-start; }
  .panel { padding: 14px 20px; }
  h1 { font-size: 34px; display: inline; }
  h1 span { display: inline; margin-left: 10px; }
  .tagline { margin: 6px 0 8px; font-size: 12px; }
  .label, label { margin: 6px 0 4px; }
  input, select { padding: 8px 10px; }
  .row { margin-top: 8px; }
  button.big { padding: 11px; font-size: 18px; }
  .controls { margin-top: 10px; padding-top: 8px; font-size: 11px; line-height: 1.5; }
  .room-code { font-size: 34px; }
}

@media (max-width: 600px) {
  h1 { font-size: 40px; }
  .hud-box { font-size: 20px; }
  #hud-center { font-size: 64px; }
  .rank { min-width: 130px; font-size: 13px; }
}
