/* Arcade Express — "arcade néon" dark theme. The Halloween theme (css/halloween.css) recolours the site, but the
   games keep this palette: .game-host declares it again for them. */

:root, .game-host {
  --bg: #070a1a;
  --bg-2: #0c1130;
  --surface: rgba(20, 26, 62, 0.72);
  --surface-solid: #141b42;
  --surface-2: rgba(255, 255, 255, 0.045);
  --input-bg: #0a0f2b;
  --border: rgba(130, 150, 255, 0.16);
  --border-strong: rgba(150, 170, 255, 0.34);
  --grid: rgba(110, 130, 255, 0.07);

  --text: #eef1ff;
  --muted: #9aa3c7;
  --faint: #8189b3;   /* ≥ 4.5:1 (WCAG AA) on --bg, cards and overlays */

  --accent: #00e5ff;      /* cyan */
  --accent-2: #ff3bd4;    /* magenta */
  --accent-3: #ffd23f;    /* yellow */
  --success: #3dff9a;
  --danger: #ff4d6d;
  --warning: #ffb84d;

  --accent-soft: rgba(0, 229, 255, 0.12);
  --magenta-soft: rgba(255, 59, 212, 0.14);
  --accent-end: #4d8dff;  /* end of the .btn gradient */
  --on-accent: #04121f;   /* text on --accent */
  --glow-mid: #8a5bff;    /* middle of the .btn-glow gradient */

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.7);
  --font-ui: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Bungee', 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 8% -12%, rgba(120, 60, 255, 0.28), transparent 60%),
    radial-gradient(900px 560px at 108% 8%, rgba(0, 229, 255, 0.14), transparent 60%),
    radial-gradient(900px 600px at 50% 120%, rgba(255, 59, 212, 0.12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Subtle neon grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000 10%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000 10%, transparent 75%);
}

#app { position: relative; z-index: 1; min-height: 100vh; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.muted { color: var(--muted); }
.small { font-size: 14px; }
.noscript { padding: 24px; text-align: center; }

/* ---------- Cards & titles ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  min-width: 0;
}

.card-title {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-title {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 700;
}

.label {
  display: block;
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border: 0;
  border-radius: 14px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .01em;
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-end));
  box-shadow: 0 8px 24px -10px var(--accent);
  transition: transform .15s var(--ease), filter .15s, box-shadow .2s, background .2s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }

.btn-secondary {
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border-strong);
  box-shadow: none;
}
.btn-secondary:hover:not(:disabled) { background: rgba(255, 255, 255, .09); border-color: var(--accent); }

.btn-ghost {
  color: var(--muted);
  background: transparent;
  box-shadow: none;
}
.btn-ghost:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, .06); }

.btn-danger {
  color: #ffb3c1;
  background: rgba(255, 77, 109, .14);
  border: 1.5px solid rgba(255, 77, 109, .45);
  box-shadow: none;
}
.btn-danger:hover:not(:disabled) { background: rgba(255, 77, 109, .24); color: #fff; }

.btn-glow {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-2), var(--glow-mid) 60%, var(--accent));
  box-shadow: 0 10px 34px -10px var(--accent-2), 0 0 0 1px rgba(255, 255, 255, .08) inset;
}

.btn-lg { min-height: 56px; padding: 14px 26px; font-size: 18px; border-radius: 16px; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: 14px; border-radius: 11px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--faint);
  font-size: 14px;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--danger); background: rgba(255, 77, 109, .12); border-color: rgba(255, 77, 109, .35); }

/* ---------- Inputs ---------- */

.input, .select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--faint); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input-lg { min-height: 54px; font-size: 18px; padding: 12px 16px; }
.input-code {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: .32em;
  text-transform: uppercase;
  text-align: center;
}
.select { width: auto; padding-right: 32px; cursor: pointer; }
.select:disabled { opacity: .7; cursor: default; }

/* ---------- Feedback: spinner, banner, toasts ---------- */

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255, 255, 255, .15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex: 0 0 auto;
}
.spinner-lg { width: 42px; height: 42px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

.waiting {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 600;
  color: var(--muted);
}

.banner {
  position: fixed;
  top: 76px; /* below the game HUD */
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--warning);
  color: #261500;
  font-weight: 700;
  box-shadow: 0 10px 30px -10px rgba(255, 184, 77, .7);
  max-width: calc(100vw - 32px);
}
.banner::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #261500;
  animation: blink 1s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: .2; } }

