:root {
  --bg-deep: #070b14;
  --bg-radial-top: #111b30;
  --panel-bg: rgba(15, 23, 42, 0.78);
  --panel-card: rgba(30, 41, 59, 0.62);
  --panel-border: rgba(148, 163, 184, 0.16);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-cyan: #38bdf8;
  --accent-cyan-glow: rgba(56, 189, 248, 0.28);
  --accent-amber: #fbbf24;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --radius-lg: 16px;
  --radius-md: 11px;
  --radius-sm: 8px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(circle at 32% 28%, var(--bg-radial-top), var(--bg-deep) 72%);
  color: var(--text-main);
  overflow: hidden;
  user-select: none;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* ============================================================================
   TOPBAR
   ============================================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 20px;
  background: rgba(9, 14, 26, 0.84);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--panel-border);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-cube-icon {
  display: grid;
  grid-template-columns: repeat(3, 8px);
  grid-template-rows: repeat(3, 8px);
  gap: 2px;
  padding: 4px;
  background: #0b0f17;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-cube-icon span {
  border-radius: 2px;
}
.brand-cube-icon .c-r { background: #e11d38; }
.brand-cube-icon .c-y { background: #ffd500; }
.brand-cube-icon .c-b { background: #0055d4; }
.brand-cube-icon .c-g { background: #00b353; }
.brand-cube-icon .c-w { background: #f8fafc; }
.brand-cube-icon .c-o { background: #ff6a00; }

.brand-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  margin: 1px 0 0;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.mode-switch {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.mode-btn:hover {
  color: var(--text-main);
}

.mode-btn.is-active {
  background: rgba(56, 189, 248, 0.16);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.45);
}

#btn-mode-freeplay.is-active {
  background: rgba(251, 191, 36, 0.16);
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.48);
}

.mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.training-dot { background: var(--accent-cyan); }
.freeplay-dot { background: var(--accent-amber); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-pill {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(30, 41, 59, 0.55);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.icon-pill:hover {
  color: var(--text-main);
  border-color: rgba(148, 163, 184, 0.36);
}

.icon-pill.is-active {
  color: var(--text-main);
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.4);
}

.back-portal-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  white-space: nowrap;
}

/* ============================================================================
   WORKSPACE LAYOUT
   ============================================================================ */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  min-height: 0;
}

.stage-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.canvas-container {
  flex: 1;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.canvas-container:active {
  cursor: grabbing;
}

/* ============================================================================
   HUD SCÈNE 3D (ORIENTATION, PATRON 2D, PAVÉ DE MOUVEMENTS)
   ============================================================================ */
.viewport-hud-top {
  position: absolute;
  top: 14px;
  left: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  z-index: 8;
  pointer-events: none;
}

.viewed-face-pill,
.peek-bottom-btn,
.align-recommended-btn {
  pointer-events: auto;
}

.peek-bottom-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(12px);
  color: var(--text-main);
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.peek-bottom-btn:hover {
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(30, 41, 59, 0.92);
}

.peek-bottom-btn.is-active {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.22);
  color: #ffffff;
}

.viewed-face-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  font-size: 0.82rem;
}

.cam-step-btn {
  background: rgba(255, 255, 255, 0.07);
  border: none;
  color: var(--text-main);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.7rem;
  display: grid;
  place-items: center;
}
.cam-step-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.face-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: #00b353;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.align-recommended-btn {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.65);
  background: rgba(245, 158, 11, 0.22);
  backdrop-filter: blur(10px);
  color: #fef08a;
  font-size: 0.81rem;
  font-weight: 600;
  cursor: pointer;
  animation: gentlePulse 2s infinite;
}

@keyframes gentlePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* Mini-patron 2D */
.net-floating-card {
  position: absolute;
  top: 14px;
  right: 16px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  z-index: 8;
}

.net-card-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.cube-net-grid {
  display: grid;
  grid-template-columns: repeat(4, 34px);
  grid-template-rows: repeat(3, 34px);
  gap: 4px;
}

.net-face {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 1.5px;
  padding: 2px;
  background: #090d16;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.net-face.is-active-front {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.35);
}

.net-sticker {
  border-radius: 1.5px;
}

/* Bannière de célébration (placée en haut pour ne jamais masquer le cube ni la face du bas) */
.celebration-banner {
  position: absolute;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  background: rgba(6, 78, 59, 0.92);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(52, 211, 153, 0.6);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  z-index: 12;
  max-width: 90%;
}

.celebration-content strong {
  display: block;
  font-size: 0.94rem;
  color: #ecfdf5;
}
.celebration-content p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: #a7f3d0;
}

