:root {
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  color: #f5fbff;
  background: #07151f;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% -10%,#12394b,#07151f 55%);
}

.app-shell {
  max-width: 520px;
  width: 100%;
  flex: 1 0 auto;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(26px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 2px;
  color: #72e2bc;
  margin: 0 0 5px;
  font-weight: 700;
}

h1,h2,p {
  margin-top: 0;
}

h1 {
  font-size: 26px;
  margin-bottom: 0;
}

h2 {
  font-size: 20px;
}

.session-stats {
  text-align: right;
  color: #a9bec6;
  font-size: 12px;
  display: none;
  gap: 4px;
}

.session-stats span:first-child {
  font-size: 25px;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.panel,.instruction-card {
  background: linear-gradient(145deg,#132e3b,#0d222d);
  border: 1px solid #2d4b59;
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 18px 50px #0003;
}

.panel p {
  color: #a9bec6;
  line-height: 1.5;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 13px 20px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}

button:disabled {
  opacity: .45;
}

.primary {
  background: #32e58b;
  color: #052018;
}

.secondary {
  background: #203e4b;
  color: #dcecf0;
}

.error {
  color: #ff8b8b!important;
}

.camera-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 9/16;
  border-radius: 22px;
  overflow: hidden;
  background: #020b10;
  border: 1px solid #31515d;
}

.camera-wrap video,.camera-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scaleX(-1);
}

.camera-wrap canvas {
  pointer-events: none;
}

.instruction-card {
  margin-top: 0;
  text-align: center;
  padding: 20px;
}

.instruction-label {
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 1.5px;
  color: #b2c8d0;
  font-weight: 700;
  text-align: left;
}

.target-name {
  font-size: clamp(27px,6vw,36px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.035em;
  margin: 0 0 6px;
  overflow-wrap: anywhere;
}

.court-diagram {
  position: relative;
  margin: auto;
  max-width: 560px;
  width: 100%;
  aspect-ratio: 8.133333/5.052;
  overflow: visible;
}
.court-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.court-ground { fill: #07534c; }
.court-line {
  fill: none;
  stroke: #fff;
  stroke-width: .04;
  stroke-linecap: square;
}
.court-line-net { stroke-width: .08; }
.court-line-selection { stroke-dasharray: .12 .1; }
.court-net-label { fill: #dcecf0; font-size: .25px; font-weight: 700; text-anchor: middle; letter-spacing: .04px; }
.center-area { fill: #ffffff18; stroke: #fff; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.target-area { fill: #ffffff18; stroke: #fff; stroke-width: 1.5px; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.target-area[hidden] { display: none; }
.target-area.target-reached { fill: #32e58b33; stroke-dasharray: none; }
.court-center {
  position: absolute;
  transform: translate(-50%,-50%);
}

.target-dot {
  position: absolute;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  transform: translate(-50%,-50%);
  transition: left .2s, top .2s;
}
.target-dot[hidden] { display: none; }
.target-dot::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  transform: translate(-50%,-50%) rotate(45deg);
  border: 2px solid #fff;
  background: #ff4566;
  box-shadow: 0 0 0 2px #07151f;
}
.target-zone {
  position: relative;
  color: #07151f;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
}
.target-check {
  position: absolute;
  left: calc(50% + 9px);
  top: calc(50% - 30px);
  width: 23px;
  height: 23px;
  border-radius: 50%;
  border: 2px solid #07151f;
  background: #fff;
  color: #07151f;
  font-size: 17px;
  font-weight: 900;
  line-height: 19px;
}
.player-dot {
  position: absolute;
  width: 26px;
  height: 26px;
  transform: translate(-50%,-50%);
  border-radius: 50%;
  border: 3px dashed #fff;
  background: transparent;
  box-shadow: 0 0 0 2px #07151f;
  pointer-events: none;
}

.session-actions {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  max-width: 340px;
  gap: 10px;
  margin: 16px auto 0;
  padding-top: 16px;
  border-top: 1px solid #ffffff10;
}

.debug-panel {
  margin-top: 14px;
  color: #9fbac3;
  font-size: 12px;
}

.debug-panel pre {
  white-space: pre-wrap;
  background: #06131d;
  padding: 12px;
  border-radius: 12px;
  line-height: 1.45;
}

.calibration-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.calibration-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.calibration-point {
  position: absolute;
  width: 25px;
  height: 25px;
  border: 3px solid #fff;
  background: #ff4566;
  border-radius: 50%;
  transform: translate(-50%,-50%);
  box-shadow: 0 0 0 7px #ff456655;
}

.calibration-label {
  position: absolute;
  background: #06131ddd;
  padding: 5px 7px;
  border-radius: 7px;
  font-size: 11px;
  transform: translate(-50%,22px);
  white-space: nowrap;
}

/* Calibration et retour caméra */
.calibrating .instruction-card { display: none; }
.session-live .calibration-camera { display: none; }
.calibration-mode .calibration-camera { height: 100%; }
.calibration-mode { height: 100svh; min-height: 100svh; }
.calibration-mode .app-shell {
  max-width: none;
  height: auto;
  min-height: 0;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
}
.calibration-mode .topbar { display: none; }
.calibration-mode .camera-wrap {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 16px;
}
.calibration-mode #calibration-panel {
  flex: 0 0 auto;
  margin: 0;
  padding: 14px;
}

/* Consignes temporaires : les boutons restent accessibles. */
.fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: #07151fd9;
  backdrop-filter: blur(5px);
  pointer-events: none;
}
.fullscreen-overlay[hidden] { display: none; }
.fullscreen-overlay > div {
  font-size: min(66vw,450px);
  font-weight: 900;
  line-height: 1;
  color: #32e58b;
  text-shadow: 0 0 35px #32e58b88;
}
.zone-flash > div { color: #ff4967; text-shadow: 0 0 35px #ff496788; }
@keyframes zone-fade {
  0% { opacity: 1; transform: scale(1.15); }
  100% { opacity: 0; transform: scale(1); }
}
.main-menu-button {
  min-height: 44px;
  font-size: 13px;
  padding: 10px 16px;
  background: transparent;
  color: #b2c8d0;
  border: 1px solid #365360;
}

.center-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  transform: translate(-50%,-50%);
  border-radius: 50%;
  background: #33df88;
  color: #07151f;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #07151f;
  font-size: 19px;
  font-weight: 900;
}
.court-center,.target-dot,.player-dot { z-index: 8; }
.target-dot.target-reached::before { background: #32e58b; }
.court-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  margin: 14px 0 0;
  font-size: 13px;
  color: #dcecf0;
}
.court-legend span { display: inline-flex; align-items: center; gap: 5px; }
.court-legend b { color: #fff; font-size: 17px; }
.app-footer {
  flex: 0 0 auto;
  width: 100%;
  padding: 0 12px calc(8px + env(safe-area-inset-bottom));
  text-align: right;
}
.app-version {
  display: inline-block;
  color: rgba(220,240,244,.5);
  font: 11px ui-monospace,SFMono-Regular,Menlo,monospace;
  background: transparent;
  border: 0;
  padding: 4px 6px;
  cursor: pointer;
}

/* Les repères renforcés sont activables depuis la préparation. */
body:not(.colorblind-mode) .target-dot::before {
  width: 23px;
  height: 23px;
  border-radius: 50%;
  transform: translate(-50%,-50%);
  border: 0;
  box-shadow: 0 0 0 7px #ff456633;
}
body:not(.colorblind-mode) .target-dot.target-reached::before { box-shadow: 0 0 0 7px #32e58b33; }
body:not(.colorblind-mode) .target-zone,
body:not(.colorblind-mode) .target-check,
body:not(.colorblind-mode) .court-legend { display: none; }
body:not(.colorblind-mode) .center-mark {
  width: 18px;
  height: 18px;
  font-size: 0;
  box-shadow: none;
}
body:not(.colorblind-mode) .player-dot {
  width: 12px;
  height: 12px;
  border: 0;
  background: #fff;
  box-shadow: none;
}

.section-kicker { color: #8fe6c6; font-size: 10px; letter-spacing: 1.8px; font-weight: 750; margin: 0 0 9px; }
.panel .section-kicker { color: #8fe6c6; }
.setup-panel h2,.finish-panel h2 { font-size: 29px; letter-spacing: -.6px; margin-bottom: 10px; }
.setup-intro { font-size: 14px; margin-bottom: 18px; }
.setup-fields { display: grid; gap: 12px; margin-bottom: 16px; }
.setup-options { border: 1px solid #2d4b59; border-radius: 16px; margin-bottom: 16px; overflow: hidden; }
.option-row { display: flex; align-items: center; gap: 12px; padding: 12px; cursor: pointer; }
.option-row + .option-row { border-top: 1px solid #2d4b59; }
.option-row input { width: 20px; height: 20px; flex: 0 0 20px; accent-color: #32e58b; }
.option-row strong { display: block; font-size: 14px; font-weight: 650; }
.option-row small { display: block; color: #a9bec6; line-height: 1.5; font-size: 12px; margin-top: 3px; }
.setup-panel .primary,.finish-panel .primary { width: 100%; min-height: 48px; }
.session-active .session-stats { display: grid; }
.instruction-hero {
  display: grid;
  grid-template-columns: 52px minmax(0,1fr);
  gap: 14px;
  align-items: center;
  min-height: 92px;
  padding: 12px 0 16px;
}
.instruction-symbol {
  display: grid;
  place-items: center;
  height: 52px;
  border-radius: 14px;
  background: #ff45661a;
  color: #ff7189;
  border: 1px solid #ff45664d;
  font-size: 34px;
  font-weight: 850;
  line-height: 1;
}
.instruction-copy { text-align: left; min-width: 0; }
.target-side {
  color: #a9bec6;
  font-size: 14px;
  line-height: 1.4;
}
.instruction-card[data-phase="RETURNING_TO_CENTER"] .instruction-symbol,
.instruction-card[data-phase="AT_CENTER"] .instruction-symbol,
.instruction-card[data-phase="AT_TARGET"] .instruction-symbol,
.instruction-card[data-phase="COUNTDOWN"] .instruction-symbol { background: #32e58b15; color: #7df0b6; border-color: #32e58b55; }
.instruction-card[data-phase="RETURNING_TO_CENTER"] .center-area { stroke-width: 2.5px; fill: #32e58b30; }
.instruction-card[data-phase="RETURNING_TO_CENTER"] .target-dot { opacity: .5; }
.tracking-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  margin: 0 0 14px;
  padding: 8px 10px;
  border: 1px solid #e4b86938;
  border-radius: 10px;
  background: #e4b8690b;
  color: #ffda99;
  font-size: 12px;
  line-height: 1.4;
}
.tracking-status[hidden] {
  display: none;
}
.stop-button { min-height: 44px; background: #244453; }
.calibration-mode #session-panel { flex: 1 1 0; min-height: 0; }
.calibration-mode .debug-panel { display: none; }
.text-button { background: transparent; color: #b8cbd3; font-size: 13px; padding: 10px; margin-right: auto; min-height: 44px; }
#calibration-panel h2 { font-size: 18px; margin-bottom: 8px; }
#calibration-panel p { font-size: 13px; margin-bottom: 10px; }
.finish-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 24px 0; }
.finish-stats div { padding: 18px 10px; border: 1px solid #2d4b59; border-radius: 16px; text-align: center; }
.finish-stats b { display: block; font-size: 32px; font-variant-numeric: tabular-nums; }
.finish-stats span { color: #a9bec6; font-size: 12px; }
button:focus-visible,input:focus-visible,summary:focus-visible { outline: 3px solid #8fe6c6; outline-offset: 4px; }
@media (max-width: 350px), (max-height: 620px) {
  .app-shell { padding: calc(12px + env(safe-area-inset-top)) 12px calc(24px + env(safe-area-inset-bottom)); }
  .topbar { margin-bottom: 12px; }
  .instruction-card { padding: 14px; }
  .instruction-hero { min-height: 86px; grid-template-columns: 46px minmax(0,1fr); gap: 12px; }
  .instruction-symbol { height: 46px; font-size: 30px; border-radius: 12px; }
  .target-name { font-size: 27px; }
  .target-side { font-size: 14px; }
}

.setup-panel { padding: 20px; }

.tracking-status.tracking-ok { background: #32e58b0b; border-color: #32e58b30; color: #9ee7c0; }

.debug-camera-control { display: none; }
.session-active .debug-camera-control { display: flex; align-items: center; gap: 10px; margin: 14px 0; font-size: 13px; cursor: pointer; }
.debug-camera-control input { width: 20px; height: 20px; accent-color: #32e58b; }
#debug-camera { max-width: 320px; margin: 0 auto 12px; }
#debug-camera[hidden] { display: none; }
#debug-camera .camera-wrap { border-radius: 14px; }

/* Choix courts : toutes les options restent visibles, avec un choix actif distinct. */
.choice-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.choice-field legend { padding: 0; margin-bottom: 9px; color: #bdced4; font-size: 13px; font-weight: 600; }
.choice-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.choice-options-three { grid-template-columns: repeat(3,minmax(0,1fr)); }
.choice { position: relative; cursor: pointer; min-width: 0; }
.choice input { position: absolute; width: 1px; height: 1px; opacity: 0; clip-path: inset(50%); }
.choice-content {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0,1fr);
  place-items: center;
  text-align: center;
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid #365360;
  border-radius: 12px;
  background: #0a202b;
  color: #aebfc7;
  font-size: 14px;
  font-weight: 600;
  transition: background .15s, border-color .15s, color .15s;
}
.choice-label { line-height: 1.2; white-space: nowrap; }
.choice input:checked + .choice-content { background: #22483f; border-color: #7ddfba; color: #effff8; font-weight: 750; }
.choice input:focus-visible + .choice-content { outline: 3px solid #8fe6c6; outline-offset: 3px; }
@media (hover: hover) { .choice:hover .choice-content { border-color: #8bb2bf; color: #fff; } }
@media (max-width: 350px) { .choice-options { gap: 6px; } .choice-options-three .choice-content { font-size: 13px; padding-inline: 14px; } }

/* Minuteur autonome : un accès direct, sans activer la caméra. */
.timer-entry { display: flex; gap: 14px; align-items: center; padding: 16px; margin-bottom: 16px; border: 1px solid #387565; border-radius: 18px; background: #14392f; color: #effff8; text-decoration: none; }
.timer-entry > span:nth-child(2) { flex: 1; }
.timer-entry strong { display: block; font-size: 16px; }
.timer-entry small { display: block; color: #b6cec5; margin-top: 5px; line-height: 1.4; }
.timer-entry-icon { font-size: 32px; color: #8fe6c6; }
.calibration-mode .timer-entry,.session-active .timer-entry { display: none; }
.timer-back { color: #b6cec5; text-decoration: none; padding: 12px 0 12px 12px; }
a:focus-visible { outline: 3px solid #8fe6c6; outline-offset: 4px; }
.exercise-timer { text-align: center; }
.timer-intro { font-size: 14px; }
.exercise-status { font-size: 15px; font-weight: 650; margin: 22px 0 0; }
.exercise-display { font-size: clamp(68px, 19vw, 104px); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.05em; line-height: 1.3; color: #8ff0bd; }
#exercise-progress { width: 100%; height: 7px; border: 0; border-radius: 10px; overflow: hidden; background: #233f49; accent-color: #32e58b; margin: 8px 0 26px; }
#exercise-progress::-webkit-progress-bar { background: #233f49; }
#exercise-progress::-webkit-progress-value { background: #32e58b; }
#exercise-progress::-moz-progress-bar { background: #32e58b; }
.duration-settings { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
.duration-settings legend { width: 100%; color: #bdced4; font-size: 13px; margin-bottom: 12px; }
.duration-inputs { display: flex; justify-content: center; align-items: end; gap: 12px; }
.duration-inputs label { display: grid; gap: 7px; width: 108px; color: #a9bec6; font-size: 12px; }
.duration-inputs input { appearance: none; -webkit-appearance: none; width: 100%; height: 52px; padding: 0 8px; border-radius: 12px; border: 1px solid #365360; background: #071c27; color: #fff; font: inherit; font-size: 24px; line-height: normal; font-variant-numeric: tabular-nums; text-align: center; }
.duration-colon { padding-bottom: 12px; color: #a9bec6; font-size: 25px; }
.duration-presets { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-top: 14px; }
.duration-presets button { min-height: 44px; border-radius: 12px; padding: 8px 4px; background: #203e4b; color: #dcecf0; font-size: 13px; }
.duration-settings:disabled { opacity: .55; }
.timer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.timer-actions button { min-height: 50px; padding-inline: 8px; }
.timer-sound { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 18px; border-top: 1px solid #ffffff15; padding-top: 12px; }
.timer-sound label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.timer-sound input { width: 20px; height: 20px; accent-color: #32e58b; }
.timer-sound .text-button { margin-right: 0; }
.exercise-timer .timer-note { font-size: 12px; line-height: 1.5; color: #9db6bf; margin: 8px 0 0; }
.timer-note:empty { display: none; }
.timer-finished .exercise-timer { border-color: #32e58b; background: linear-gradient(145deg,#164835,#0d2925); }
.timer-finished .exercise-status { color: #8ff0bd; }
@media (max-width: 350px) { .exercise-timer { padding: 16px; } }