/* Name of a non-production environment (pre-production, local dev), added by the server: see withEnvLabel().
   The client adds its testing tools next to it (envtools.js). */
.env-bar {
  position: fixed;
  left: 6px;
  top: 6px;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.env-label,
.env-join,
.env-theme {
  /* One box for the three pills (badge, theme menu, « + joueur »): same height, border and type. */
  display: inline-flex;
  align-items: center;
  height: 30px;
  margin: 0;
  padding: 0 12px;
  border: 2px solid var(--warning);
  border-radius: 999px;
  font: 800 14px/1 var(--font-ui);
  letter-spacing: .02em;
  box-shadow: 0 4px 14px -4px rgba(0, 0, 0, .6);
}
.env-label {
  background: var(--warning);
  color: #261500;
  letter-spacing: .08em;
}
.env-join,
.env-theme {
  background: #261500;
  color: var(--warning);
  cursor: pointer;
  pointer-events: auto;
}
.env-join:hover,
.env-theme:hover { background: #3d2300; }
a.env-join { text-decoration: none; }
/* Theme menu (envtools.js): a native select, its arrow kept. */
.env-theme { padding: 0 8px 0 10px; }
.env-theme option { background: #261500; color: #ffe2b8; }

.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 110;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  width: 100%;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow);
  font-weight: 600;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast.visible { opacity: 1; transform: none; }
.toast-error { border-left-color: var(--danger); }
.toast-success { border-left-color: var(--success); }

/* ---------- Shared bits ---------- */

.dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c, #888);
  box-shadow: 0 0 10px var(--c, transparent);
}

.tag-me { color: var(--accent); font-weight: 600; font-size: 14px; white-space: nowrap; }
.tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.tag-offline { background: rgba(255, 255, 255, .08); color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-spectator { background: var(--magenta-soft); color: #ff9ce9; border: 1px solid rgba(255, 59, 212, .4); }

/* ---------- Loading ---------- */

.loading { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.loading-card { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 36px 44px; text-align: center; }
.loading-card p { margin: 0; font-size: 18px; color: var(--muted); }

/* ---------- Home ---------- */

.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  min-height: 100vh;
  padding: 40px 16px;
}
.home-hero { text-align: center; }
.logo-badge {
  display: inline-grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin-bottom: 12px;
  border-radius: 24px;
  font-size: 40px;
  background: linear-gradient(135deg, var(--accent-2), #8a5bff 55%, var(--accent));
  box-shadow: 0 14px 40px -12px var(--accent-2);
  animation: float 4s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-6px) rotate(-3deg); } }

.title-display {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(40px, 9vw, 76px);
  line-height: 1.05;
  letter-spacing: .02em;
  background: linear-gradient(90deg, #8ff6ff, var(--accent) 35%, #b88cff 65%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 24px rgba(0, 229, 255, .35));
}
.tagline { margin: 10px 0 0; font-size: clamp(16px, 2.4vw, 20px); color: var(--muted); }

.home-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(460px, 100%);
  padding: 26px;
}
.field { margin: 0; }
.quick-join:empty { display: none; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--faint);
  font-size: 14px;
  font-weight: 600;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.join-form { display: flex; gap: 10px; }
.join-form .input-code { flex: 1 1 auto; }
.join-form .btn { flex: 0 0 auto; }
.home-footer { margin: 0; color: var(--faint); font-size: 14px; text-align: center; }

/* ---------- Lobby ---------- */

.lobby {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) minmax(280px, 360px);
  grid-template-areas:
    'header header header'
    'players main chat';
  align-items: start;
  gap: 18px;
  max-width: 1640px;
  margin: 0 auto;
  padding: 24px;
}

.lobby-header {
  grid-area: header;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 28px;
  padding: 18px 24px;
}
.code-block { display: flex; flex-direction: column; }
.code-block .label { margin-bottom: 2px; }
.room-code {
  font-family: var(--font-display);
  font-size: clamp(38px, 6vw, 56px);
  line-height: 1;
  letter-spacing: .14em;
  color: var(--accent-3);
  text-shadow: 0 0 22px rgba(255, 210, 63, .45);
}
.share-hint { flex: 1 1 220px; margin: 0; color: var(--muted); }
.header-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.lobby-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.lobby-players { grid-area: players; }
.lobby-main { grid-area: main; }
.lobby-chat { grid-area: chat; min-width: 0; position: sticky; top: 18px; }
.lobby-chat .chat { height: min(680px, calc(100vh - 60px)); }

.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface-2);
  transition: opacity .2s, background .2s;
}
.player-row.me { background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(0, 229, 255, .3); }
.player-row.offline { opacity: .5; }
.player-row.offline .dot { box-shadow: none; filter: grayscale(.6); }
.player-name {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.crown { font-size: 16px; }
.promote-btn, .kick-btn { margin-left: auto; }
.promote-btn + .kick-btn { margin-left: 0; }
.promote-btn:hover { color: #ffd23f; background: rgba(255, 210, 63, .12); border-color: rgba(255, 210, 63, .35); }

.rename-form { display: flex; gap: 8px; margin-bottom: 16px; }
.rename-form .btn { flex: 0 0 auto; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  position: relative;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .35) inset;
  transition: transform .15s var(--ease), box-shadow .15s;
}
.swatch:hover:not(:disabled) { transform: scale(1.12); }
.swatch.selected { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px #fff, 0 0 18px var(--c); }
.swatch:disabled { opacity: .22; cursor: not-allowed; }
.swatch:disabled::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 2px;
  background: #fff;
  transform: translateX(-50%) rotate(45deg);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 18px;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  text-align: left;
  color: var(--text);
  transition: transform .18s var(--ease), border-color .18s, box-shadow .18s, background .18s;
}
.game-card.clickable:hover { transform: translateY(-3px); border-color: var(--border-strong); background: rgba(255, 255, 255, .07); }
.game-card.selected {
  border-color: var(--accent);
  background: linear-gradient(160deg, rgba(0, 229, 255, .16), rgba(138, 91, 255, .1));
  box-shadow: 0 0 0 1px var(--accent) inset, 0 12px 36px -14px var(--accent);
}
.game-card.selected.clickable { cursor: default; transform: none; }
.game-icon { font-size: 38px; line-height: 1.1; margin-bottom: 6px; }
.game-name { font-size: 19px; font-weight: 800; }
.game-tagline { color: var(--muted); font-size: 15px; }
.game-players {
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.game-selected-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: #04121f;
  font-size: 12px;
  font-weight: 800;
}

.rules-settings { display: flex; flex-wrap: wrap; gap: 24px; }
.rules, .settings-wrap { flex: 1 1 260px; min-width: 0; }
.rules-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.rules-list li::marker { color: var(--accent); }

.settings { display: flex; flex-direction: column; gap: 10px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  min-height: 48px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}
.setting-label { font-weight: 600; }
.setting-hint { color: var(--muted); font-weight: 600; font-size: 15px; text-align: right; }

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  background: var(--input-bg);
  overflow: hidden;
}
.stepper-btn {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  transition: background .15s;
}
.stepper-btn:hover:not(:disabled) { background: var(--accent-soft); }
.stepper-btn:disabled { color: var(--faint); cursor: not-allowed; }
.stepper-value { min-width: 3ch; text-align: center; font-weight: 800; font-size: 18px; }
.stepper.readonly .stepper-btn { display: none; }
.stepper.readonly { padding: 6px 14px; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px;
  border: 0;
  background: transparent;
  font-weight: 600;
}
.toggle-track {
  position: relative;
  width: 50px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  transition: background .2s;
}
.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s var(--ease);
}
.toggle.on .toggle-track { background: var(--accent); box-shadow: 0 0 14px rgba(0, 229, 255, .5); }
.toggle.on .toggle-knob { transform: translateX(22px); }
.toggle:disabled { cursor: default; opacity: .75; }

