:root {
  /* Charte vert bouteille + touches jade / or discret (inspire papier laque, bamboo) */
  --bottle: #0a1815;
  --bottle-mid: #122924;
  --bottle-panel: #152f29;
  --border-subtle: #2a4d42;
  --jade: #3d7c6e;
  --jade-deep: #2d5c52;
  /* Doré un peu plus saturé et lisible sur fond bouteille */
  --gold: #e2b82a;
  --gold-rgb: 226 184 42;
  --gold-soft: rgb(var(--gold-rgb) / 30%);
  --light-square: #e9ebe5;
  --dark-square: #5a736a;
  --highlight: #ddc056;
  --accent: #6bbf9e;
  --capture: #e0786e;
  --bg: var(--bottle);
  --panel: var(--bottle-panel);
  --text: #e8ede9;
  --text-muted: #9fb8b0;
  --font-ui: "Zen Kaku Gothic New", "Hiragino Sans", "Segoe UI", sans-serif;
  --font-display: "Noto Serif JP", "Georgia", serif;
  --square-size: 64px;
  --piece-scale: 0.93;
  --board-border-size: 8px;
  /* Tampon latéral (badges ! sur colonnes a/h) ; bande h/b plus fine. */
  --board-badge-gutter: calc(var(--square-size) * 0.14);
  --board-badge-gutter-y: calc(var(--square-size) * 0.08);
  --board-column-height: calc(
    8 * var(--square-size) + 2 * var(--board-border-size) + 2 *
      var(--board-badge-gutter-y) + 5.75rem
  );
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 400;
  background-color: var(--bottle);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgb(61 124 110 / 18%), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 100%, rgb(10 24 21 / 90%), var(--bottle)),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 2px,
      rgb(255 255 255 / 1%) 2px,
      rgb(255 255 255 / 1%) 4px
    );
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.header {
  text-align: center;
  margin-bottom: 1.5rem;
  position: relative;
}

.header h1 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: clamp(1.35rem, 3.2vw, 2.35rem);
  color: var(--text);
  text-shadow: 0 1px 0 rgb(0 0 0 / 35%);
  margin: 0;
  /* Réserve la place du bouton Paramètres (jamais de chevauchement). */
  padding-inline: clamp(6.5rem, 12vw, 9.5rem);
  box-sizing: border-box;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.header h1::after {
  content: "";
  display: block;
  width: 72px;
  height: 2px;
  margin: 0.85rem auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.95;
}

.ecole-brand {
  margin: 0.55rem 0 2.5rem 0;
  font-size: 0.92rem;
  letter-spacing: 0.06em;
}

.ecole-brand a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.ecole-brand a:hover {
  color: var(--gold);
}

.settings-box {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.pgn-editor-btn {
  padding: 0.55rem 0.8rem;
  font-size: 0.88rem;
  white-space: nowrap;
}

.pgn-editor-btn[hidden] {
  display: none !important;
}

.settings-btn {
  padding: 0.55rem 0.8rem;
  font-size: 0.9rem;
}

.settings-menu {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  min-width: 300px;
  background: linear-gradient(165deg, rgb(21 47 41 / 99%), rgb(10 24 21 / 96%));
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: 0 12px 36px rgb(0 0 0 / 42%);
  padding: 0.65rem;
  display: none;
  z-index: 1000;
  text-align: left;
}

.settings-menu.open {
  display: block;
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.settings-category {
  margin-bottom: 0.55rem;
  padding: 0.5rem 0.55rem 0.45rem;
  border-radius: 8px;
  border: 1px solid rgb(var(--gold-rgb) / 22%);
  background: rgb(10 24 21 / 42%);
}

.settings-category-title {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}

.settings-special-row {
  justify-content: space-between;
  margin-bottom: 0.35rem;
  cursor: help;
  gap: 0.75rem;
}

.settings-special-row:last-child {
  margin-bottom: 0;
}

.settings-special-label {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.settings-special-row input[type="checkbox"] {
  flex-shrink: 0;
}

.settings-menu select {
  width: 100%;
}

.settings-category-select {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.52rem 2rem 0.52rem 0.55rem;
  border-radius: 8px;
  border: 1px solid rgb(var(--gold-rgb) / 30%);
  background-color: rgb(10 28 24 / 88%);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e2b82a' d='M3 4.2 6 7.8 9 4.2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 11px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
}

.settings-category-select:hover {
  border-color: rgb(var(--gold-rgb) / 48%);
}

.settings-category-select:focus {
  outline: none;
  border-color: rgb(var(--gold-rgb) / 62%);
  box-shadow: 0 0 0 2px rgb(var(--gold-rgb) / 18%);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin-bottom: 1rem;
  align-items: center;
}

.controls-primary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  align-items: center;
}

body:not(.edit-ui) .edit-ui-only {
  display: none !important;
}

body:not(.edit-ui) .controls {
  display: none !important;
}

body:not(.edit-ui) .board-area-side-left .status {
  display: none !important;
}

body:not(.edit-ui) .board-area-side-left:not(:has(.lesson-photos)) {
  display: none !important;
}

.controls-secondary {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.controls-secondary-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
}

.controls-secondary-edit-row .piece-picker-label {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.92rem;
}

button {
  border: 1px solid rgb(var(--gold-rgb) / 44%);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: linear-gradient(180deg, var(--jade) 0%, var(--jade-deep) 100%);
  color: #f8faf9;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgb(0 0 0 / 25%);
}

button:hover {
  background: linear-gradient(180deg, #4a907f 0%, var(--jade) 100%);
  border-color: rgb(var(--gold-rgb) / 62%);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgb(21 47 41 / 95%);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

select {
  border: 1px solid var(--border-subtle);
  background: rgb(10 28 24 / 85%);
  color: var(--text);
  padding: 0.55rem 0.5rem;
  border-radius: 8px;
}

/* Rangée principale : board-area (côté + échiquier) | history-panel */
.study-stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  overflow: visible;
}

.board-area {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 1rem;
  overflow: visible;
}

/* Colonne gauche : statut + futurs tableaux — décale l’échiquier vers la droite */
.board-area-side-left {
  flex: 0 0 clamp(10.25rem, 14vw, 14.5rem);
  width: clamp(10.25rem, 14vw, 14.5rem);
  max-width: 15rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  padding-right: 0.25rem;
  box-sizing: border-box;
}

.board-column {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex-shrink: 0;
  overflow: visible;
}

.board-wrap {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template: 1fr / 1fr;
  position: relative;
  align-self: stretch;
  justify-self: stretch;
  overflow: visible;
}

.board-shell.coords-outside .board-wrap {
  grid-column: 1;
  grid-row: 1;
}

.board-wrap .board {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
}

.board-shapes-svg {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
  overflow: visible;
}

.board-nag-badges {
  position: absolute;
  inset: calc(-1 * var(--board-badge-gutter));
  pointer-events: none;
  z-index: 35;
  overflow: visible;
}

.board-nag-badges .move-annotation-badge {
  /* Coin haut-droit de la case, légèrement à l’intérieur (style Lichess). */
  top: calc(
    var(--board-badge-gutter) + var(--badge-ui-row) * var(--square-size) +
      var(--square-size) * 0.12
  );
  left: calc(
    var(--board-badge-gutter) + (var(--badge-ui-col) + 1) * var(--square-size) -
      var(--square-size) * 0.12
  );
  right: auto;
  transform: translate(-50%, -50%);
  min-width: max(2.15rem, calc(var(--square-size) * 0.46));
  min-height: max(2.15rem, calc(var(--square-size) * 0.46));
  font-size: clamp(0.95rem, calc(var(--square-size) * 0.32), 1.25rem);
}

.board-shell .board-wrap .board {
  position: relative;
  z-index: 1;
}

.annotation-flyout-anchor {
  flex-shrink: 0;
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border-subtle);
}

.annotation-flyout-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.15rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid rgb(var(--gold-rgb) / 35%);
  border-radius: 8px;
  background: rgb(21 47 41 / 92%);
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgb(0 0 0 / 22%);
  transition:
    background 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease;
}

.annotation-flyout-toggle:hover {
  background: rgb(var(--gold-rgb) / 14%);
  border-color: rgb(var(--gold-rgb) / 55%);
}

.annotation-flyout-toggle:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.annotation-flyout-toggle-open {
  background: rgb(98 153 36 / 92%);
  border-color: rgb(120 180 50 / 95%);
  color: #f8fff0;
}

.annotation-flyout-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  margin-top: 0.45rem;
  max-height: min(52vh, 360px);
  overflow: hidden auto;
  padding: 0.55rem 0.6rem 0.45rem;
  border-radius: 8px;
  border: 1px solid rgb(255 255 255 / 12%);
  background: rgb(22 26 24 / 98%);
  box-shadow: 0 8px 28px rgb(0 0 0 / 38%);
}

