:root {
  --bg: #070a12;
  --bg2: #101827;
  --panel: rgba(15, 23, 42, 0.78);
  --panel2: rgba(30, 41, 59, 0.64);
  --line: rgba(148, 163, 184, 0.26);
  --line2: rgba(255, 255, 255, 0.14);
  --text: #f8fafc;
  --soft: #dbeafe;
  --muted: #94a3b8;
  --accent: #f2cc83;
  --accent2: #7dd3fc;
  --green: #86efac;
  --shadow: 0 34px 90px rgba(0, 0, 0, 0.48);
  --radius: 30px;

  --nav-panel-bg:
    linear-gradient(180deg, rgba(15, 23, 42, 0.88), rgba(15, 23, 42, 0.58)),
    radial-gradient(circle at 18% 0%, rgba(242, 204, 131, 0.15), transparent 44%);
  --nav-card-bg:
    linear-gradient(180deg, rgba(30, 41, 59, 0.66), rgba(15, 23, 42, 0.46));
  --nav-card-inner: rgba(2, 6, 23, 0.30);
  --nav-text: #f8fafc;
  --nav-soft: #dbeafe;
  --nav-muted: #94a3b8;
  --nav-border: rgba(148, 163, 184, 0.23);
}

body.nav-light {
  --nav-panel-bg:
    linear-gradient(180deg, rgba(255, 247, 231, 0.96), rgba(250, 239, 220, 0.90)),
    radial-gradient(circle at 18% 0%, rgba(242, 204, 131, 0.34), transparent 44%);
  --nav-card-bg:
    linear-gradient(180deg, rgba(255, 251, 235, 0.96), rgba(255, 247, 231, 0.82));
  --nav-card-inner: rgba(255, 255, 255, 0.72);
  --nav-text: #172033;
  --nav-soft: #26364f;
  --nav-muted: #64748b;
  --nav-border: rgba(120, 113, 108, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(125, 211, 252, 0.18), transparent 30%),
    radial-gradient(circle at 82% 15%, rgba(242, 204, 131, 0.16), transparent 34%),
    radial-gradient(circle at 50% 100%, rgba(134, 239, 172, 0.10), transparent 34%),
    linear-gradient(145deg, #05070c 0%, #101827 52%, #111827 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.034) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.034) 1px, transparent 1px);
  background-size: 46px 46px;
  opacity: 0.26;
  mask-image: radial-gradient(circle at center, black 0%, transparent 74%);
}

button,
input,
select {
  font: inherit;
}

button {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 11px 15px;
  color: #09111f;
  background: linear-gradient(135deg, #f2cc83, #fff0ba);
  font-weight: 900;
  letter-spacing: -0.02em;
  box-shadow:
    0 14px 34px rgba(242, 204, 131, 0.23),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
  transition:
    transform 0.18s ease,
    filter 0.18s ease,
    box-shadow 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow:
    0 18px 46px rgba(242, 204, 131, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

button:active {
  transform: translateY(0) scale(0.98);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

button.secondary {
  color: var(--text);
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 14px 34px rgba(0, 0, 0, 0.18);
}

body.nav-light .sidePanel button.secondary {
  color: #172033;
  background: rgba(255, 255, 255, 0.76);
  border-color: rgba(120, 113, 108, 0.26);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 10px 28px rgba(120, 113, 108, 0.14);
}

code {
  color: #fde68a;
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 0.88em;
}

body.nav-light .sidePanel code {
  color: #8a5c00;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(380px, 540px) minmax(0, 1fr);
  gap: 22px;
}

.sidePanel,
.stagePanel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.sidePanel {
  height: calc(100vh - 48px);
  overflow: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: var(--nav-text);
  background: var(--nav-panel-bg);
  scrollbar-width: thin;
  scrollbar-color: rgba(242, 204, 131, 0.6) rgba(15, 23, 42, 0.3);
  transition:
    background 0.25s ease,
    color 0.25s ease,
    border-color 0.25s ease;
}

body.nav-light .sidePanel {
  border-color: rgba(120, 113, 108, 0.24);
}

.stagePanel {
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.15), transparent 24%),
    radial-gradient(circle at 50% 58%, rgba(125, 211, 252, 0.13), transparent 38%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.62), rgba(2, 6, 23, 0.74));
}

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

.brandMain {
  display: flex;
  align-items: center;
  gap: 15px;
}

.brandIcon {
  width: 62px;
  height: 62px;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
  background:
    conic-gradient(
      from 45deg,
      #ef4444,
      #fb923c,
      #facc15,
      #22c55e,
      #2563eb,
      #f8fafc,
      #ef4444
    );
  box-shadow:
    0 0 38px rgba(242, 204, 131, 0.28),
    inset 0 0 0 3px rgba(255, 255, 255, 0.25);
}

.brandIcon::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 15px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.76), transparent 32%),
    rgba(0, 0, 0, 0.25);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.32),
    0 10px 24px rgba(0, 0, 0, 0.18);
}

.brandIcon span {
  position: absolute;
  inset: 20px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.55);
  z-index: 2;
}