/* One-click presets (meta.presets) */
.presets-row { align-items: flex-start; flex-direction: column; }
.presets { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.preset-group { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-btn {
  flex: 1 1 auto;
  min-height: 40px;
  padding: 6px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text);
  font-weight: 700;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.preset-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.preset-btn.on { border-color: var(--accent); background: var(--accent); color: #04121f; box-shadow: 0 0 14px rgba(0, 229, 255, .45); }
.preset-btn:disabled { cursor: default; }
.preset-btn:disabled:not(.on) { opacity: .7; }
.preset-hint { margin: 0; color: var(--muted); font-size: 14px; }

/* Advanced settings (def.advanced), folded by default */
.settings-advanced { border-bottom: 1px dashed var(--border); }
.settings-advanced > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  font-weight: 700;
  color: var(--muted);
  list-style: none;
}
.settings-advanced > summary::-webkit-details-marker { display: none; }
.settings-advanced > summary::before { content: '▸'; color: var(--accent); transition: transform .15s; }
.settings-advanced[open] > summary::before { transform: rotate(90deg); }
.settings-advanced > summary:hover { color: var(--text); }
.settings-custom {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--magenta-soft);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
}
.settings-advanced-body { display: flex; flex-direction: column; gap: 4px; padding: 0 0 8px 14px; }
.settings-advanced-body .setting-row:last-child { border-bottom: 0; }
.settings-group {
  margin: 10px 0 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
}
.settings-subgroup {
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.setting-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  vertical-align: middle;
}

.start-card { display: flex; flex-direction: column; align-items: center; text-align: center; }
.start-box { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.btn-start { min-width: min(320px, 100%); font-size: 20px; }
.start-status { margin: 0; font-weight: 600; }
.start-status.ok { color: var(--success); }
.start-status.blocked { color: var(--warning); }
.start-box .muted { margin: 0; }

/* ---------- Chat ---------- */

.chat { display: flex; flex-direction: column; min-height: 0; padding: 16px; position: relative; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-header .card-title { margin-bottom: 10px; }
.chat-toggle {
  position: relative;
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.chat.collapsible .chat-toggle { display: inline-flex; }
.chat-toggle:hover { border-color: var(--accent); }
.chat-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 12px rgba(255, 77, 109, .7);
}
.chat-list {
  flex: 1 1 auto;
  min-height: 120px;
  margin: 0;
  padding: 0 4px 0 0;
  list-style: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overscroll-behavior: contain;
}
.chat-msg { font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
.chat-msg.mine .chat-text { color: #d8fbff; }
.chat-msg.system {
  padding: 4px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  color: var(--muted);
  font-style: italic;
  font-size: 14px;
  text-align: center;
}
.chat-time { margin-right: 6px; color: var(--faint); font-size: 12px; font-style: normal; }
.chat-author { margin-right: 6px; font-weight: 700; }
.chat-form { display: flex; gap: 8px; margin-top: 12px; }
.chat-form .input { flex: 1 1 auto; }
.chat-form .btn { flex: 0 0 auto; min-height: 44px; }

.chat.collapsed { padding: 10px 8px; align-items: center; }
.chat.collapsed .card-title,
.chat.collapsed .chat-list,
.chat.collapsed .chat-form { display: none; }
.chat.collapsed .chat-toggle { margin: 0; }

/* Collapse arrow of the side panels (ui:chevron points right): toward where the panel folds, or opens. */
.panel-chevron { font-size: 18px; transition: transform .2s ease; }
.scoreboard:not(.collapsed) .panel-chevron,
.chat.collapsed .panel-chevron { transform: rotate(180deg); }

/* ---------- Game view ---------- */

.game-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: rgba(10, 14, 38, .82);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.hud-game { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-icon { font-size: 28px; }
.hud-name { font-size: 20px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-center { display: flex; align-items: center; gap: 18px; }
.hud-round {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 700;
  white-space: nowrap;
}
.hud-timer {
  min-width: 4.6ch;
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(0, 229, 255, .5);
  text-align: center;
}
.hud-timer.urgent {
  color: var(--danger);
  text-shadow: 0 0 20px rgba(255, 77, 109, .75);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.1); } }
.hud-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.sound-toggle { padding: 6px 10px; font-size: 20px; }

.game-body {
  --score-w: clamp(220px, 17vw, 300px);
  --chat-w: clamp(270px, 21vw, 380px);
  display: grid;
  grid-template-columns: var(--score-w) minmax(0, 1fr) var(--chat-w);
  grid-template-areas: 'score stage chat';
  gap: 14px;
  padding: 14px;
  min-height: 0;
}
.game-body:has(.chat.collapsed) { --chat-w: 58px; }
.game-body:has(.scoreboard.collapsed) { --score-w: 58px; }

.scoreboard { grid-area: score; display: flex; flex-direction: column; min-height: 0; padding: 16px; }
.scoreboard-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.scoreboard-header .card-title { margin-bottom: 10px; }
.score-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.score-toggle:hover { border-color: var(--accent); }
.scoreboard.collapsed { padding: 10px 8px; align-items: center; }
.scoreboard.collapsed .card-title,
.scoreboard.collapsed .score-list { display: none; }
.scoreboard.collapsed .score-toggle { margin: 0; }
.score-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.score-row {
  display: grid;
  grid-template-columns: 22px 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface-2);
  transition: background .2s, opacity .2s;
}
.score-row.team-row { grid-template-columns: 12px minmax(0, 1fr); }
.score-row.me { background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(0, 229, 255, .35); }
.score-row.offline { opacity: .45; }
.score-row.spectator .score-name { color: var(--muted); }
.score-row .rank { font-weight: 800; color: var(--muted); text-align: center; }
.score-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.score-values { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.score-total { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-gain { font-size: 13px; font-weight: 700; color: var(--faint); }
.score-gain.pos { color: var(--success); }
.score-gain.neg { color: var(--danger); }

.stage {
  grid-area: stage;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background:
    radial-gradient(ellipse at 50% 30%, rgba(60, 80, 200, .18), transparent 70%),
    rgba(5, 8, 24, .85);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, .5), var(--shadow);
}
.game-host, .game-container { position: absolute; inset: 0; }
.game-chat { grid-area: chat; min-width: 0; min-height: 0; display: flex; }
.game-chat .chat { flex: 1 1 auto; }

.game-unavailable {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
  text-align: center;
}
.game-unavailable h2 { margin: 8px 0; font-size: 26px; }
.game-unavailable p { margin: 0; max-width: 420px; color: var(--muted); }
.big-emoji { font-size: 56px; }

/* ---------- Overlays ---------- */

.overlay-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  pointer-events: auto;
  animation: fade-in .25s var(--ease);
}
/* Compact pill at the top: the game stays visible below (players must spot their own bike/spawn). */
.overlay-countdown { background: transparent; align-items: flex-start; padding-top: 12px; pointer-events: none; }
.overlay-roundEnd { background: rgba(7, 10, 26, .84); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.overlay-matchEnd { background: rgba(7, 10, 26, .94); }
/* Result cards can be taller than the stage (12 players): scroll instead of clipping both ends. */
.overlay-roundEnd, .overlay-matchEnd { align-items: flex-start; overflow-y: auto; }
@keyframes fade-in { from { opacity: 0; } }

.overlay-card {
  width: min(560px, 100%);
  padding: 26px;
  border-radius: 22px;
  background: rgba(20, 26, 62, .9);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow), 0 0 60px -20px rgba(138, 91, 255, .6);
  text-align: center;
}
.countdown-card {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 18px;
  width: auto;
  max-width: 100%;
  padding: 10px 26px 10px 22px;
  border-radius: 999px;
  background: rgba(20, 26, 62, .88);
  text-align: left;
}
.countdown-card > * { grid-column: 2; }
.countdown-card .countdown-number { grid-column: 1; grid-row: 1 / span 3; font-size: clamp(40px, 7vmin, 56px); line-height: 1; }
.countdown-card .overlay-kicker { font-size: 12px; }
.countdown-card .overlay-title { margin: 0; font-size: clamp(18px, 2.4vw, 22px); }
.countdown-card .overlay-sub { font-size: 14px; }
.roundend-card { margin: auto 0; } /* centred when it fits, top-aligned and scrollable when it does not */
.matchend-card { width: min(980px, 100%); margin: auto 0; }
.matchend-card.coop { width: min(640px, 100%); }

/* Team result (cooperative games, ctx.endRound(result)) */
.team-result { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 10px 0 6px; }
.team-emoji {
  font-size: clamp(64px, 12vmin, 96px);
  line-height: 1;
  filter: drop-shadow(0 0 24px rgba(255, 210, 63, .55));
  animation: rise .6s var(--ease) both, float 3.2s ease-in-out .6s infinite;
}
.team-title {
  max-width: 100%;
  font-family: var(--font-display);
  font-size: clamp(22px, 4vw, 34px);
  line-height: 1.15;
  background: linear-gradient(90deg, var(--accent-3), var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rise .6s var(--ease) .1s both;
}
.team-sub { color: var(--text); font-size: clamp(17px, 2.4vw, 21px); font-weight: 700; }
.team-tokens { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 520px; }
.team-token {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 22px;
  animation: rise .4s var(--ease) both;
  animation-delay: calc(.35s + var(--i, 0) * .08s);
}
.team-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 6px 0 0; }
.team-stat { min-width: 120px; padding: 8px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.team-stat dt { color: var(--muted); font-size: 13px; font-weight: 700; }
.team-stat dd { margin: 2px 0 0; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.team-members { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; margin-top: 16px; color: var(--muted); }
.team-round + .team-round { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--border); }
.team-round-label { font-weight: 700; color: var(--muted); }
@media (prefers-reduced-motion: reduce) {
  .team-emoji, .team-title, .team-token { animation: none; }
}
.overlay-kicker { font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-size: 14px; }
.overlay-title { margin: 6px 0 14px; font-size: clamp(24px, 3.4vw, 34px); font-weight: 800; }
.overlay-sub { color: var(--muted); font-size: 18px; font-weight: 600; }
.overlay-footer { margin-top: 16px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }

.countdown-number {
  font-family: var(--font-display);
  font-size: clamp(90px, 16vmin, 150px);
  line-height: 1.05;
  color: var(--accent-3);
  text-shadow: 0 0 30px rgba(255, 210, 63, .6), 0 0 80px rgba(255, 59, 212, .35);
}
.countdown-number.pop { animation: pop .45s var(--ease); }
@keyframes pop { from { transform: scale(1.6); opacity: .2; } }

.rank-table { width: 100%; border-collapse: collapse; text-align: left; font-variant-numeric: tabular-nums; }
.rank-table th {
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
  border-bottom: 1px solid var(--border);
}
.rank-table td { padding: 9px 10px; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.rank-table tr.me td { background: var(--accent-soft); }
.rank-table .num { text-align: right; }
.rank-table .rank { font-weight: 800; color: var(--muted); width: 2.5ch; }
.rank-table .gain { color: var(--success); font-weight: 800; }
.rank-table .total { font-weight: 800; }

.who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(8px, 2vw, 20px);
  margin: 10px 0 24px;
}
.podium-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: clamp(92px, 16vw, 160px);
  min-width: 0;
  animation: rise .6s var(--ease) both;
}
.podium-step.rank-1 { animation-delay: .25s; }
.podium-step.rank-3 { animation-delay: .1s; }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.podium-medal { font-size: 34px; line-height: 1; }
.podium-avatar {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--c);
  color: #0b0e24;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .85), 0 0 26px var(--c);
}
.podium-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.podium-score { color: var(--muted); font-weight: 700; font-size: 15px; }
.podium-block {
  display: grid;
  place-items: center;
  width: 100%;
  margin-top: 6px;
  border-radius: 14px 14px 4px 4px;
  font-family: var(--font-display);
  font-size: 30px;
  color: rgba(255, 255, 255, .9);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 70%, transparent), rgba(255, 255, 255, .04));
  border: 1px solid color-mix(in srgb, var(--c) 60%, transparent);
}
.podium-step.rank-1 .podium-block { height: 130px; }
.podium-step.rank-2 .podium-block { height: 96px; }
.podium-step.rank-3 .podium-block { height: 70px; }
.podium-step.me .podium-name { color: var(--accent); }

.final-grid { display: flex; flex-wrap: wrap; gap: 24px; text-align: left; }
.final-col { flex: 1 1 300px; min-width: 0; }
.final-ranking { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.final-ranking li {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface-2);
}
.final-ranking li.me { background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(0, 229, 255, .35); }
.final-ranking .rank { font-weight: 800; font-size: 18px; text-align: center; }
.final-ranking .total { font-weight: 800; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
.history-table th, .history-table td { padding-left: 6px; padding-right: 6px; }
.history-table .who-name { max-width: 9em; }
.history-table .tag-me { display: none; }
.overlay-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 26px; }
.matchend-card .waiting { margin-top: 26px; }

/* ---------- Explanation screen before a match (public/js/views/briefing.js) ---------- */

.overlay-briefing { background: rgba(7, 10, 26, .94); align-items: flex-start; overflow-y: auto; }
.briefing-card { width: min(1000px, 100%); margin: auto 0; padding-bottom: 0; text-align: left; }
.briefing-card > .overlay-kicker, .briefing-card > .overlay-title { text-align: center; }
.briefing-card > .overlay-kicker { font-size: 12px; }
.briefing-card > .overlay-title { margin: 2px 0 2px; font-size: clamp(22px, 3vw, 30px); }
.briefing-tagline { margin: 0 0 14px; text-align: center; color: var(--muted); font-weight: 600; }
.briefing-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.briefing-demo {
  position: relative;
  aspect-ratio: 4 / 3;
  max-height: 48vh;
  border-radius: 16px;
  overflow: hidden;
  background: #03050c;
  border: 1px solid var(--border-strong);
  box-shadow: 0 0 40px -18px var(--accent);
}
.briefing-demo.is-empty { display: grid; place-items: center; background: var(--surface-2); box-shadow: none; }
.briefing-demo-icon { font-size: 96px; line-height: 1; opacity: .85; }
.briefing-demo canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.briefing-rules { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.briefing-rule {
  display: flex;
  gap: 12px;
  padding: 7px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--muted);
  line-height: 1.4;
  transition: background .3s var(--ease), color .3s var(--ease), border-color .3s var(--ease);
}
.briefing-rule.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.briefing-rule-num { font-family: var(--font-display); color: var(--accent-3); min-width: 26px; }
.briefing-controls { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 8px; }
.briefing-controls-title { font-weight: 700; letter-spacing: .1em; text-transform: uppercase; font-size: 12px; color: var(--muted); }
.briefing-control { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; color: var(--muted); }
.briefing-keys { display: inline-flex; gap: 5px; }
.briefing-key {
  min-width: 30px;
  padding: 3px 9px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 3px;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}
/* Stuck to the bottom of the screen while the card scrolls: « Je suis prêt » stays in sight on a short screen. */
.briefing-footer {
  position: sticky;
  bottom: -20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 18px -26px 0;
  padding: 14px 26px 20px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 22px 22px;
  background: var(--surface-solid);
}
.briefing-players { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.briefing-player {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  background: var(--surface-2);
  color: var(--muted);
}
.briefing-player.ready { color: var(--text); border-style: solid; border-color: var(--success); }
.briefing-player-name { font-weight: 600; max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.briefing-player-state { display: inline-flex; font-size: 13px; font-weight: 700; }
.briefing-player.ready .briefing-player-state { color: var(--success); }
.briefing-player.offline { opacity: .55; }
.briefing-player.offline .dot { box-shadow: none; filter: grayscale(.6); }
.briefing-end { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; margin-left: auto; }
.briefing-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.briefing-waiting { color: var(--muted); font-weight: 600; }
/* « Je suis prêt » of the last player not ready: a flash of light sweeps the button, which pulses. */
.briefing-nudge { position: relative; overflow: hidden; animation: ready-pulse 1.6s var(--ease) infinite; }
.briefing-nudge::after {
  content: '';
  position: absolute;
  inset: -20% auto -20% -60%;
  width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .75), transparent);
  transform: skewX(-20deg);
  animation: ready-flash 1.6s var(--ease) infinite;
  pointer-events: none;
}
@keyframes ready-pulse {
  0%, 100% { transform: scale(1); }
  12% { transform: scale(1.07); box-shadow: 0 0 0 4px rgba(255, 255, 255, .35), 0 0 40px 4px var(--accent-2); }
  30% { transform: scale(1); }
}
@keyframes ready-flash {
  0% { left: -60%; }
  35%, 100% { left: 130%; }
}
.briefing-watch { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; }
@media (max-width: 760px) {
  .briefing-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .briefing-card { padding: 18px 18px 0; }
  .briefing-footer { margin: 14px -18px 0; padding: 12px 18px 18px; }
  .briefing-end { margin-left: 0; width: 100%; justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) {
  .briefing-rule { transition: none; }
  .briefing-nudge { animation: none; box-shadow: 0 0 0 3px #fff, 0 0 30px 2px var(--accent-2); }
  .briefing-nudge::after { display: none; }
}

/* ---------- Player feedback (public/js/views/feedback.js) ---------- */

/* End-of-match vote */
.vote-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 22px auto 0;
  max-width: 460px;
}
.vote-question { color: var(--muted); font-weight: 700; }
.vote-choices { display: flex; gap: 10px; }
.vote-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 84px;
  padding: 10px 12px 8px;
  border: 1.5px solid var(--border-strong);
  border-radius: 14px;
  background: var(--input-bg);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform .15s var(--ease), border-color .15s, background .15s;
}
.vote-btn .icon { font-size: 34px; }
.vote-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--accent); background: var(--accent-soft); }
.vote-btn:disabled { cursor: default; opacity: .6; }
.vote-done { display: flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 700; }
.vote-done .icon { font-size: 24px; }
.vote-comment { display: flex; gap: 8px; width: 100%; align-items: center; }
.vote-comment .input { flex: 1 1 auto; }
.feedback-text { resize: vertical; min-height: 44px; line-height: 1.4; }

