:root {
  --bg: #0f0f12;
  --bg-pane: #17171c;
  --bg-pane-2: #1f1f26;
  --border: #2a2a33;
  --text: #ececf0;
  --text-dim: #9a9aa6;
  --accent: #ffd500;
  --accent-dim: #806800;
  --rubik-red: #c41e3a;
  --rubik-orange: #ff7f1f;
  --rubik-blue: #3b6df0;
  --rubik-green: #1bb55c;
  --rubik-white: #f6f6f6;
  --rubik-yellow: #ffd500;
  --remark-red: #ff5f5f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  background: var(--bg-pane-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ─── Header ─── */
.topbar {
  padding: 22px 32px 14px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  background: linear-gradient(180deg, #18181f 0%, var(--bg) 100%);
  position: relative;
}

/* ─── Language switcher (top-right of header) ─── */
.lang-switcher {
  position: absolute;
  top: 22px;
  right: 32px;
  display: flex;
  gap: 4px;
  background: var(--bg-pane-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}
.lang-btn {
  background: transparent;
  color: var(--text-dim);
  border: none;
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active {
  background: var(--accent);
  color: #000;
}
@media (max-width: 600px) {
  .lang-switcher {
    position: static;
    margin: 10px auto 0;
    width: max-content;
  }
}
.topbar h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.topbar h1::after {
  content: "";
  display: inline-block;
  margin-left: 10px;
  width: 14px;
  height: 14px;
  background:
    linear-gradient(var(--rubik-yellow), var(--rubik-yellow)) 0 0/50% 50% no-repeat,
    linear-gradient(var(--rubik-red), var(--rubik-red))    100% 0/50% 50% no-repeat,
    linear-gradient(var(--rubik-blue), var(--rubik-blue))   0 100%/50% 50% no-repeat,
    linear-gradient(var(--rubik-green), var(--rubik-green)) 100% 100%/50% 50% no-repeat;
  border-radius: 3px;
  vertical-align: middle;
}
.subtitle {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 14px;
}

/* ─── Main layout ─── */
.layout {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 24px;
  padding: 24px 32px;
  max-width: 1400px;
  margin: 0 auto;
}

.cube-pane {
  background: var(--bg-pane);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 540px;
}

#cube-canvas-container {
  flex: 1;
  min-height: 480px;
  border-radius: 10px;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #1d1d24 0%, #0c0c10 100%);
  position: relative;
}
#cube-canvas-container canvas { display: block; }

.cube-hint {
  margin: 10px 4px 0;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
}

/* ─── Text pane ─── */
.text-pane {
  background: var(--bg-pane);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 26px 20px;
  display: flex;
  flex-direction: column;
  max-height: 78vh;
  overflow: hidden;
}

.step-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.step-counter {
  display: inline-block;
  padding: 3px 10px;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 12px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#step-title {
  margin: 10px 0 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.step-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
}

.step-body p { margin: 0 0 10px; }
.step-body p:last-child { margin-bottom: 0; }
.step-body strong { color: #fff; }
.step-body .case {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: var(--bg-pane-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
}
.step-body .case-title {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.step-body .remark {
  margin-top: 14px;
  padding: 12px 14px;
  border: 2px solid var(--remark-red);
  border-radius: 10px;
  background: rgba(255, 95, 95, 0.05);
}
.step-body .remark-title {
  display: block;
  font-weight: 700;
  color: var(--remark-red);
  text-align: center;
  margin-bottom: 6px;
  font-style: italic;
  font-size: 15px;
}
.step-body .remark-body { font-size: 13px; }

.step-body::-webkit-scrollbar { width: 8px; }
.step-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ─── Formula block ─── */
.formula-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.formula-label {
  margin: 0 0 8px;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.moves-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.move-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 8px 5px;
  background: var(--bg-pane-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.18s ease;
  min-width: 62px;
}
.move-icon-svg {
  width: 44px;
  height: 44px;
  display: block;
}
.move-icon-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 2px;
  line-height: 1.1;
}
.move-icon-notation {
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.move-icon-label {
  font-size: 9.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1px;
}
.move-icon.current {
  background: rgba(255, 213, 0, 0.14);
  border-color: var(--accent);
  transform: scale(1.06);
  box-shadow: 0 0 18px rgba(255, 213, 0, 0.35);
}
.move-icon.current .move-icon-notation {
  color: var(--accent);
}
.move-icon.done {
  opacity: 0.42;
}
.moves-list:empty::after {
  content: "(aucun mouvement — pas de formule miracle, c'est à toi !)";
  color: var(--text-dim);
  font-style: italic;
  font-size: 13px;
}

/* ─── Controls ─── */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 32px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  background: #131318;
}
.ctrl-btn {
  background: var(--bg-pane-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 18px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ctrl-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.ctrl-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.ctrl-play {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  min-width: 130px;
}
.ctrl-play:hover:not(:disabled) {
  background: #fff066;
  color: #000;
}
.ctrl-reset {
  font-size: 13px;
  padding: 9px 14px;
}

/* ─── Speed slider ─── */
.speed-control {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  margin-left: auto;
  padding: 0 4px;
  min-width: 130px;
}
.speed-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  text-align: center;
}
.speed-label #speed-value {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
#speed-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--bg-pane-2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
#speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #000;
  transition: transform 0.1s ease;
}
#speed-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
#speed-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #000;
}

.timeline {
  display: flex;
  gap: 8px;
  padding: 0 8px;
}
.timeline-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-pane-2);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.timeline-dot:hover { border-color: var(--accent); }
.timeline-dot.active {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.15);
}
.timeline-dot.done {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
}
.timeline-dot::after {
  content: attr(data-step);
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-dim);
}

/* ─── Footer credit ─── */
.credit {
  padding: 18px 32px 28px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  border-top: 1px solid var(--border);
  background: #0a0a0d;
}
.credit p { margin: 4px 0; }
.credit-thanks {
  margin-top: 8px !important;
  color: var(--accent);
  font-weight: 600;
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .cube-pane { min-height: 420px; }
  #cube-canvas-container { min-height: 380px; }
  .text-pane { max-height: none; }
  .topbar h1 { font-size: 22px; }
  .controls { padding: 12px 16px; }
  .ctrl-reset { margin-left: 0; }
}