.annotation-flyout-panel[hidden] {
  display: none !important;
}

.annotation-flyout-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 0.75rem;
  align-items: start;
}

.annotation-flyout-col {
  min-width: 0;
}

.annotation-flyout-col-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgb(180 185 178 / 88%);
  margin-bottom: 0.35rem;
}

.annotation-flyout-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.annotation-flyout-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.28rem 0.38rem;
  margin: 0;
  border: none;
  border-radius: 5px;
  background: rgb(255 255 255 / 4%);
  color: rgb(232 236 232 / 95%);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s ease;
}

.annotation-flyout-row:hover:not(:disabled) {
  background: rgb(98 153 36 / 52%);
  color: #fff;
}

.annotation-flyout-row:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.annotation-flyout-row-active {
  background: rgb(98 153 36 / 78%);
  color: #fff;
}

.annotation-flyout-symbol {
  flex-shrink: 0;
  min-width: 1.85rem;
  font-weight: 700;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.annotation-flyout-label {
  flex: 1;
  line-height: 1.25;
}

.annotation-flyout-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.55rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgb(255 255 255 / 8%);
}

.annotation-flyout-footer-label {
  font-size: 0.68rem;
  color: rgb(160 168 162 / 95%);
}

.annotation-flyout-footer-input {
  width: 3.5rem;
  padding: 0.22rem 0.3rem;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 5px;
  background: rgb(10 14 12 / 85%);
  color: var(--text);
  font-size: 0.75rem;
}

.annotation-flyout-footer-btn {
  padding: 0.22rem 0.45rem;
  font-size: 0.72rem;
  border-radius: 5px;
  border: 1px solid rgb(255 255 255 / 16%);
  background: rgb(38 44 40 / 95%);
  color: rgb(228 232 228 / 95%);
  cursor: pointer;
}

.annotation-flyout-footer-btn:hover:not(:disabled) {
  border-color: rgb(var(--gold-rgb) / 38%);
}

.annotation-flyout-footer-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.annotation-flyout-clear-btn {
  margin-left: auto;
}

.annotation-flyout-hint {
  margin: 0.35rem 0 0;
  font-size: 0.62rem;
  line-height: 1.35;
  color: rgb(140 148 142 / 88%);
}

.annotation-flyout-hint a {
  color: rgb(130 190 160 / 95%);
}

.trace-toolbar {
  flex-shrink: 0;
  margin-top: 0.42rem;
  padding: 0.38rem 0.45rem 0.42rem;
  border-radius: 7px;
  border: 1px solid rgb(255 255 255 / 10%);
  background: rgb(14 22 20 / 96%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 6%);
}

.trace-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.28rem 0.38rem;
}

.trace-toolbar-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: rgb(150 158 152 / 82%);
  flex-shrink: 0;
}

.trace-brush-group {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  flex: 1;
  min-width: 0;
}

.trace-brush-btn {
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgb(0 0 0 / 35%);
  cursor: pointer;
  flex-shrink: 0;
  box-shadow:
    inset 0 2px 4px rgb(255 255 255 / 35%),
    inset 0 -3px 6px rgb(0 0 0 / 28%),
    0 2px 6px rgb(0 0 0 / 25%);
  transition:
    transform 0.1s ease,
    box-shadow 0.12s ease,
    outline 0.12s ease;
}

.trace-brush-btn:hover {
  transform: scale(1.06);
}

.trace-brush-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.trace-brush-green {
  background: radial-gradient(circle at 32% 28%, #4caf50 0%, #15781b 48%, #0d4d12 100%);
}

.trace-brush-red {
  background: radial-gradient(circle at 32% 28%, #e05555 0%, #882020 48%, #501010 100%);
}

.trace-brush-blue {
  background: radial-gradient(circle at 32% 28%, #4a7ecf 0%, #003088 48%, #001850 100%);
}

.trace-brush-yellow {
  background: radial-gradient(circle at 32% 28%, #f5c04a 0%, #e69f00 48%, #a06a00 100%);
}

.trace-brush-btn[aria-pressed="true"] {
  box-shadow:
    inset 0 1px 3px rgb(255 255 255 / 45%),
    inset 0 -2px 5px rgb(0 0 0 / 22%),
    0 0 0 2px rgb(var(--gold-rgb) / 55%),
    0 2px 10px rgb(0 0 0 / 35%);
  border-color: rgb(var(--gold-rgb) / 45%);
}

.trace-clear-btn {
  margin-left: auto;
  padding: 0.28rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgb(21 90 48 / 85%);
  background: linear-gradient(180deg, rgb(52 120 72 / 98%), rgb(28 78 42 / 98%));
  color: #f6fff8;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgb(0 0 0 / 22%);
  transition:
    background 0.12s ease,
    border-color 0.12s ease;
}

.trace-clear-btn:hover {
  border-color: rgb(98 180 110 / 95%);
  background: linear-gradient(180deg, rgb(62 138 82 / 98%), rgb(32 92 52 / 98%));
}

.trace-clear-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.trace-toolbar-hint {
  margin: 0.28rem 0 0;
  font-size: 0.58rem;
  line-height: 1.3;
  color: rgb(140 148 142 / 88%);
}

.history-move-nav-wrap {
  flex-shrink: 0;
  margin-top: 0.52rem;
  padding-bottom: 0.42rem;
  border-bottom: 1px solid var(--gold-soft);
}

.history-move-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.32rem;
}

/*
 * Pastilles compactes, contour doré lisible (charte --gold).
 */
.history-nav-btn {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background-color: rgb(21 47 41);
  background-image: radial-gradient(
    circle at 50% 28%,
    rgb(44 76 62 / 98%) 0%,
    rgb(21 47 41 / 99%) 55%,
    rgb(14 36 30 / 99%) 100%
  );
  box-shadow:
    inset 0 1px 3px rgb(255 255 255 / 12%),
    inset 0 -3px 6px rgb(0 0 0 / 38%),
    0 2px 6px rgb(0 0 0 / 28%);
  cursor: pointer;
  position: relative;
  font-size: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background-color 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}

.history-nav-btn::before {
  content: "";
  width: 10px;
  height: 10px;
  box-sizing: border-box;
  border-right: 2.5px solid rgb(248 250 249 / 94%);
  border-bottom: 2.5px solid rgb(248 250 249 / 94%);
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center;
  pointer-events: none;
}

.history-nav-btn::after {
  content: none;
  width: 10px;
  height: 10px;
  box-sizing: border-box;
  border-right: 2.5px solid rgb(248 250 249 / 94%);
  border-bottom: 2.5px solid rgb(248 250 249 / 94%);
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center;
  pointer-events: none;
}

.history-nav-btn.nav-prev::before {
  transform: translate(-40%, -50%) rotate(135deg);
}

.history-nav-btn.nav-next::before {
  transform: translate(-60%, -50%) rotate(-45deg);
}

.history-nav-btn.nav-to-first::before {
  transform: translate(-76%, -50%) rotate(135deg);
}

.history-nav-btn.nav-to-first::after {
  content: "";
  transform: translate(-24%, -50%) rotate(135deg);
}

.history-nav-btn.nav-to-last::before {
  transform: translate(-76%, -50%) rotate(-45deg);
}

.history-nav-btn.nav-to-last::after {
  content: "";
  transform: translate(-24%, -50%) rotate(-45deg);
}

.history-nav-btn:hover:not(:disabled) {
  border-color: var(--highlight);
  background-image: radial-gradient(
    circle at 50% 28%,
    rgb(52 88 72 / 98%) 0%,
    rgb(24 52 44 / 99%) 55%,
    rgb(17 40 34 / 99%) 100%
  );
  box-shadow:
    inset 0 1px 4px rgb(255 255 255 / 16%),
    inset 0 -3px 8px rgb(0 0 0 / 32%),
    0 2px 10px rgb(0 0 0 / 30%);
}

.history-nav-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.history-nav-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, var(--square-size));
  grid-template-rows: repeat(8, var(--square-size));
  border: none;
  box-shadow: 0 16px 40px rgb(0 0 0 / 45%);
  overflow: visible;
}

.board-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  border: var(--board-border-size) solid rgb(21 47 41 / 98%);
  box-shadow: 0 0 0 1px rgb(var(--gold-rgb) / 38%);
  pointer-events: none;
  z-index: 25;
}