/* « Donner mon avis » */
.home-extras { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; margin-top: -14px; }
.home-extras .theme-toggle.home-theme { margin-top: 0; }
.feedback-btn .icon { font-size: 20px; }
.header-actions .btn.feedback-btn { flex: 0 0 auto; min-height: 44px; }
.feedback-card { text-align: left; }
.feedback-card .confirm-title, .feedback-card .confirm-message { text-align: center; }
.feedback-kinds { margin: 18px 0 10px; }
.feedback-kinds .preset-btn { flex: 1 1 0; }
.feedback-card .feedback-text { display: block; }
/* Honeypot of the bots: out of sight and out of reach (not display: none, which some bots skip). */
.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }

/* ---------- Confirmation dialog (public/js/dialog.js) ---------- */

.confirm-dialog {
  width: min(440px, calc(100vw - 32px));
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: visible;
}
.confirm-dialog[open] { animation: confirm-in .22s var(--ease); }
.confirm-dialog::backdrop {
  background: rgba(7, 10, 26, .78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-in .22s var(--ease);
}
@keyframes confirm-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.confirm-card {
  padding: 26px 24px 22px;
  border-radius: 22px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow), 0 0 60px -20px rgba(138, 91, 255, .6);
  text-align: center;
}
.confirm-title { margin: 0; font-size: 22px; font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; }
.confirm-message { margin: 10px 0 0; color: var(--muted); font-weight: 600; line-height: 1.45; }
.confirm-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 22px; }
.confirm-actions .btn { flex: 1 1 140px; }

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .lobby {
    grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
    grid-template-areas:
      'header header'
      'players main'
      'chat chat';
  }
  .lobby-chat { position: static; }
  .lobby-chat .chat { height: 420px; }
}

