:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: #e6eaf2;
  background: #000;
  font-synthesis: none;
  --accent: #6c9cf0;
  --border: #2b3240;
  --stop: #ff5558;
  --muted: #9aa6bb;
  --btn-bg: #141922;
  --btn-border: #3a4352;
}
* { box-sizing: border-box; }
body { margin: 0; }
.header {
  min-height: 86px;
  margin: 0 12px;
  padding: 10px 24px 16px;
  display: flex;
  align-items: center;
  gap: 30px;
  border-bottom: 1px solid var(--border);
}
h1 { font-size: clamp(30px, 3.25vw, 48px); line-height: 1.1; letter-spacing: -1.5px; margin: 0; font-weight: 800; }
.header-title { padding-left: 30px; border-left: 2px solid var(--border); font-size: clamp(20px, 2.35vw, 36px); font-weight: 750; letter-spacing: -.7px; }
.mode { margin-left: auto; color: var(--accent); font-size: clamp(15px, 1.6vw, 23px); font-weight: 750; text-align: right; }
main { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 12px; padding: 12px; align-items: start; }
.panel { min-width: 0; padding: 14px 16px 16px; border: 1px solid var(--border); border-radius: 14px; }
h2 { margin: 0; font-size: 20px; line-height: 1.2; font-weight: 800; letter-spacing: -.4px; }
p { margin: 0; }
.subtitle { margin-top: 4px; font-size: 14px; line-height: 1.4; color: var(--muted); }
.video-placeholder {
  aspect-ratio: 16 / 9;
  margin: 0;
  padding: 22px;
  border-radius: 15px;
  background: #293346;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 25px;
  text-align: center;
  box-shadow: 0 2px 3px #10214518;
}
.video-frame {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 24px - 32px);
  margin: 0;
  border: 0;
  border-radius: 15px;
  background: #000;
  /* Le clavier et les appuis restent sur la télécommande. */
  pointer-events: none;
}
.video-frame[hidden], .video-placeholder[hidden], .video-mode[hidden] { display: none; }
legee-video { display: block; width: 100%; height: 100%; }
.video-panel { position: relative; }
.video-mode { position: absolute; top: 14px; right: 18px; font-size: 12px; color: #fff; text-shadow: 0 0 3px #000; pointer-events: none; }
.camera { width: 100px; height: 84px; fill: none; stroke: currentColor; stroke-width: 7; stroke-linejoin: round; }
.video-placeholder p { font-size: 18px; font-weight: 650; letter-spacing: -.6px; }
.video-panel { padding: 8px; }
.instruction { font-size: 14px; }
.direction-pad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; max-width: 210px; margin: 12px auto 10px; }
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: none; user-select: none; -webkit-user-select: none; }
.direction, .stop, .home { aspect-ratio: 1.05; border-radius: 12px; border: 2px solid var(--btn-border); background: var(--btn-bg); color: #e6eaf2; display: flex; align-items: center; justify-content: center; transition: background-color .1s, border-color .1s; }
.direction svg { width: 36%; height: 36%; fill: currentColor; }
.home { grid-column: 3; grid-row: 1; width: 100%; margin: 0; }
.home svg { width: 44%; height: 44%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.direction:hover:not(:disabled), .home:hover:not(:disabled) { background: #1d2431; border-color: #6a7a96; }
.direction.pressed { background: #1c2f52; border-color: var(--accent); color: var(--accent); }
.direction:focus-visible, .stop:focus-visible, .home:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.direction:disabled, .home:disabled { cursor: default; opacity: .5; }
.forward { grid-column: 2; grid-row: 1; }
.left { grid-column: 1; grid-row: 2; }
.right { grid-column: 3; grid-row: 2; }
.backward { grid-column: 2; grid-row: 2; }
.stop { grid-column: 1; grid-row: 1; background: var(--btn-bg); border-color: var(--stop); color: var(--stop); flex-direction: column; gap: 4px; font-size: 14px; font-weight: 750; }
.stop:hover:not(:disabled), .stop:active { background: #3a1517; }
.stop:disabled { opacity: .5; cursor: default; }
.stop-square { width: 27%; aspect-ratio: 1; background: var(--stop); border-radius: 5px; }
.help { font-size: 13px; line-height: 1.4; }
.help strong { font-weight: 750; }
.status-area { margin: 12px 0 0; padding: 10px 0 0; border-top: 2px solid var(--border); }
.status { color: var(--accent); font-size: 15px; font-weight: 750; line-height: 1.3; }
.status.error { color: #ff7478; }
.mode-description { font-size: 13px; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.session { margin-top: 4px; font-size: 13px; color: var(--muted); }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; touch-action: auto; }
.login-page { min-height: 100vh; display: grid; place-items: center; }
.login-panel { display: grid; gap: 12px; width: min(340px, 92vw); padding: 20px; }
.login-panel label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.login-panel input { font: inherit; padding: 8px 10px; color: inherit; background: var(--btn-bg); border: 2px solid var(--btn-border); border-radius: 8px; }
.login-panel input:focus-visible { outline: 2px solid var(--accent); }
.login-button { padding: 10px; font-weight: 750; color: #e6eaf2; background: #1c2f52; border: 2px solid var(--accent); border-radius: 8px; touch-action: auto; }
@media (max-width: 760px) {
  main { grid-template-columns: 1fr; padding: 8px; gap: 8px; }
  .video-frame { border-radius: 10px; max-height: none; }
  .video-placeholder { border-radius: 10px; }
  .camera { width: 58px; height: 49px; }
  .direction-pad { max-width: 240px; }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } }

.stop.start-mode .stop-square { width: 0; height: 0; border-top: 15px solid transparent; border-bottom: 15px solid transparent; border-left: 24px solid #22c55e; background: transparent; border-radius: 0; }
.stop.start-mode { color: #22c55e; border-color: #22c55e; }