.board-shell {
  --board-gap: 0px;
  --cell-radius: 0px;
  display: grid;
  grid-template-columns: 20px auto 20px;
  grid-template-rows: 20px auto 20px;
  align-items: stretch;
  justify-items: stretch;
  overflow: visible;
  padding: var(--board-badge-gutter);
  box-sizing: content-box;
}

.board-shell.coords-outside {
  /* Colonne un peu plus large pour décaler les rangées hors du filet doré du plateau */
  grid-template-columns: auto minmax(26px, max-content);
  grid-template-rows: auto minmax(22px, max-content);
}

.board-shell.coords-outside .coords-top,
.board-shell.coords-outside .coords-left {
  display: none !important;
}

.board-shell.coords-outside .coords-right {
  grid-column: 2;
  grid-row: 1;
}

.board-shell.coords-outside .coords-bottom {
  grid-column: 1;
  grid-row: 2;
}

.outer-coords {
  display: none;
  font-size: 0.84rem;
  font-weight: 700;
  font-family: Arial, sans-serif;
  color: rgb(232 237 233 / 88%);
}

.board-shell.coords-outside .outer-coords.coords-bottom {
  display: grid;
  grid-template-columns: repeat(8, var(--square-size));
  gap: var(--board-gap);
  justify-content: start;
  justify-items: stretch;
  padding-block-start: 8px;
  box-sizing: border-box;
}

.board-shell.coords-outside .outer-coords.coords-right {
  display: grid;
  grid-template-rows: repeat(8, var(--square-size));
  gap: var(--board-gap);
  align-content: start;
  justify-items: stretch;
  box-sizing: border-box;
}

/* Rangées 1–8 : aligner vers la droite + marge intérieure pour ne pas chevaucher le cadre */
.board-shell.coords-outside .outer-coords.coords-right.vertical .outer-coord {
  justify-content: flex-end;
  padding-inline-start: 10px;
  padding-inline-end: 3px;
}

.coords-top {
  grid-column: 2;
  grid-row: 1;
  align-items: center;
}

.coords-bottom {
  grid-column: 2;
  grid-row: 3;
  align-items: center;
}

.coords-left {
  grid-column: 1;
  grid-row: 2;
  flex-direction: column;
  justify-content: flex-start;
}

.coords-right {
  grid-column: 3;
  grid-row: 2;
  flex-direction: column;
  justify-content: flex-start;
}

.outer-coords.horizontal .outer-coord {
  flex: 0 0 var(--square-size);
  text-align: center;
}

.outer-coords.vertical .outer-coord {
  flex: 0 0 var(--square-size);
  display: flex;
  align-items: center;
  justify-content: center;
}

.coords-top.horizontal,
.coords-bottom.horizontal {
  padding-inline: var(--board-border-size);
}

.board-shell.coords-outside .coords-bottom.horizontal {
  justify-content: unset;
}

.coords-left.vertical,
.coords-right.vertical {
  padding-block: var(--board-border-size);
}

.square {
  position: relative;
  width: var(--square-size);
  height: var(--square-size);
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font-size: 2.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  appearance: none;
  -webkit-appearance: none;
  border-radius: var(--cell-radius, 0px);
  overflow: visible;
}

.square.draggable {
  cursor: grab;
  touch-action: none;
}

.square.draggable:active {
  cursor: grabbing;
}

body.piece-pointer-dragging,
body.piece-pointer-dragging * {
  cursor: grabbing !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

.piece {
  position: relative;
  z-index: 2;
  width: calc(var(--square-size) * var(--piece-scale));
  height: calc(var(--square-size) * var(--piece-scale));
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgb(0 0 0 / 35%));
  pointer-events: none;
}

.piece-drag-ghost {
  position: fixed;
  margin: 0;
  padding: 0;
  pointer-events: none;
  z-index: 10000;
  box-sizing: border-box;
}

.piece-drag-ghost .piece {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.piece.interactive-move-anim {
  filter: drop-shadow(0 2px 4px rgb(0 0 0 / 45%));
}

/* Pièce masquée sur la case de départ tant que le glisser-déposer n’est pas terminé */
.square.drag-source-active .piece {
  visibility: hidden;
}

/* Halo discret autour du roi lorsque le camp au trait est en échec */
.square.king-in-check .piece {
  filter:
    drop-shadow(0 1px 1px rgb(0 0 0 / 35%))
    drop-shadow(0 0 5px rgb(212 130 95 / 55%))
    drop-shadow(0 0 12px rgb(200 85 72 / 28%));
}

.square.king-in-check.drag-source-active {
  box-shadow: inset 0 0 0 2px rgb(212 130 95 / 35%), 0 0 14px rgb(200 85 72 / 22%);
}

.coord {
  position: absolute;
  z-index: 3;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: Arial, sans-serif;
  pointer-events: none;
  opacity: 0.85;
}

.coord-rank {
  top: 3px;
  /* Un peu plus à l’intérieur de la case pour éviter le halo du cadre sur la colonne h */
  right: 10px;
}

.coord-file {
  right: 5px;
  bottom: 3px;
}

.square.light .coord {
  color: rgb(42 62 56 / 82%);
}

.square.dark .coord {
  color: rgb(232 237 233 / 88%);
}

.square.light {
  background: var(--light-square);
}

.square.dark {
  background: var(--dark-square);
}

.square.last-move:not(.selected) {
  box-shadow: inset 0 0 0 999px rgb(204 227 82 / 42%);
}

.square.selected.last-move {
  box-shadow:
    inset 0 0 0 999px rgb(61 124 110 / 38%),
    inset 0 0 0 999px rgb(204 227 82 / 28%);
}

.square.selected {
  box-shadow: inset 0 0 0 999px rgb(61 124 110 / 38%);
}

.square.selected::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      135deg,
      rgb(255 255 255 / 12%) 0%,
      rgb(255 255 255 / 4%) 40%,
      rgb(0 0 0 / 10%) 100%
    );
  pointer-events: none;
  z-index: 1;
}

