:root {
  color-scheme: dark;
  --ink: #f7f7ff;
  --muted: #a9add1;
  --panel: rgba(17, 19, 48, 0.66);
  --panel-border: rgba(255, 255, 255, 0.11);
  --rx: -24deg;
  --ry: 38deg;
  --move-ms: 260ms;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 14%, rgba(75, 66, 221, 0.34), transparent 34rem),
    radial-gradient(circle at 84% 86%, rgba(255, 61, 129, 0.18), transparent 31rem),
    linear-gradient(145deg, #080918 0%, #11142d 48%, #090b1c 100%);
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.aurora {
  position: fixed;
  width: 34rem;
  height: 34rem;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.22;
  pointer-events: none;
  animation: drift 14s ease-in-out infinite alternate;
}

.aurora-one { left: -14rem; bottom: -12rem; background: #1ad7a1; }
.aurora-two { right: -15rem; top: -12rem; background: #6f48ff; animation-delay: -7s; }

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 68px 0;
  display: grid;
  grid-template-columns: minmax(330px, 0.86fr) minmax(480px, 1.14fr);
  align-items: center;
  gap: clamp(42px, 7vw, 96px);
}

.hero-copy { max-width: 540px; }

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 35px;
  height: 35px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 4px;
  border-radius: 9px;
  transform: rotate(-8deg);
  background: #0b0c1c;
  box-shadow: 0 10px 25px rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,255,255,.1);
}
.brand-mark span { border-radius: 2px; }
.brand-mark span:nth-child(1), .brand-mark span:nth-child(5), .brand-mark span:nth-child(9) { background:#ffce3a; }
.brand-mark span:nth-child(2), .brand-mark span:nth-child(6) { background:#ff3f5f; }
.brand-mark span:nth-child(3), .brand-mark span:nth-child(7) { background:#25d97b; }
.brand-mark span:nth-child(4), .brand-mark span:nth-child(8) { background:#4a7dff; }

.eyebrow {
  color: #c6c8e8;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(3.3rem, 6vw, 6.35rem);
  line-height: 0.92;
  letter-spacing: -0.072em;
  font-weight: 880;
}

h1 span {
  display: inline-block;
  color: transparent;
  background: linear-gradient(90deg, #7b63ff 0%, #43c8ff 38%, #39e09b 72%, #ffcb45 100%);
  background-clip: text;
  -webkit-background-clip: text;
}

.intro {
  max-width: 505px;
  margin: 28px 0 31px;
  color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.17rem);
  line-height: 1.72;
}

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

.button {
  position: relative;
  min-width: 154px;
  border: 0;
  border-radius: 16px;
  padding: 15px 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: white;
  font-weight: 820;
  letter-spacing: .01em;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease, background .18s ease;
}

.button:hover:not(:disabled) { transform: translateY(-2px); }
.button:active:not(:disabled) { transform: translateY(1px) scale(.985); }
.button:focus-visible { outline: 3px solid rgba(101, 193, 255, .75); outline-offset: 3px; }
.button:disabled { cursor: not-allowed; opacity: .43; }
.button-icon { font-size: 1.2rem; line-height: 1; }

.button-primary {
  background: linear-gradient(135deg, #7155ff, #9a48f5);
  box-shadow: 0 14px 30px rgba(104, 73, 255, .32), inset 0 1px 0 rgba(255,255,255,.22);
}
.button-primary:hover:not(:disabled) { box-shadow: 0 18px 38px rgba(104, 73, 255, .42), inset 0 1px 0 rgba(255,255,255,.25); }

.button-secondary {
  background: rgba(255,255,255,.075);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14), 0 12px 26px rgba(0,0,0,.2);
  backdrop-filter: blur(12px);
}

.button.busy .button-icon { animation: spin .6s linear infinite; }

.status-card {
  position: relative;
  margin-top: 24px;
  padding: 18px 19px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 15px 18px;
  overflow: hidden;
  background: rgba(255,255,255,.045);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 38px rgba(0,0,0,.18);
}

.status-label {
  display: block;
  margin-bottom: 5px;
  color: #7f85ae;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.status-card strong { font-size: .98rem; }

.move-pill {
  min-width: 112px;
  padding: 7px 12px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  background: rgba(5,7,22,.38);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.07);
}
.move-pill span { color: #76eebc; font-weight: 900; }
.move-pill small { margin-top: 2px; color: #858aad; }

.progress-track {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,.07);
}
.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6a58ff, #2dd9ac, #ffd050);
  transition: width .18s ease;
}

.legend {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 17px;
  color: #7f84a8;
  font-size: .7rem;
  font-weight: 730;
  letter-spacing: .045em;
  text-transform: uppercase;
}
.legend span::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 7px;
  display: inline-block;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: 0 0 12px color-mix(in srgb, var(--dot) 65%, transparent);
}

.cube-panel {
  position: relative;
  min-height: 620px;
  border: 1px solid var(--panel-border);
  border-radius: 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(255,255,255,.085), rgba(255,255,255,.018)),
    rgba(14, 16, 42, .58);
  box-shadow: 0 38px 90px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.12);
  backdrop-filter: blur(26px);
}

.cube-panel::before {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 27px;
  border: 1px solid rgba(255,255,255,.045);
  pointer-events: none;
}

.panel-glow {
  position: absolute;
  width: 330px;
  height: 330px;
  border-radius: 50%;
  background: #5a4aff;
  opacity: .18;
  filter: blur(70px);
  animation: breathe 5s ease-in-out infinite alternate;
}

.scene {
  position: relative;
  width: min(430px, 92vw);
  height: 430px;
  perspective: 1100px;
  perspective-origin: 50% 44%;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.scene:active { cursor: grabbing; }

.cube {
  position: absolute;
  left: 50%;
  top: 47%;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform .15s ease-out;
}
.cube.dragging { transition: none; }

.layer-pivot {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.cubie {
  position: absolute;
  left: 0;
  top: 0;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  transform-style: preserve-3d;
  will-change: transform;
}

.face {
  position: absolute;
  inset: 0;
  border: 4px solid #101119;
  border-radius: 9px;
  overflow: hidden;
  background: #181923;
  backface-visibility: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.035);
}

.face.sticker { background: var(--sticker); }
.face.sticker::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 4px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.42) 0%, rgba(255,255,255,.07) 33%, rgba(0,0,0,.15) 76%, rgba(0,0,0,.3) 100%);
  mix-blend-mode: soft-light;
}
.face.sticker::after {
  content: "";
  position: absolute;
  inset: 5px 7px auto;
  height: 12px;
  border-radius: 50%;
  background: rgba(255,255,255,.21);
  filter: blur(4px);
}