.themeToggleBtn {
  align-self: flex-start;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 900;
}

.eyebrow.small {
  margin-bottom: 4px;
  font-size: 0.68rem;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.055em;
}

h1 {
  color: var(--nav-text);
  font-size: clamp(2.05rem, 4vw, 3.35rem);
  line-height: 0.95;
}

.stagePanel h2,
.stagePanel h3 {
  color: var(--text);
}

h2 {
  font-size: 1.18rem;
}

h3 {
  font-size: 1.15rem;
}

.panel {
  border: 1px solid var(--nav-border);
  border-radius: 23px;
  padding: 16px;
  background: var(--nav-card-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition:
    background 0.25s ease,
    border-color 0.25s ease;
}

.compactPanel {
  padding: 13px 15px;
}

.intro p,
.hint,
.techNote {
  margin: 0;
  color: var(--nav-muted);
  line-height: 1.52;
  font-size: 0.9rem;
}

.hint {
  margin-top: 12px;
}

.miniNote {
  margin: 0;
  color: var(--muted);
  line-height: 1.52;
  font-size: 0.9rem;
}

.intro p {
  color: var(--nav-soft);
  font-size: 1rem;
}

.intro strong {
  color: var(--accent);
}

.panelHead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 10px;
  color: #dcfce7;
  background: rgba(22, 101, 52, 0.26);
  border: 1px solid rgba(134, 239, 172, 0.35);
  font-size: 0.75rem;
  font-weight: 900;
  white-space: nowrap;
}

.statusPill.is-mixed {
  color: #fef3c7;
  background: rgba(146, 64, 14, 0.38);
  border-color: rgba(251, 191, 36, 0.42);
}

.statusPill.is-solving {
  color: #e0f2fe;
  background: rgba(3, 105, 161, 0.34);
  border-color: rgba(125, 211, 252, 0.42);
}

.statusPill.is-solved {
  color: #dcfce7;
  background: rgba(22, 101, 52, 0.30);
  border-color: rgba(134, 239, 172, 0.42);
}

body.nav-light .sidePanel .pill {
  color: #14532d;
  background: rgba(187, 247, 208, 0.62);
  border-color: rgba(34, 197, 94, 0.28);
}

.steps {
  display: grid;
  gap: 10px;
}

.lessonControls {
  margin-top: 12px;
}

.step {
  width: 100%;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  text-align: left;
  align-items: start;
  padding: 12px;
  border-radius: 18px;
  color: var(--nav-text);
  background: var(--nav-card-inner);
  border: 1px solid rgba(148, 163, 184, 0.20);
  box-shadow: none;
}

body.nav-light .sidePanel .step {
  border-color: rgba(120, 113, 108, 0.20);
}

.step:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.2);
}

body.nav-light .sidePanel .step:hover {
  box-shadow: 0 14px 34px rgba(120, 113, 108, 0.16);
}

.step.active {
  border-color: rgba(242, 204, 131, 0.58);
  background:
    radial-gradient(circle at 0% 0%, rgba(242, 204, 131, 0.20), transparent 52%),
    var(--nav-card-inner);
}

.stepNo {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #101827;
  background: linear-gradient(135deg, var(--accent), #fde68a);
  font-weight: 950;
  box-shadow: 0 10px 26px rgba(242, 204, 131, 0.26);
}

.step strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.94rem;
}

.step small {
  display: block;
  color: var(--nav-muted);
  line-height: 1.38;
  font-size: 0.82rem;
}

.moveGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 12px;
}

