/* Styles propres au jeu gardiens-balle; fondations dans /common/css. */
body {
  margin: 0;
  background: #10191a;
  color: #f5e7c8;
  font-family: system-ui, Arial, sans-serif;
}
header {
  max-width: 1120px;
  margin: auto;
  padding: 17px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
header strong {
  color: #f3c76b;
  letter-spacing: 0.06em;
}
main {
  max-width: 1120px;
  margin: auto;
  padding: 0 12px 30px;
}
.game {
  position: relative;
  border: 5px solid #9b7849;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(#5a8190, #d2a86b);
  box-shadow: 0 14px 55px #0008;
}
#view {
  display: block;
  width: 100%;
  height: min(65vw, 620px);
  min-height: 320px;
  touch-action: none;
}
.point-popup {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 4;
  pointer-events: none;
  font-size: clamp(23px, 4vw, 43px);
  font-weight: 1000;
  color: #ffe48b;
  text-shadow:
    0 3px 2px #35200e,
    0 0 15px #f7a32b,
    0 0 35px #f7a32b;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
}
.point-popup.show {
  animation: point-rise 1.25s ease-out forwards;
}
@keyframes point-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, -25%) scale(0.65);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -70%) scale(1.28);
  }
  65% {
    opacity: 1;
    transform: translate(-50%, -120%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -180%) scale(0.9);
  }
}
.shot-gauges {
  position: absolute;
  bottom: 13px;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 20px));
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 2;
  pointer-events: none;
}
.aim {
  flex: 1;
  min-width: 0;
  background: #132222d9;
  border: 1px solid #d8b878;
  border-radius: 12px;
  padding: 8px 12px;
  text-align: center;
  pointer-events: none;
}
.aim-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.07em;
}
.aim-track {
  height: 13px;
  border-radius: 9px;
  position: relative;
  margin-top: 7px;
  background: linear-gradient(
    90deg,
    #a64134 0%,
    #d4a653 29%,
    #52b27e 45%,
    #52b27e 55%,
    #d4a653 71%,
    #a64134 100%
  );
}
.aim-cursor {
  position: absolute;
  top: -4px;
  width: 5px;
  height: 21px;
  background: white;
  box-shadow: 0 0 7px #000;
  left: 50%;
  border-radius: 3px;
}
.aim-info {
  font-size: 11px;
  color: #e6d8bd;
  margin-top: 5px;
}
.score-pulse {
  animation: score-pulse 0.4s ease-out;
}
@keyframes score-pulse {
  50% {
    transform: scale(1.3);
    color: #fff;
  }
}
.hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}
.stat {
  background: #172322dc;
  border: 1px solid #d6b57a8a;
  border-radius: 9px;
  padding: 8px 12px;
  font-size: clamp(12px, 2vw, 17px);
}
.stat b {
  color: #ffd477;
}
.bonus-panel {
  position: absolute;
  top: 61px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  pointer-events: none;
  width: 90%;
}
.bonus-badge {
  display: none;
  border: 2px solid;
  border-radius: 12px;
  padding: 9px 14px;
  font-weight: 900;
  font-size: clamp(12px, 1.8vw, 17px);
  box-shadow: 0 0 22px #0009;
  animation: bonus-breathe 1s ease-in-out infinite alternate;
}
.bonus-badge.active {
  display: block;
}
.slow-badge {
  background: #123d5be8;
  color: #c8f7ff;
  border-color: #65e5ff;
}
.shield-badge {
  background: #123c46e8;
  color: #c9fbff;
  border-color: #83eaff;
}
@keyframes bonus-breathe {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.5);
  }
}
.leaderboard {
  position: absolute;
  z-index: 6;
  top: 67px;
  right: 10px;
  width: 185px;
  max-width: 45%;
  background: #122426e8;
  border: 1px solid #d6b57a;
  border-radius: 11px;
  padding: 10px;
  color: #f9e9c6;
  font-size: 13px;
  pointer-events: none;
}
.leaderboard h2 {
  font-size: 13px;
  color: #ffdb8b;
  margin: 0 0 7px;
}
.leaderboard ol {
  margin: 0;
  padding-left: 23px;
}
.leaderboard li {
  margin: 3px 0;
}
.leaderboard small {
  display: block;
  margin-top: 6px;
  color: #c8c8bd;
}
.ranking-result {
  display: none;
  margin: 12px auto 0;
  padding: 10px;
  border: 1px solid #e1bd77;
  border-radius: 9px;
  background: #253e3e;
  color: #ffdf92;
  font-weight: 800;
}
.ranking-result.show {
  display: block;
}
@media (max-width: 600px) {
  .leaderboard {
    top: 95px;
    right: 6px;
    width: 145px;
    padding: 7px;
    font-size: 11px;
  }
  .leaderboard h2 {
    font-size: 11px;
  }
}
.overlay {
  position: absolute;
  inset: 0;
  background: #0b181bd9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
}
.overlay.hidden {
  display: none;
}
.panel {
  max-width: 550px;
  background: #1b2c2de8;
  border: 1px solid #c9a76d;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 60px #0009;
}
.panel h1 {
  margin: 0 0 12px;
  font-size: clamp(25px, 4vw, 43px);
  color: #f4d18a;
}
.panel p {
  line-height: 1.55;
}
button {
  border: 2px solid #f2d28c;
  border-radius: 10px;
  background: linear-gradient(#edc477, #bd823e);
  color: #2a2017;
  font-size: 16px;
  font-weight: 800;
  padding: 12px 20px;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled {
  opacity: 0.45;
}
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 0;
}
.controls button {
  min-width: 72px;
  min-height: 53px;
}
.controls #hit {
  min-width: 160px;
}
.small {
  font-size: 13px;
  color: #c6bba7;
  line-height: 1.6;
}
.status {
  color: #f2d28c;
  text-align: center;
  min-height: 24px;
}
.legend {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}
@media (max-width: 600px) {
  .stat {
    padding: 7px;
  }
  #view {
    height: 440px;
  }
  .panel {
    padding: 16px;
  }
  .controls button {
    flex: 1;
  }
}