.square.can-move::after {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: color-mix(in oklab, var(--accent) 80%, #000 20%);
  position: absolute;
}

.square.can-capture::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 3px solid var(--capture);
  border-radius: 50%;
}

.edge {
  position: absolute;
  background: transparent;
  pointer-events: none;
}

.edge.top,
.edge.bottom {
  height: 6px;
  left: 0;
  right: 0;
}

.edge.left,
.edge.right {
  width: 6px;
  top: 0;
  bottom: 0;
}

.edge.top {
  top: 0;
}

.edge.bottom {
  bottom: 0;
}

.edge.left {
  left: 0;
}

.edge.right {
  right: 0;
}

.square.edge-hint .edge {
  background: color-mix(in oklab, var(--highlight) 65%, #000 35%);
}

.status {
  margin-top: 1rem;
  text-align: center;
  color: var(--text-muted);
  min-height: 1.2rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease;
}

.status.visible {
  opacity: 1;
  visibility: visible;
}

/* À gauche de l’échiquier (colonne dédiée, sans chevaucher les cases) */
.status-beside-board {
  margin-top: 0;
  text-align: left;
  font-size: 0.86rem;
  line-height: 1.35;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0;
  min-height: 0;
  height: 0;
  overflow: hidden;
  margin-bottom: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

.status-beside-board.visible {
  padding: 0.35rem 0.5rem;
  min-height: 2.25rem;
  height: auto;
  overflow: visible;
  border-radius: 8px;
  background: rgb(10 24 21 / 88%);
  box-shadow: 0 1px 10px rgb(0 0 0 / 30%);
}

.feedback {
  margin-top: 0.65rem;
  text-align: center;
  color: var(--text-muted);
  min-height: 1.2rem;
}

.analysis-panel {
  width: min(560px, 100%);
  margin: 0 auto;
  background: linear-gradient(165deg, rgb(21 47 41 / 98%), rgb(10 24 21 / 92%));
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.8rem;
  box-shadow: 0 8px 28px rgb(0 0 0 / 28%);
}

.analysis-panel + .analysis-panel {
  margin-top: 0.75rem;
}

.analysis-panel h2,
.analysis-panel h3 {
  margin: 0 0 0.6rem;
}

.analysis-panel h2 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--gold);
  font-size: 1.05rem;
}

.analysis-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.analysis-panel.collapsed .analysis-panel-head {
  margin-bottom: 0;
}

.analysis-panel-head h2 {
  margin: 0;
  flex: 1;
}

.analysis-panel-toggle {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: rgb(10 24 21 / 55%);
  color: var(--gold);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.analysis-panel-toggle:hover {
  background: rgb(255 255 255 / 8%);
  border-color: rgb(212 175 55 / 35%);
}

.analysis-panel-toggle:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.analysis-panel-toggle-icon::before {
  content: "▼";
  font-size: 0.55rem;
  line-height: 1;
  display: inline-block;
  transition: transform 0.18s ease;
}

.analysis-panel.collapsed .analysis-panel-toggle-icon::before {
  transform: rotate(-90deg);
}

.analysis-panel.collapsed .analysis-panel-body {
  display: none;
}

.history-panel {
  width: 100%;
  background: linear-gradient(165deg, rgb(21 47 41 / 98%), rgb(10 24 21 / 92%));
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.8rem;
  box-shadow: 0 8px 28px rgb(0 0 0 / 28%);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* Scroll limité UNIQUEMENT hors mode interactif (édition / historique / notation) */
body:not(.interactive-mode) .history-panel {
  max-height: min(var(--board-column-height), calc(100vh - 7.5rem));
  overflow: hidden;
}

body:not(.interactive-mode) .move-tree {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
}

body:not(.interactive-mode) .edit-history-ui {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

body:not(.interactive-mode) .history-move-nav-wrap {
  flex-shrink: 0;
}

.history-lichess-link {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.55rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgb(var(--gold-rgb) / 40%);
  background: rgb(21 47 41 / 92%);
  color: var(--gold);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}

.history-lichess-link:hover {
  border-color: rgb(var(--gold-rgb) / 62%);
  background: rgb(var(--gold-rgb) / 12%);
}

.history-lichess-link[hidden] {
  display: none !important;
}

.history-lesson-score {
  flex-shrink: 0;
  margin-top: 0.45rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid rgb(var(--gold-rgb) / 35%);
  background: rgb(var(--gold-rgb) / 10%);
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
}

.history-lesson-score[hidden] {
  display: none !important;
}

.history-panel h3 {
  margin: 0 0 0.6rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.06em;
  color: var(--gold);
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border-subtle);
  background: rgb(10 24 21 / 65%);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem;
  margin: 0.4rem 0 0.5rem;
}

.pgn-tags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.55rem 0.75rem;
  margin-bottom: 0.35rem;
}

.pgn-tag-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.pgn-tag-field input,
.pgn-tag-field select {
  width: 100%;
  margin: 0;
  padding: 0.38rem 0.45rem;
  border: 1px solid var(--border-subtle);
  background: rgb(10 24 21 / 65%);
  color: var(--text);
  border-radius: 8px;
  font-size: 0.88rem;
}

.pgn-tag-field-result {
  grid-column: 1 / -1;
  max-width: 12rem;
}

.fen-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.move-tree {
  flex: 1 1 auto;
  min-height: 8.5rem;
  max-height: min(300px, 42vh);
  overflow-y: auto;
  overflow-x: hidden;
}

.move-comment-panel {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.move-comment-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.35rem;
}

.move-comment-panel textarea.move-comment-input {
  width: 100%;
  margin: 0;
  min-height: 4.25rem;
  max-height: 8rem;
  font-size: 0.82rem;
  line-height: 1.45;
  resize: vertical;
}

.move-comment-panel textarea.move-comment-input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  resize: none;
}

.move-row {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.45rem 0.55rem;
  align-items: center;
  margin-bottom: 0.3rem;
  font-family:
    Consolas,
    "Segoe UI Symbol",
    "Noto Sans Symbols 2",
    "DejaVu Sans",
    "Courier New",
    monospace;
  font-variant-numeric: tabular-nums;
}

.move-row-white-only {
  grid-template-columns: 2.2rem minmax(0, 1fr);
}

.move-row-white-only .move-white {
  grid-column: 2;
}

.move-row-black-only .move-black {
  grid-column: 3;
}

.move-tree .move-no {
  color: var(--text-muted);
  white-space: nowrap;
}

.move-tree .move-white,
.move-tree .move-black {
  min-width: 0;
}

.move-tree .move-white {
  text-align: left;
  white-space: nowrap;
}

.move-tree .move-black {
  text-align: right;
  white-space: nowrap;
}

.variation-block {
  display: flex;
  flex-direction: column;
}