/* Pavé inférieur de rotations */
.move-dock {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(690px, calc(100% - 28px));
  padding: 9px 14px 11px;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  z-index: 8;
}

.move-dock-header {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 7px;
}

.move-dock-header code {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
}

.move-pad-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 5px;
}

.pad-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(30, 41, 59, 0.75);
  color: var(--text-main);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}

.pad-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(255, 255, 255, 0.35);
}

.pad-btn:active {
  transform: scale(0.95);
}

.pad-btn.is-suggested {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.22);
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.pad-dot {
  width: 14px;
  height: 4px;
  border-radius: 99px;
}

.dock-align-btn {
  margin-left: auto;
  padding: 3px 9px;
  border-radius: 99px;
  border: 1px solid rgba(251, 191, 36, 0.55);
  background: rgba(245, 158, 11, 0.2);
  color: #fde68a;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.dock-align-btn:hover {
  background: rgba(245, 158, 11, 0.34);
}

/* ============================================================================
   PANNEAU LATÉRAL DROIT
   ============================================================================ */
.side-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--panel-border);
  overflow-y: auto;
  padding: 16px;
}

.panel-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.submode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(9, 14, 26, 0.65);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
}

.submode-tab {
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.submode-tab.is-active {
  background: rgba(56, 189, 248, 0.16);
  color: var(--text-main);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.38);
}

.card-section {
  background: var(--panel-card);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}

.section-eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
}

.compact-heading {
  margin: 2px 0 0;
  font-size: 0.96rem;
}

.lesson-pills-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.lesson-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.lesson-pill:hover {
  border-color: rgba(148, 163, 184, 0.4);
  color: var(--text-main);
}

.lesson-pill.is-active {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.15);
  color: #ffffff;
}

.lesson-pill.is-done .lesson-pill-badge::after {
  content: ' ✓';
  color: var(--accent-emerald);
}

.lesson-pill-badge {
  font-size: 0.66rem;
  font-weight: 700;
  opacity: 0.85;
}

.lesson-pill-title {
  font-size: 0.73rem;
  font-weight: 600;
  margin-top: 2px;
  line-height: 1.15;
}

.lesson-variants-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.variants-label {
  display: block;
  font-size: 0.71rem;
  color: #93c5fd;
  font-weight: 600;
  margin-bottom: 6px;
}

.lesson-variants-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.variant-pill {
  padding: 5px 10px;
  border-radius: 99px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.72);
  color: var(--text-muted);
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.variant-pill:hover {
  border-color: rgba(148, 163, 184, 0.5);
  color: var(--text-main);
}

.variant-pill.is-active {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.22);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

/* Barre de progression Résolution guidée */
.progress-bar-track {
  height: 7px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-emerald));
  border-radius: 99px;
  transition: width 0.3s ease;
}

.stages-mini-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.stage-step-dot {
  font-size: 0.68rem;
  text-align: center;
  padding: 4px 0;
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.65);
  color: var(--text-muted);
  font-weight: 600;
}