/* Responsive layout and accessible end-of-game dialog. */
.overlay {
  z-index: 20;
  overflow-y: auto;
  overscroll-behavior: contain;
  align-items: safe center;
  justify-content: center;
}
.overlay .panel {
  width: min(100%, 550px);
  max-height: calc(100% - 4px);
  overflow-y: auto;
  overscroll-behavior: contain;
  min-width: 0;
  overflow-wrap: break-word;
}
.overlay .panel p {
  overflow-wrap: anywhere;
}
.game:has(.overlay:not(.hidden)) > .leaderboard {
  visibility: hidden;
}
.result-leaderboard {
  display: none;
  margin: 12px auto 0;
  padding: 10px 12px;
  border: 1px solid #d6b57a;
  border-radius: 10px;
  background: #122426;
  color: #f9e9c6;
  text-align: left;
  font-size: 13px;
}
.result-leaderboard.show {
  display: block;
}
.result-leaderboard h2 {
  font-size: 14px;
  color: #ffdb8b;
  margin: 0 0 6px;
  text-align: center;
}
.result-leaderboard ol {
  margin: 0;
  padding-left: 24px;
}
.result-leaderboard li {
  margin: 3px 0;
}
.result-leaderboard small {
  display: block;
  margin-top: 5px;
  text-align: center;
}
@media (max-width: 768px) {
  .game > .leaderboard {
    display: none;
  }

  header {
    padding: 10px 12px;
    gap: 4px;
    font-size: 13px;
  }
  main {
    padding: 0 6px 16px;
  }
  .game {
    border-width: 3px;
    border-radius: 10px;
  }
  .overlay {
    padding: 8px;
  }
  .panel {
    padding: 14px 12px;
    border-radius: 12px;
  }
  .panel h1 {
    font-size: clamp(21px, 5vw, 28px);
    margin-bottom: 7px;
  }
  .panel p {
    font-size: 13px;
    line-height: 1.4;
    margin: 8px 0;
  }
  .ranking-result {
    font-size: 12px;
    padding: 8px;
    margin: 9px auto 0;
  }
  .hud {
    top: 5px;
    left: 5px;
    right: 5px;
    gap: 4px;
    flex-wrap: wrap;
  }
  .stat {
    font-size: 11px;
    padding: 5px 7px;
  }
  .bonus-panel {
    top: 55px;
  }
  .leaderboard {
    top: 100px;
    max-width: 42%;
    font-size: 10px;
  }
  .controls {
    gap: 6px;
    padding: 9px 0;
  }
  .controls button {
    min-width: 0;
    min-height: 45px;
    padding: 8px 6px;
    font-size: 12px;
  }
  .controls #hit {
    min-width: 100px;
    flex: 1.5;
  }
  .shot-gauges {
    bottom: 7px;
  }
  .aim {
    padding: 5px 8px;
  }
  .aim-info {
    font-size: 10px;
  }
}
@media (max-width: 480px) {
  #view {
    height: min(115vw, 490px);
    min-height: 300px;
  }
  .overlay {
    align-items: flex-start;
  }
  .overlay .panel {
    margin: auto 0;
    max-height: 100%;
    padding: 12px 10px;
  }
  .panel h1 {
    font-size: 21px;
  }
  .panel p {
    font-size: 12px;
    line-height: 1.35;
  }
  .panel button {
    font-size: 14px;
    padding: 10px 18px;
  }
  .panel .small {
    font-size: 11px;
    line-height: 1.4;
  }
  .leaderboard {
    top: 100px;
    right: 5px;
    width: 120px;
    padding: 6px;
  }
  .stat {
    font-size: 10px;
    padding: 4px 5px;
  }
  .controls #hit {
    min-width: 90px;
  }
}
@media (max-height: 550px) {
  .overlay {
    align-items: flex-start;
  }
  .overlay .panel {
    margin: auto 0;
    max-height: 100%;
  }
}