@media (max-width: 980px) {
  .game-view { height: auto; min-height: 100vh; }
  .hud { grid-template-columns: minmax(0, 1fr) auto; }
  .hud-center { grid-column: 1 / -1; grid-row: 2; justify-content: center; }
  .game-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'stage' 'score' 'chat';
    align-content: start;
  }
  .stage { height: 62vh; min-height: 340px; }
  .scoreboard.collapsed { align-items: flex-start; }
  /* Collapsed scoreboard: the stage fills the screen down to the thin bar instead of keeping 62vh. */
  .game-view:has(.scoreboard.collapsed) { min-height: 100vh; min-height: 100dvh; }
  .game-body:has(.scoreboard.collapsed) { grid-template-rows: minmax(340px, 1fr) auto auto; }
  .game-body:has(.scoreboard.collapsed) .stage { height: auto; }
  .game-chat .chat { height: 360px; }
  .game-chat .chat.collapsed { height: auto; align-items: flex-start; }
  /* Panels stacked under the stage: the arrow points down to open, up to fold. */
  .game-body .scoreboard .panel-chevron,
  .game-chat .chat .panel-chevron { transform: rotate(-90deg); }
  .game-body .scoreboard.collapsed .panel-chevron,
  .game-chat .chat.collapsed .panel-chevron { transform: rotate(90deg); }
}