.face.pz { transform: translateZ(29px); }
.face.nz { transform: rotateY(180deg) translateZ(29px); }
.face.px { transform: rotateY(90deg) translateZ(29px); }
.face.nx { transform: rotateY(-90deg) translateZ(29px); }
.face.ny { transform: rotateX(90deg) translateZ(29px); }
.face.py { transform: rotateX(-90deg) translateZ(29px); }

.floor-shadow {
  position: absolute;
  left: 50%;
  top: 72%;
  width: 242px;
  height: 77px;
  border-radius: 50%;
  transform: translateX(-50%) rotateX(72deg);
  background: rgba(0,0,0,.48);
  filter: blur(21px);
  opacity: .72;
}

.drag-hint {
  position: absolute;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%);
  width: max-content;
  color: #7f84a8;
  font-size: .73rem;
  font-weight: 700;
  letter-spacing: .04em;
}
.drag-hint span { color: #9f91ff; font-size: 1rem; margin-right: 6px; }

.algorithm-strip {
  position: absolute;
  left: 30px;
  right: 30px;
  bottom: 22px;
  padding-top: 15px;
  border-top: 1px solid rgba(255,255,255,.075);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: #767c9e;
  font-size: .71rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.algorithm-strip code {
  max-width: 70%;
  overflow: hidden;
  color: #cdd1f3;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: .74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
}

@keyframes drift { to { transform: translate(55px, -28px) scale(1.08); } }
@keyframes breathe { to { transform: scale(1.17); opacity: .26; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(680px, calc(100% - 28px));
    padding: 44px 0 58px;
    gap: 38px;
  }
  .hero-copy { max-width: none; }
  .cube-panel { min-height: 580px; }
}

@media (max-width: 520px) {
  .app-shell { width: min(100% - 20px, 500px); padding-top: 28px; }
  h1 { font-size: clamp(3.15rem, 16vw, 4.7rem); }
  .intro { margin-top: 22px; }
  .controls { display: grid; grid-template-columns: 1fr 1fr; }
  .button { min-width: 0; padding-inline: 14px; }
  .status-card { grid-template-columns: 1fr; }
  .move-pill { align-items: flex-start; }
  .cube-panel { min-height: 520px; border-radius: 28px; }
  .scene { height: 370px; transform: scale(.88); }
  .drag-hint { bottom: 70px; }
  .algorithm-strip { left: 20px; right: 20px; }
  .algorithm-strip span { display: none; }
  .algorithm-strip code { max-width: 100%; margin: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .aurora, .panel-glow { animation: none; }
  .button, .cube, .progress-track span { transition-duration: .01ms !important; }
}