/* V32.6.2 — Commandes tactiles : trois boutons pleine largeur,
   texte d'état, puis Pause sur une ligne séparée.
   L'agencement ordinateur reste inchangé. */
@media (max-width: 768px) {
  main {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 6px;
    align-items: stretch;
  }
  main > .game {
    grid-column: 1 / -1;
    order: 0;
  }
  main > .controls {
    display: contents;
  }
  .controls #left,
  .controls #hit,
  .controls #right {
    order: 1;
    width: 100%;
    min-width: 0;
    min-height: 48px;
    box-sizing: border-box;
    margin-top: 10px;
    padding: 8px 3px;
    font-size: clamp(11px, 3vw, 15px);
    white-space: nowrap;
  }
  .controls #hit {
    min-width: 0;
  }
  main > #status {
    grid-column: 1 / -1;
    order: 2;
    margin: 12px 0 4px;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .controls #pause {
    grid-column: 1 / -1;
    order: 3;
    justify-self: center;
    min-width: 135px;
    min-height: 46px;
    margin: 4px 0 12px;
  }
}

/* Saisie du pseudo à la fin de la partie */
.score-form:not([hidden]) { display:flex; flex-direction:column; align-items:center; gap:9px; margin:14px auto; max-width:370px; }
.score-form label { font-weight:700; text-align:center; }
.score-form input, .score-form select { width:100%; box-sizing:border-box; padding:12px; font-size:16px; border:1px solid #d8b878; border-radius:8px; background:#fdf6e6; color:#182628; }
.score-actions { display:flex; justify-content:center; gap:9px; flex-wrap:wrap; }
.score-form button { min-height:44px; cursor:pointer; }

/* Fit the complete game to embedded/mobile viewports, including 400 × 600.
   The arena takes the space left by navigation, controls and status. */
@media (max-width: 768px), (max-height: 550px) {
  html {
    min-height: 100%;
  }
  body {
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
  }
  body > #kn-language-switch {
    flex: 0 0 auto;
    padding: 4px 6px;
    gap: 4px;
  }
  body > header {
    flex: 0 0 auto;
    width: 100%;
    padding: 5px 8px;
    gap: 2px 8px;
    font-size: 12px;
  }
  body > nav.game-guide {
    margin: 4px auto 6px;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
  }
  body > main {
    height: calc(100dvh - var(--game-chrome-height, 110px));
    min-height: 280px;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr) auto 34px;
    gap: 4px;
    padding: 0 6px max(4px, env(safe-area-inset-bottom));
  }
  main > .game {
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 0;
    min-width: 0;
  }
  #view {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
  }
  main > .controls {
    display: contents;
  }
  .controls #left,
  .controls #hit,
  .controls #right,
  .controls #pause {
    grid-row: 2;
    grid-column: auto;
    justify-self: stretch;
    width: 100%;
    min-width: 0;
    min-height: 48px;
    margin: 0;
    padding: 6px 2px;
    font-size: 12px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  main > #status {
    grid-row: 3;
    grid-column: 1 / -1;
    min-height: 0;
    margin: 0;
    font-size: 12px;
    line-height: 16px;
    overflow-y: auto;
  }
  .overlay {
    padding: 6px;
  }
  .overlay .panel {
    max-height: 100%;
    margin: auto 0;
  }
}