@media (max-width: 760px) {
  .lobby {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'header' 'players' 'main' 'chat';
    padding: 16px;
    gap: 14px;
  }
  .card { padding: 16px; }
  .lobby-header { padding: 16px; }
  .header-actions { width: 100%; }
  .header-actions .btn { flex: 1 1 auto; }
  .game-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 420px) {
  .join-form { flex-direction: column; }
  .home-card { padding: 20px; }
  .rename-form { flex-wrap: wrap; }
  .rename-form .btn { flex: 1 1 auto; }
}

/* ---------- Hidden chat (CHAT_ENABLED = false in views/chat.js) ---------- */

.no-chat .lobby-chat,
.no-chat .game-chat { display: none; }
.no-chat .lobby {
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  grid-template-areas:
    'header header'
    'players main';
}
.no-chat .game-body {
  grid-template-columns: var(--score-w) minmax(0, 1fr);
  grid-template-areas: 'score stage';
}

@media (max-width: 1180px) {
  .no-chat .lobby { grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); }
}

@media (max-width: 980px) {
  .no-chat .game-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'stage' 'score';
  }
}

@media (max-width: 760px) {
  .no-chat .lobby {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'header' 'players' 'main';
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Custom icons (public/js/icons.js): neon strokes with a glow in the icon's colour. */
.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; overflow: visible;
  stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 3px var(--icon-glow, currentColor)); }