/* Ligne principale : fond noir ; variantes : fond normal (pas de teinte or). */
.variation-mainline > .move-row {
  background: #070b0a;
  border-radius: 6px;
  padding: 0.18rem 0.35rem;
  margin-bottom: 0.28rem;
}

.variation-nested {
  margin-left: 0.9rem;
  padding: 0.3rem 0.35rem 0.25rem 0.6rem;
  border-left: 2px solid rgb(var(--gold-rgb) / 28%);
  background: transparent;
  border-radius: 8px;
  margin-top: 0.2rem;
  margin-bottom: 0.25rem;
  font-size: 0.88rem;
}

.variation-nested .move-row {
  margin-bottom: 0.2rem;
  background: transparent;
}

.clickable-move {
  cursor: pointer;
  border-radius: 6px;
  padding: 0.08rem 0.2rem;
}

.clickable-move:hover:not(.active-move) {
  background: rgb(255 255 255 / 10%);
}

.active-move {
  background: linear-gradient(180deg, rgb(var(--gold-rgb) / 88%), rgb(176 128 18 / 93%));
  color: #141008;
}

.active-move:hover {
  background: linear-gradient(180deg, rgb(var(--gold-rgb) / 88%), rgb(176 128 18 / 93%));
  color: #141008;
}

.move-tree .move-nag-glyph {
  font-weight: 700;
}

.move-tree .move-nag-glyph.nag-vis-good {
  color: #5cbf98;
}

.move-tree .move-nag-glyph.nag-vis-bad {
  color: var(--capture);
}

.move-tree .move-nag-glyph.nag-vis-interesting {
  color: var(--gold);
}

.move-tree .move-nag-glyph.nag-vis-eval {
  color: #8eb8ff;
}

.move-tree .move-nag-glyph.nag-vis-novelty {
  color: #c9e872;
}

.move-tree .move-nag-glyph.nag-vis-idea {
  color: #7ec8e3;
}

.move-tree .move-nag-glyph.nag-vis-only {
  color: #d4c8f5;
}

.move-tree .move-nag-glyph.nag-vis-muted {
  color: #aab8b3;
}

.move-tree .move-nag-glyph.nag-vis-other {
  color: #c5cfc9;
}

.active-move .move-nag-glyph.nag-vis-good {
  color: #14523c;
}

.active-move .move-nag-glyph.nag-vis-bad {
  color: #7a251c;
}

.active-move .move-nag-glyph.nag-vis-interesting {
  color: #5c4810;
}

.active-move .move-nag-glyph.nag-vis-eval {
  color: #2a5080;
}

.active-move .move-nag-glyph.nag-vis-novelty {
  color: #3d6218;
}

.active-move .move-nag-glyph.nag-vis-idea {
  color: #215a6e;
}

.active-move .move-nag-glyph.nag-vis-only {
  color: #4a3d68;
}

.active-move .move-nag-glyph.nag-vis-muted {
  color: #4a5550;
}

.active-move .move-nag-glyph.nag-vis-other {
  color: #3a3f3c;
}