/* V33.1 : jauge de préparation, sans nouvelle commande tactile. */
.preparation-track {
  height: 4px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: #45504b;
}
#preparationProgress { height: 100%; width: 0; background: #f3c76b; }
#preparationProgress.ready { background: #68dc91; }
#preparationProgress.overdue { background: #db8872; }
#hit { touch-action: none; }

/* Énergie à côté de la précision, dans le même panneau de commandes. */
.special-gauge {
  flex: 0 0 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 2px;
  border-radius: 7px;
  background: #10191ae8;
  color: #f3c76b;
  font: 700 9px/1.2 system-ui, sans-serif;
  pointer-events: none;
}
.special-gauge[hidden] { display: none; }
.special-announcement {
  position:absolute; top:25%; left:50%; z-index:12; width:max-content; max-width:85%;
  padding:10px 18px; border:2px solid currentColor; border-radius:12px;
  background:linear-gradient(120deg,#071b21ed,#123333d9); box-shadow:0 0 28px currentColor;
  font-size:clamp(16px,3vw,30px); font-weight:900; text-align:center; text-transform:uppercase;
  text-shadow:0 2px 5px #000; pointer-events:none; opacity:0; transform:translateX(-50%);
}
.special-announcement[hidden] { display:none; }
.special-announcement.show { animation:special-announcement-burst 1.6s ease-out both; }
@keyframes special-announcement-burst {
  0% { opacity:0; transform:translateX(-50%) scale(.65); }
  15% { opacity:1; transform:translateX(-50%) scale(1.08); }
  30%,75% { opacity:1; transform:translateX(-50%) scale(1); }
  100% { opacity:0; transform:translateX(-50%) translateY(-12px) scale(1); }
}
@media (prefers-reduced-motion:reduce) {
  .special-announcement.show { animation:none; opacity:1; }
}
.special-label { font-size: 8px; }
.special-track { width: 13px; height: 64px; border: 1px solid #f3c76b; border-radius: 7px; overflow: hidden; position: relative; }
#specialFill { position: absolute; bottom: 0; width: 100%; height: 0; background: linear-gradient(#ffe8a6, #d99722); }
.special-gauge.ready { box-shadow: 0 0 14px #ffd15a; }
.special-gauge.executing { box-shadow: 0 0 20px #fff0b0; }
@media (max-height: 500px) { .special-track { height: 44px; } }

/* Compact end-of-game form and disclosure help. */
.score-message { display:none; align-items:center; gap:8px; margin:12px 0; }
.score-message:has(.ranking-result.show) { display:flex; }
.score-message .ranking-result { flex:1; min-width:0; margin:0; }
.score-help { position:relative; flex:none; }
.score-help summary { display:grid; place-items:center; width:28px; height:28px; border:1px solid #d8b878; border-radius:50%; color:#f4d18a; cursor:pointer; font-weight:800; list-style:none; }
.score-help summary::-webkit-details-marker { display:none; }
.score-help summary:focus-visible { outline:2px solid #f4d18a; outline-offset:3px; }
.overlay .panel .score-help #scorePrivacy { display:none; position:absolute; z-index:5; top:100%; right:0; width:min(320px, 65vw); box-sizing:border-box; margin:6px 0 0; padding:12px; border:1px solid #d8b878; border-radius:8px; background:#132222; color:#fdf6e6; font-size:12px; line-height:1.45; font-weight:400; }
.overlay .panel .score-help details[open] + #scorePrivacy,
.overlay .panel .score-help:hover #scorePrivacy,
.overlay .panel .score-help:focus-within #scorePrivacy { display:block; }
.score-fields { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:10px; width:100%; max-width:34ch; }
.score-field { min-width:0; display:flex; flex-direction:column; justify-content:flex-end; gap:6px; }
.score-field label { font-size:12px; }
.score-field input, .score-field select { min-width:0; padding:9px 7px; height:40px; text-overflow:ellipsis; }

/* Choix utilisable au clavier comme au toucher, dans le panneau de précision. */
.spectacular-choice { display:flex; align-items:center; gap:6px; margin-bottom:6px; flex-wrap:wrap; pointer-events:auto; }
.spectacular-choice label { font-size:11px; color:#f3c76b; }
.spectacular-choice select { flex:1; min-width:0; max-width:100%; min-height:32px; border:1px solid #c9a76d; border-radius:6px; padding:4px; background:#162727; color:#f5e7c8; font:inherit; font-size:12px; touch-action:manipulation; }
.spectacular-choice select:focus-visible { outline:2px solid #ffe2a1; outline-offset:2px; }
#spectacularLevel { font-size:10px; color:#f3c76b; }
@media (max-width:600px) { .spectacular-choice label { display:none; } .spectacular-choice { gap:3px; } .spectacular-choice select { font-size:10px; } }

/* Mode d’essai explicite, hors classement. */
.game.test-mode > .leaderboard { display:none; }

/* Choix de frappe sous les compteurs, avec hauteur adaptée au retour à la ligne. */
.hud { flex-wrap:wrap; z-index:3; }
.spectacular-row { flex:0 0 100%; display:flex; justify-content:center; min-width:0; }
.spectacular-row .spectacular-choice { width:min(420px, 100%); box-sizing:border-box; margin:0; padding:5px 8px; border:1px solid #d8b878; border-radius:8px; background:#132222e8; }
.hud > .bonus-panel { position:static; flex:0 0 100%; width:100%; transform:none; }

/* Help remains readable below the viewport-sized playing area. */
body > #regles { width:100%; margin:24px auto; padding:0 16px 24px; }
.game, .hud, .stat, .spectacular-choice { min-width:0; }
.spectacular-choice > [hidden] { display:none; }
#automaticStrike { overflow-wrap:anywhere; font-size:12px; }
.leaderboard { top:var(--hud-bottom, 130px); overflow-wrap:anywhere; }
.special-announcement { top:45%; box-sizing:border-box; }
@media (max-width:768px) {
  .special-announcement { left:73%; width:48%; max-width:48%; padding:6px; font-size:clamp(12px,3vw,17px); }
}

/* Help shares the language bar without taking a row away from the arena. */
body > #kn-language-switch { min-height:44px; padding-left:112px; flex-wrap:nowrap; align-items:center; }
body > nav.game-guide { position:absolute; z-index:10000; top:12px; left:8px; max-width:100px; margin:0; padding:0; font-size:12px; line-height:20px; }
@media (max-width:420px) {
  body > #kn-language-switch { justify-content:flex-end; padding-left:94px; padding-right:4px; gap:3px; }
  body > #kn-language-switch button { min-width:0; gap:3px; padding:5px 4px; font-size:10px; }
  body > nav.game-guide { left:6px; max-width:84px; font-size:11px; }
}

.demo-progress { flex:0 0 100%; padding:5px 7px; background:#132222ed; border:1px solid #d8b878; border-radius:8px; font-size:11px; }
.demo-progress[hidden] { display:none; }