.stage-step-dot.is-done {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.stage-step-dot.is-current {
  background: rgba(56, 189, 248, 0.25);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px var(--accent-cyan);
}

/* Carte du Coach */
.coach-card {
  background: linear-gradient(165deg, rgba(30, 41, 59, 0.84), rgba(15, 23, 42, 0.88));
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: var(--radius-lg);
  padding: 15px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.coach-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.stage-badge {
  padding: 3px 9px;
  border-radius: 99px;
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
  font-size: 0.72rem;
  font-weight: 700;
}

.coach-face-indicator {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.face-chip {
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 0.73rem;
  color: #0b0f19;
  background: #00c853;
  cursor: pointer;
}

.coach-title {
  margin: 0 0 6px;
  font-size: 1.02rem;
  line-height: 1.3;
}

.coach-explanation {
  margin: 0 0 12px;
  font-size: 0.84rem;
  line-height: 1.48;
  color: #cbd5e1;
  white-space: pre-line;
  user-select: text;
}

.coach-warning {
  margin-bottom: 12px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fde68a;
  font-size: 0.79rem;
  font-weight: 600;
}

.sequence-box {
  background: rgba(7, 11, 20, 0.68);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.sequence-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.step-counter {
  font-weight: 700;
  color: #7dd3fc;
}

.formula-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.formula-token {
  min-width: 32px;
  padding: 5px 8px;
  text-align: center;
  border-radius: 7px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-weight: 700;
  font-size: 0.88rem;
  background: rgba(30, 41, 59, 0.75);
  color: var(--text-muted);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.formula-token.is-done {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.4);
}

.formula-token.is-current {
  background: rgba(56, 189, 248, 0.25);
  color: #ffffff;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-cyan-glow);
  transform: scale(1.08);
}

.step-comment {
  margin: 0;
  font-size: 0.8rem;
  color: #e2e8f0;
  font-weight: 500;
}

.coach-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.tool-btn {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(30, 41, 59, 0.72);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-btn:hover:not(:disabled) {
  background: rgba(51, 65, 85, 0.92);
  border-color: rgba(255, 255, 255, 0.35);
}

.tool-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.tool-btn.is-active {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.2);
}

.accent-tool {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(14, 165, 233, 0.18);
}

/* Fiches mémo théoriques */
.theory-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.theory-card {
  padding: 11px 13px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.56);
  border: 1px solid rgba(148, 163, 184, 0.13);
}

.theory-card h3 {
  margin: 0 0 4px;
  font-size: 0.82rem;
  color: #bae6fd;
}

.theory-card p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-muted);
  white-space: pre-line;
  user-select: text;
}

/* ============================================================================
   MODE JEU LIBRE
   ============================================================================ */
.freeplay-hero-card {
  background: linear-gradient(165deg, rgba(30, 41, 59, 0.84), rgba(15, 23, 42, 0.9));
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  text-align: center;
}

.freeplay-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.no-help-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.14);
  padding: 3px 9px;
  border-radius: 99px;
}

.timer-status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.16);
  color: var(--text-muted);
}

.timer-status-pill.is-armed {
  background: rgba(16, 185, 129, 0.22);
  color: #6ee7b7;
}
.timer-status-pill.is-running {
  background: rgba(56, 189, 248, 0.24);
  color: #7dd3fc;
}

.freeplay-timer {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 3.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 6px 0;
  color: #ffffff;
}

.freeplay-subtext {
  margin: 0 0 14px;
  font-size: 0.79rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stat-box {
  background: rgba(7, 11, 20, 0.62);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
}

.stat-label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.stat-value {
  display: block;
  margin-top: 3px;
  font-size: 1rem;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}

.primary-btn {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #ffffff;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.primary-btn:hover {
  filter: brightness(1.1);
}
.primary-btn:active {
  transform: scale(0.98);
}

.small-btn {
  padding: 7px 12px;
  font-size: 0.78rem;
}

.full-width-btn {
  width: 100%;
}

.freeplay-actions-primary {
  margin-bottom: 8px;
}

.freeplay-actions-secondary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.scramble-box {
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(7, 11, 20, 0.65);
  text-align: left;
  font-size: 0.74rem;
}

.scramble-label {
  display: block;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.scramble-box code {
  color: #fde68a;
  word-break: break-word;
  user-select: text;
}

.ghost-btn {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.22);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 9px;
  cursor: pointer;
}
.ghost-btn:hover {
  color: var(--text-main);
  border-color: rgba(148, 163, 184, 0.45);
}
.tiny-btn {
  font-size: 0.72rem;
}

.records-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.record-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.65);
  font-size: 0.8rem;
}

.record-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 0;
}

/* ============================================================================
   MODALE D'AIDE
   ============================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}

.modal-card {
  width: min(520px, 100%);
  background: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.help-item {
  margin-bottom: 12px;
}
.help-item strong {
  display: block;
  font-size: 0.86rem;
  margin-bottom: 3px;
  color: #7dd3fc;
}
.help-item p {
  margin: 0;
  font-size: 0.81rem;
  line-height: 1.45;
  color: #cbd5e1;
}
.help-item code {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ============================================================================
   RESPONSIVE (TABLETTES & ÉCRANS ÉTROITS)
   ============================================================================ */
@media (max-width: 1024px) {
  html,
  body {
    overflow: auto;
  }
  .app-shell {
    height: auto;
    min-height: 100vh;
  }
  .topbar {
    flex-wrap: wrap;
  }
  .workspace {
    grid-template-columns: 1fr;
  }
  .stage-panel {
    height: 58vh;
    min-height: 430px;
  }
  .side-panel {
    border-left: none;
    border-top: 1px solid var(--panel-border);
  }
  .move-pad-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}