.moveGridFull button {
  font-size: 0.95rem;
  padding: 10px 8px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.field span {
  color: var(--nav-soft);
  font-size: 0.86rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.30);
  border-radius: 16px;
  padding: 13px 14px;
  color: var(--nav-text);
  background: rgba(2, 6, 23, 0.48);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

select {
  cursor: pointer;
}

body.nav-light .sidePanel input,
body.nav-light .sidePanel select {
  color: #172033;
  background: rgba(255, 255, 255, 0.76);
  border-color: rgba(120, 113, 108, 0.24);
}

input:focus,
select:focus {
  border-color: rgba(242, 204, 131, 0.70);
  box-shadow:
    0 0 0 4px rgba(242, 204, 131, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.speedControl {
  border: 1px solid var(--nav-border);
  border-radius: 18px;
  padding: 13px;
  margin-bottom: 14px;
  background: var(--nav-card-inner);
}

.speedHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.speedHead span {
  color: var(--nav-soft);
  font-size: 0.86rem;
  font-weight: 900;
}

.speedHead strong {
  color: var(--nav-text);
  font-size: 0.86rem;
  white-space: nowrap;
}

.speedRange {
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  accent-color: #f2cc83;
  cursor: pointer;
}

.speedRange:focus {
  box-shadow: none;
}

.speedScale {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  color: var(--nav-muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.solveKpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 12px;
}

.solveKpis div {
  border: 1px solid var(--nav-border);
  border-radius: 16px;
  padding: 11px;
  background: var(--nav-card-inner);
}

.solveKpis span {
  display: block;
  margin-bottom: 4px;
  color: var(--nav-muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.solveKpis strong {
  display: block;
  color: var(--nav-text);
  font-size: 1.1rem;
}

.sequenceBox {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.sequenceBox span {
  color: var(--nav-soft);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sequenceBox output {
  display: block;
  min-height: 42px;
  max-height: 110px;
  overflow: auto;
  border: 1px solid var(--nav-border);
  border-radius: 16px;
  padding: 10px;
  color: var(--nav-text);
  background: var(--nav-card-inner);
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    monospace;
  font-size: 0.84rem;
  line-height: 1.5;
}

.stagePanel {
  height: calc(100vh - 48px);
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.stageTop {
  position: relative;
  z-index: 5;
  padding: 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.statusCluster {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.statusCluster .brand {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 999px;
  color: #f8fafc;
  text-decoration: none;
  background: rgba(2, 6, 23, 0.42);
  border: 1px solid rgba(148, 163, 184, 0.26);
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease;
}

.statusCluster .brand:hover {
  transform: translateY(-1px);
  border-color: rgba(242, 204, 131, 0.55);
  background: rgba(15, 23, 42, 0.68);
}

.statusCluster .brand img {
  width: 26px;
  height: 26px;
  display: block;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  object-fit: cover;
  flex: 0 0 auto;
}

.statusCluster .bt {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}

.statusCluster .bt strong {
  font-weight: 900;
  font-size: 0.92rem;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.statusCluster .bt span {
  color: #94a3b8;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.statusBadge {
  border: 1px solid rgba(134, 239, 172, 0.35);
  color: #dcfce7;
  background: rgba(22, 101, 52, 0.26);
  border-radius: 999px;
  padding: 9px 11px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.viewerWrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}

#cubeCanvas {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  cursor: grab;
  touch-action: none;
}

#cubeCanvas.dragging {
  cursor: grabbing;
}

.fallbackMessage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(520px, calc(100% - 32px));
  transform: translate(-50%, -50%);
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: 22px;
  padding: 18px;
  color: #fee2e2;
  background: rgba(127, 29, 29, 0.42);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
  z-index: 10;
}

.fallbackMessage strong {
  display: block;
  margin-bottom: 6px;
}

.fallbackMessage span {
  display: block;
  color: #fecaca;
  line-height: 1.45;
}

.viewerOverlay {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  pointer-events: none;
}

.glassCard,
.moveCard {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(2, 6, 23, 0.48);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.24);
}

.glassCard {
  max-width: 590px;
  border-radius: 22px;
  padding: 15px 17px;
}

.glassCard p:last-child {
  margin: 6px 0 0;
  color: #cbd5e1;
  line-height: 1.46;
  font-size: 0.92rem;
}

.moveCard {
  min-width: 132px;
  border-radius: 20px;
  padding: 15px 17px;
  text-align: center;
}

.moveCard span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.moveCard strong {
  display: block;
  color: var(--accent);
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.04em;
}

.stageBottom {
  position: relative;
  z-index: 5;
  padding: 0 22px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #dbeafe;
  border-radius: 999px;
  padding: 8px 10px;
  background: rgba(2, 6, 23, 0.40);
  border: 1px solid rgba(148, 163, 184, 0.22);
  font-size: 0.82rem;
  font-weight: 800;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.50);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.62),
    0 0 13px rgba(255, 255, 255, 0.12);
}

.dot.white { background: #ffffff; }
.dot.yellow { background: #facc15; }
.dot.red { background: #ef233c; }
.dot.orange { background: #ff7a18; }
.dot.blue { background: #2563eb; }
.dot.green { background: #16a34a; }

@media (max-width: 1120px) {
  body {
    overflow: auto;
  }

  .app {
    grid-template-columns: 1fr;
  }

  .sidePanel,
  .stagePanel {
    height: auto;
  }

  .stagePanel {
    min-height: 760px;
  }

  .viewerWrap {
    min-height: 560px;
  }

  .viewerOverlay {
    display: none;
  }
}

@media (max-width: 1366px) {
  .viewerOverlay {
    display: none;
  }
}

@media (max-width: 720px) {
  .app {
    padding: 12px;
    gap: 14px;
  }

  .sidePanel,
  .stagePanel {
    border-radius: 23px;
  }

  .sidePanel {
    padding: 18px;
  }

  .stageTop,
  .stageBottom {
    padding: 16px;
  }

  .stageTop,
  .stageBottom,
  .viewerOverlay {
    flex-direction: column;
    align-items: stretch;
  }

  .viewerOverlay {
    left: 14px;
    right: 14px;
    bottom: 14px;
  }

  .viewerWrap {
    min-height: 500px;
  }

  .moveGrid {
    grid-template-columns: repeat(3, 1fr);
  }

  .moveCard {
    width: max-content;
  }

  .solveKpis {
    grid-template-columns: 1fr;
  }

  .speedHead {
    align-items: flex-start;
    flex-direction: column;
  }
}