.move-annotation-badge {
  position: absolute;
  top: 0;
  right: 0;
  /* Coin haut-droit de la case : décal diagonal vers l’extérieur. */
  transform: translate(
    calc(var(--square-size) * 0.16),
    calc(-1 * var(--square-size) * 0.16)
  );
  z-index: 30;
  box-sizing: border-box;
  min-width: max(2rem, calc(var(--square-size) * 0.42));
  min-height: max(2rem, calc(var(--square-size) * 0.42));
  padding: 0.14rem 0.48rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family:
    system-ui,
    "Segoe UI Symbol",
    "Noto Sans Symbols 2",
    "DejaVu Sans",
    sans-serif;
  font-size: clamp(0.85rem, calc(var(--square-size) * 0.28), 1.15rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: #fff;
  border-radius: 999px;
  box-shadow:
    0 1px 3px rgb(0 0 0 / 40%),
    inset 0 1px 0 rgb(255 255 255 / 22%);
  text-shadow: 0 1px 2px rgb(0 0 0 / 42%);
  pointer-events: auto;
  cursor: inherit;
}

.move-annotation-badge-wide {
  min-width: max(2.45rem, calc(var(--square-size) * 0.52));
  min-height: max(1.75rem, calc(var(--square-size) * 0.32));
  padding: 0.18rem 0.46rem;
  font-size: clamp(0.72rem, calc(var(--square-size) * 0.2), 0.95rem);
  white-space: nowrap;
}

.move-annotation-badge-interesting {
  background: linear-gradient(165deg, #e888b8, #c06090);
}

.move-annotation-badge-good {
  background: linear-gradient(165deg, #4daf88, #2a7058);
}

.move-annotation-badge-bad {
  background: linear-gradient(165deg, #e07048, #b03828);
}

.move-annotation-badge-eval {
  background: linear-gradient(165deg, #5878c8, #384878);
}

.move-annotation-badge-novelty {
  background: linear-gradient(165deg, #88a838, #586818);
}

.move-annotation-badge-idea {
  background: linear-gradient(165deg, #4898b8, #286878);
}

.move-annotation-badge-only {
  background: linear-gradient(165deg, #786898, #584868);
}

.move-annotation-badge-muted {
  background: linear-gradient(165deg, #708078, #485850);
}

.move-annotation-badge-other {
  background: linear-gradient(165deg, #586860, #384038);
}

.move-comment-inline {
  display: block;
  margin-top: 0.05rem;
  margin-bottom: 0.35rem;
}

.move-comment-inline-body {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-muted);
  padding: 0.15rem 0.2rem 0.25rem;
  background: transparent;
  border: none;
  border-radius: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.variation-nested .move-comment-inline {
  margin-bottom: 0.22rem;
}

.pgn-hint {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.pgn-hint code {
  font-size: 0.78rem;
  padding: 0.12rem 0.28rem;
  border-radius: 4px;
  background: rgb(10 24 21 / 72%);
  border: 1px solid var(--border-subtle);
}

.promotion-dialog {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgb(5 12 10 / 72%);
  backdrop-filter: blur(3px);
}

.promotion-dialog.open {
  display: flex;
}

.promotion-dialog-panel {
  background: linear-gradient(165deg, rgb(21 47 41 / 99%), rgb(10 24 21 / 96%));
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  box-shadow: 0 16px 48px rgb(0 0 0 / 48%);
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.promotion-dialog-title {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold);
  font-size: 1.05rem;
}

.promotion-dialog-sub {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.promotion-choices {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.promotion-choice {
  width: 72px;
  height: 72px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.promotion-choice img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 35%));
}

.move-context-menu {
  position: fixed;
  z-index: 9999;
  display: none;
  min-width: 260px;
  background: linear-gradient(165deg, rgb(21 47 41 / 99%), rgb(10 24 21 / 96%));
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: 0 12px 36px rgb(0 0 0 / 42%);
  padding: 0.35rem;
}

.move-context-menu.open {
  display: block;
}

.move-context-menu button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font-weight: 600;
}

.move-context-menu button:hover {
  background: var(--gold-soft);
}

/* ——— Mode interactif ——— */
body.interactive-mode .feedback {
  display: none !important;
}

body.interactive-mode .container {
  max-width: none;
  padding: 0.65rem 1rem 1.25rem;
}

body.interactive-mode .header {
  margin-bottom: 0.35rem;
}

body.interactive-mode .header h1 {
  font-size: clamp(1.2rem, 2.2vw, 1.85rem);
  padding-inline: clamp(6.5rem, 12vw, 9.5rem);
}

body.interactive-mode .header h1::after {
  margin-top: 0.4rem;
}

body.interactive-mode .ecole-brand {
  margin: 0.25rem 0 0.45rem;
  font-size: 0.82rem;
}

body.interactive-mode:not(.lesson-layout) .study-stage {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 1.1rem;
  margin-bottom: 0;
}

body.interactive-mode:not(.lesson-layout) .board-area {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 0;
}

body.interactive-mode:not(.lesson-layout) .board-column {
  align-self: flex-end;
  flex: 0 0 auto;
}

body.interactive-mode:not(.lesson-layout) .history-panel {
  align-self: flex-end;
  margin-top: 0;
  height: auto;
  min-height: 0;
  max-height: none !important;
  display: block;
  overflow: visible !important;
}

body.interactive-mode:not(.lesson-layout) .board-area-side-left {
  display: flex;
  flex: 0 0 9.5rem;
  width: 9.5rem;
  max-width: 9.5rem;
  align-self: stretch;
}

/* Leçon : même ancrage échiquier en interactif et en notation */
body.lesson-layout .container {
  max-width: none;
  padding: 0.65rem 1rem 1.25rem;
}

body.lesson-layout .header {
  margin-bottom: 0.35rem;
}

body.lesson-layout .header h1 {
  font-size: clamp(1.2rem, 2.2vw, 1.85rem);
  padding-inline: clamp(6.5rem, 12vw, 9.5rem);
}

body.lesson-layout .header h1::after {
  margin-top: 0.4rem;
}

body.lesson-layout .ecole-brand {
  margin: 0.25rem 0 0.45rem;
  font-size: 0.82rem;
}

body.lesson-layout .study-stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 1.1rem;
  margin-bottom: 0;
}

@media (min-width: 901px) {
  body.lesson-layout .container,
  body.interactive-mode .container {
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
    max-height: 100vh;
    overflow: hidden;
    box-sizing: border-box;
  }

  body.lesson-layout .study-stage,
  body.interactive-mode .study-stage {
    max-height: calc(100vh - 5.5rem);
    overflow: hidden;
  }

  body.lesson-layout .board-area {
    align-items: stretch;
    max-height: calc(100vh - 5.5rem);
  }

  body.lesson-layout .board-area-side-left {
    height: auto;
    max-height: calc(100vh - 5.5rem);
    align-self: stretch;
  }

  body.lesson-layout .board-column {
    max-height: calc(100vh - 5.5rem);
  }

  body.lesson-layout .history-panel {
    max-height: min(var(--board-column-height), calc(100vh - 5.5rem));
  }
}

body.lesson-layout .board-area {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0;
}

body.lesson-layout .board-column {
  align-self: flex-start;
  flex: 0 0 auto;
  align-items: flex-start;
}

body.lesson-layout .board-area-side-left {
  display: flex;
  flex: 0 0 9.5rem;
  width: 9.5rem;
  max-width: 9.5rem;
  align-self: stretch;
}

body.lesson-layout .lesson-photos {
  min-height: 0;
  height: 100%;
  justify-content: space-between;
  gap: 0.35rem;
}

body.lesson-layout .history-panel {
  align-self: flex-start;
  margin-top: 0;
  max-height: min(var(--board-column-height), calc(100vh - 7.5rem));
  overflow: hidden;
}

/* Largeurs panneau droit : ordi — même largeur avec ou sans noms de joueurs */
@media (min-width: 901px) {
  .study-stage .history-panel {
    flex: 0 0 clamp(380px, 40vw, 560px);
    width: clamp(380px, 40vw, 560px);
    min-width: 340px;
    max-width: none;
  }
}

/* Ordi + leçon interactive : panneau droit collé en bas (aligné sur l’échiquier) */
body.lesson-layout.interactive-mode .history-panel {
  align-self: flex-end;
  overflow: visible;
  max-height: none;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

/* En mode interactif : pas d’enveloppe autour commentaires / consignes */
body.interactive-mode .history-panel {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

/* Noms joueurs au-dessus / en dessous de l'échiquier */
.player-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 1.9rem;
  padding: 0.15rem 0;
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--text);
}

body.lesson-layout .player-bar {
  width: calc(8 * var(--square-size));
  margin-inline-start: var(--board-badge-gutter);
  box-sizing: border-box;
}

body.lesson-layout .player-bar-top {
  margin-bottom: 0;
}

body.lesson-layout .player-bar-bottom {
  margin-top: 0;
}

.board-under-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  min-height: 0;
  margin-top: 0;
  box-sizing: border-box;
}

body.lesson-layout .board-under-row {
  width: calc(8 * var(--square-size));
  margin-inline-start: var(--board-badge-gutter);
}

body.lesson-layout .board-under-row .player-bar {
  width: auto;
  max-width: 55%;
  margin-inline-start: 0;
  flex: 1 1 auto;
  min-width: 0;
}

body.lesson-layout .board-under-row .player-bar-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-bar[hidden] {
  display: none !important;
}

.player-bar-top:not(body.lesson-layout *) {
  margin-bottom: 0.35rem;
}

.player-bar-bottom:not(body.lesson-layout *) {
  margin-top: 0.35rem;
}

.player-bar-dot {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgb(255 255 255 / 35%);
}

.player-bar-dot-white {
  background: #f3f5f2;
}

.player-bar-dot-black {
  background: #1a1f1d;
}

.player-bar-name {
  letter-spacing: 0.02em;
}

/* Photos desktop à gauche */
.lesson-photos {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.35rem;
  flex: 1;
  min-height: calc(8 * var(--square-size));
  height: 100%;
}

.lesson-photo-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.lesson-photo-frame {
  width: min(9.5rem, 14vw);
  aspect-ratio: 0.65;
  height: auto;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: rgb(10 24 21 / 70%);
  box-shadow: 0 6px 18px rgb(0 0 0 / 28%);
}

.lesson-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.lesson-photo-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(145deg, rgb(61 124 110 / 25%), transparent 55%),
    rgb(10 24 21 / 80%);
}

.lesson-photo-fallback::before {
  content: "";
  width: 68%;
  height: 78%;
  background: rgb(210 220 215 / 40%);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 80'%3E%3Ccircle cx='32' cy='24' r='16'/%3E%3Cpath d='M8 76c0-16.569 10.745-30 24-30s24 13.431 24 30'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 80'%3E%3Ccircle cx='32' cy='24' r='16'/%3E%3Cpath d='M8 76c0-16.569 10.745-30 24-30s24 13.431 24 30'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.lesson-photo-caption {
  display: none !important;
}

/* Responsive mobile — mode interactif / leçon */
@media (max-width: 900px) {
  :root {
    /* 8.2 = 8 cases + 2× gutter (~0.1s) ; marge pour ne pas coller aux bords. */
    --square-size: min(48px, calc((100vw - 1.25rem) / 8.2));
    --board-border-size: 5px;
    --board-badge-gutter: calc(var(--square-size) * 0.1);
    --board-badge-gutter-y: calc(var(--square-size) * 0.06);
  }

  /* Badges NAG sur l’échiquier : plus compacts (sinon trop gros vs la case). */
  .board-nag-badges .move-annotation-badge {
    min-width: max(1.05rem, calc(var(--square-size) * 0.3));
    min-height: max(1.05rem, calc(var(--square-size) * 0.3));
    padding: 0.05rem 0.22rem;
    font-size: clamp(0.58rem, calc(var(--square-size) * 0.22), 0.78rem);
  }

  .board-nag-badges .move-annotation-badge-wide {
    min-width: max(1.35rem, calc(var(--square-size) * 0.38));
    min-height: max(0.95rem, calc(var(--square-size) * 0.24));
    padding: 0.06rem 0.24rem;
    font-size: clamp(0.52rem, calc(var(--square-size) * 0.16), 0.7rem);
  }

  body.interactive-mode .container,
  body.lesson-layout .container {
    display: flex;
    flex-direction: column;
    width: 100% !important;
    max-width: none !important;
    margin-inline: 0 !important;
    /* Pas de padding horizontal : les commentaires prennent tout l’écran ;
       l’échiquier reste centré via sa max-width. */
    padding: 0.3rem 0 1rem !important;
    box-sizing: border-box;
    align-items: stretch !important;
  }

  /* Titre masqué ; tout le header (lien école + paramètres) passe en bas */
  body.interactive-mode .header,
  body.lesson-layout .header {
    order: 90;
    position: static;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    margin: 1rem 0 0.25rem;
    padding: 0 0.55rem;
    text-align: center;
  }

  body.interactive-mode .header h1,
  body.lesson-layout .header h1,
  body.interactive-mode .header h1::after,
  body.lesson-layout .header h1::after {
    display: none !important;
  }

  body.interactive-mode .ecole-brand,
  body.lesson-layout .ecole-brand {
    order: 2;
    margin: 0.15rem 0 0;
    font-size: 0.8rem;
  }

  body.interactive-mode .settings-box,
  body.lesson-layout .settings-box {
    order: 1;
    position: relative;
    top: auto;
    right: auto;
    display: flex;
    justify-content: center;
    margin: 0;
  }

  body.interactive-mode .settings-menu,
  body.lesson-layout .settings-menu {
    top: auto;
    bottom: calc(100% + 0.45rem);
    right: 50%;
    left: auto;
    transform: translateX(50%);
    min-width: min(300px, calc(100vw - 1.5rem));
  }

  body.interactive-mode .controls,
  body.lesson-layout .controls {
    order: 2;
  }

  body.interactive-mode .board-area-side-left,
  .lesson-photos {
    display: none !important;
  }

  /*
   * Commentaires = même largeur que l’échiquier (qui peut déborder du container).
   * On ne touche pas à la taille du plateau.
   */
  body.interactive-mode .study-stage,
  body.lesson-layout .study-stage {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    align-self: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    gap: 0.45rem;
    order: 1;
    margin-bottom: 0;
    box-sizing: border-box !important;
    overflow-x: clip !important;
    overflow-y: visible !important;
  }

  body.interactive-mode .study-stage .board-area,
  body.lesson-layout .study-stage .board-area {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: auto !important;
    max-width: 100% !important;
    min-width: 0 !important;
    gap: 0.35rem;
    margin-bottom: 0;
    padding-inline: 0;
    box-sizing: border-box;
    overflow: visible !important;
  }

  body.interactive-mode .board-column,
  body.interactive-mode:not(.lesson-layout) .board-column,
  body.lesson-layout .board-column {
    width: auto !important;
    max-width: 100% !important;
    align-items: stretch;
    flex: none !important;
    box-sizing: border-box;
  }

  body.interactive-mode .board-shell,
  body.lesson-layout .board-shell {
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Même formule de largeur que le plateau (square-size JS inclus). */
  body.interactive-mode .history-panel,
  body.interactive-mode:not(.lesson-layout) .history-panel,
  body.lesson-layout.interactive-mode .history-panel,
  body.lesson-layout .history-panel,
  body.interactive-mode .interactive-panel,
  body.interactive-mode .interactive-comment,
  body.interactive-mode .interactive-floor,
  body.lesson-layout .interactive-panel,
  body.lesson-layout .interactive-comment,
  body.lesson-layout .interactive-floor {
    width: calc(
      8 * var(--square-size) + 2 * var(--board-border-size) + 2 * var(--board-badge-gutter)
    ) !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  body.interactive-mode .history-panel,
  body.interactive-mode:not(.lesson-layout) .history-panel,
  body.lesson-layout.interactive-mode .history-panel,
  body.lesson-layout .history-panel {
    margin: 2px auto 0 !important;
    padding: 0 !important;
    align-self: center !important;
    flex: none !important;
    height: auto;
    min-height: 0;
    max-height: none !important;
    overflow: visible !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    display: block !important;
    position: static !important;
    left: auto !important;
    transform: none !important;
  }

  body.interactive-mode .interactive-panel,
  body.interactive-mode:not(.lesson-layout) .interactive-panel,
  body.lesson-layout .interactive-panel,
  body.lesson-layout.interactive-mode .interactive-panel {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    margin-top: 2px;
    box-sizing: border-box !important;
  }

  body.interactive-mode .interactive-comment,
  body.interactive-mode:not(.lesson-layout) .interactive-comment,
  body.lesson-layout .interactive-comment,
  body.lesson-layout.interactive-mode .interactive-comment {
    display: block !important;
    max-height: none !important;
    overflow: visible !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  body.interactive-mode .interactive-floor,
  body.interactive-mode:not(.lesson-layout) .interactive-floor,
  body.lesson-layout .interactive-floor,
  body.lesson-layout.interactive-mode .interactive-floor {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  body.interactive-mode .interactive-feedback,
  body.interactive-mode .interactive-solution-btn,
  body.interactive-mode .interactive-quit-btn,
  body.interactive-mode .interactive-view-notation,
  body.interactive-mode .interactive-lichess-link {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box !important;
  }

  body.lesson-layout .player-bar {
    width: 100%;
    max-width: calc(8 * var(--square-size));
    margin-inline: auto;
  }

  body.lesson-layout .board-under-row {
    width: 100%;
    max-width: calc(8 * var(--square-size));
    margin-inline: auto;
    margin-top: 0.1rem;
  }

  body.lesson-layout .board-under-row .player-bar {
    max-width: 52%;
  }

  body.lesson-layout .player-bar-top {
    margin-bottom: 0;
  }

  body.lesson-layout .player-bar-bottom {
    margin-top: 0;
  }

  .board-under-row .interactive-last-move {
    font-size: 0.78rem;
    max-width: 50%;
  }

  .player-bar {
    font-size: 0.85rem;
    min-height: 1.45rem;
    padding: 0;
  }

  body.interactive-mode .interactive-panel,
  body.interactive-mode:not(.lesson-layout) .interactive-panel,
  body.lesson-layout .interactive-panel,
  body.lesson-layout.interactive-mode .interactive-panel {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    margin-top: 2px;
    box-sizing: border-box !important;
  }

  body.interactive-mode .interactive-comment,
  body.interactive-mode:not(.lesson-layout) .interactive-comment,
  body.lesson-layout .interactive-comment,
  body.lesson-layout.interactive-mode .interactive-comment {
    display: block !important;
    max-height: none !important;
    overflow: visible !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  body.interactive-mode .interactive-floor,
  body.interactive-mode:not(.lesson-layout) .interactive-floor,
  body.lesson-layout .interactive-floor,
  body.lesson-layout.interactive-mode .interactive-floor {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  body.interactive-mode .interactive-feedback,
  body.interactive-mode .interactive-solution-btn,
  body.interactive-mode .interactive-quit-btn,
  body.interactive-mode .interactive-view-notation,
  body.interactive-mode .interactive-lichess-link {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box !important;
  }
}

.interactive-panel {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  overflow: visible;
}

.interactive-panel[hidden] {
  display: none !important;
}

.interactive-last-move {
  margin: 0 0 0.55rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.02em;
  min-height: 1.25rem;
}

.interactive-last-move:empty {
  display: none;
}

.board-under-row .interactive-last-move {
  margin: 0 0 0 auto;
  flex: 0 1 auto;
  max-width: 48%;
  text-align: right;
  font-size: 0.78rem;
  line-height: 1.25;
  min-height: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.interactive-comment {
  display: block;
  width: 100%;
  box-sizing: border-box;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
  padding: 0.85rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: rgb(10 24 21 / 72%);
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.5;
  white-space: pre-wrap !important;
  word-break: break-word;
}

.interactive-comment a.pgn-comment-link,
.move-comment-inline-body a.pgn-comment-link {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 0.12em;
  word-break: break-all;
}

.interactive-comment a.pgn-comment-link:hover,
.move-comment-inline-body a.pgn-comment-link:hover {
  color: #f0d78c;
}

.interactive-comment:empty {
  display: none;
}

.interactive-floor {
  margin-top: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex-shrink: 0;
}

.interactive-feedback {
  width: 100%;
  min-height: 3rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: left;
  cursor: default;
  box-shadow: 0 2px 10px rgb(0 0 0 / 22%);
}

.interactive-feedback[hidden] {
  display: none !important;
}

.interactive-feedback.play {
  background: rgb(21 47 41 / 95%);
  border-color: var(--border-subtle);
  color: var(--text);
  cursor: default;
}

.interactive-feedback.good,
.interactive-feedback.good.com {
  background: linear-gradient(180deg, #3d9a6e 0%, #2a7050 100%);
  border-color: rgb(120 200 150 / 55%);
  color: #f4fff8;
  cursor: pointer;
}

.interactive-feedback.good:hover,
.interactive-feedback.good.com:hover {
  filter: brightness(1.06);
}

.interactive-feedback.bad,
.interactive-feedback.bad.com {
  background: linear-gradient(180deg, #c05048 0%, #8a3028 100%);
  border-color: rgb(230 140 120 / 45%);
  color: #fff8f6;
  cursor: pointer;
}

.interactive-feedback.bad:hover,
.interactive-feedback.bad.com:hover {
  filter: brightness(1.06);
}

.interactive-feedback.nag-fb-good,
.interactive-feedback.nag-fb-good.com {
  background: linear-gradient(165deg, #4daf88, #2a7058);
  border-color: rgb(120 200 150 / 55%);
  color: #f4fff8;
  cursor: pointer;
}

.interactive-feedback.nag-fb-interesting,
.interactive-feedback.nag-fb-interesting.com {
  background: linear-gradient(165deg, #e888b8, #c06090);
  border-color: rgb(240 180 210 / 50%);
  color: #fff8fb;
  cursor: pointer;
}

.interactive-feedback.nag-fb-bad,
.interactive-feedback.nag-fb-bad.com {
  background: linear-gradient(165deg, #e07048, #b03828);
  border-color: rgb(230 140 120 / 45%);
  color: #fff8f6;
  cursor: pointer;
}

.interactive-feedback.nag-fb-eval,
.interactive-feedback.nag-fb-eval.com {
  background: linear-gradient(165deg, #5878c8, #384878);
  border-color: rgb(160 185 230 / 45%);
  color: #f4f7ff;
  cursor: pointer;
}

.interactive-feedback.nag-fb-novelty,
.interactive-feedback.nag-fb-novelty.com {
  background: linear-gradient(165deg, #88a838, #586818);
  border-color: rgb(190 210 120 / 45%);
  color: #f8fff0;
  cursor: pointer;
}

.interactive-feedback.nag-fb-idea,
.interactive-feedback.nag-fb-idea.com {
  background: linear-gradient(165deg, #4898b8, #286878);
  border-color: rgb(140 200 220 / 45%);
  color: #f4fcff;
  cursor: pointer;
}

.interactive-feedback.nag-fb-only,
.interactive-feedback.nag-fb-only.com {
  background: linear-gradient(165deg, #786898, #584868);
  border-color: rgb(180 170 210 / 45%);
  color: #f8f6ff;
  cursor: pointer;
}

.interactive-feedback.nag-fb-muted,
.interactive-feedback.nag-fb-muted.com,
.interactive-feedback.nag-fb-other,
.interactive-feedback.nag-fb-other.com {
  background: linear-gradient(165deg, #708078, #485850);
  border-color: rgb(160 175 168 / 40%);
  color: #f4f8f6;
  cursor: pointer;
}

.interactive-feedback.nag-fb-good:hover,
.interactive-feedback.nag-fb-interesting:hover,
.interactive-feedback.nag-fb-bad:hover,
.interactive-feedback.nag-fb-eval:hover,
.interactive-feedback.nag-fb-novelty:hover,
.interactive-feedback.nag-fb-idea:hover,
.interactive-feedback.nag-fb-only:hover,
.interactive-feedback.nag-fb-muted:hover,
.interactive-feedback.nag-fb-other:hover,
.interactive-feedback.nag-fb-good.com:hover,
.interactive-feedback.nag-fb-interesting.com:hover,
.interactive-feedback.nag-fb-bad.com:hover {
  filter: brightness(1.06);
}

.interactive-feedback.end {
  background: rgb(21 47 41 / 95%);
  border-color: rgb(var(--gold-rgb) / 45%);
  color: var(--gold);
  cursor: default;
}

.interactive-feedback.solution {
  background: linear-gradient(180deg, #3a6a9a 0%, #2a4a78 100%);
  border-color: rgb(140 180 230 / 45%);
  color: #f0f6ff;
  cursor: pointer;
}

.interactive-solution-btn,
.interactive-view-notation,
.interactive-lichess-link,
.interactive-quit-btn {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgb(var(--gold-rgb) / 40%);
  background: rgb(21 47 41 / 92%);
  color: var(--gold);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

.interactive-solution-btn:hover,
.interactive-view-notation:hover,
.interactive-lichess-link:hover,
.interactive-quit-btn:hover {
  border-color: rgb(var(--gold-rgb) / 62%);
  background: rgb(var(--gold-rgb) / 12%);
}

.interactive-quit-btn {
  border-color: rgb(255 255 255 / 14%);
  color: var(--text-muted);
  font-weight: 600;
}

.interactive-view-notation[hidden],
.interactive-lichess-link[hidden],
.interactive-solution-btn[hidden] {
  display: none !important;
}

.interactive-score {
  margin: 0;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid rgb(var(--gold-rgb) / 35%);
  background: rgb(var(--gold-rgb) / 10%);
  color: var(--gold);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
}

.interactive-score[hidden] {
  display: none !important;
}

.pgn-editor-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgb(0 0 0 / 62%);
}

.pgn-editor-modal[hidden] {
  display: none !important;
}

.pgn-editor-dialog {
  width: min(920px, 96vw);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: linear-gradient(165deg, rgb(21 47 41 / 99%), rgb(10 24 21 / 98%));
  box-shadow: 0 18px 48px rgb(0 0 0 / 45%);
}

.pgn-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.pgn-editor-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--gold);
}

.pgn-editor-close {
  min-width: 2rem;
  min-height: 2rem;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
}

.pgn-editor-textarea {
  flex: 1 1 auto;
  min-height: min(60vh, 520px);
  width: 100%;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: rgb(10 24 21 / 72%);
  color: var(--text);
  padding: 0.65rem 0.75rem;
  box-sizing: border-box;
}

.pgn-editor-actions {
  display: flex;
  justify-content: flex-end;
}

.pgn-editor-save {
  min-width: 8rem;
  font-weight: 700;
}
