/* style.css — all styling */
:root {
  --bg-0: #070912;
  --bg-1: #0d1120;
  --bg-2: #141a30;
  --fg: #eef1f8;
  --muted: #8892ad;
  --accent: #6ea8ff;
  --accent-2: #b07cff;
  --danger: #ff6b6b;
  --success: #4dd97a;
  --card: rgba(20, 26, 48, 0.55);
  --card-border: rgba(120, 140, 200, 0.18);
  --btn-bg: rgba(30, 38, 66, 0.7);
  --btn-border: rgba(140, 160, 210, 0.25);
  --glow: rgba(110, 168, 255, 0.22);
  --floor: rgba(110, 168, 255, 0.08);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-0: #eef2fb;
    --bg-1: #e3e9f6;
    --bg-2: #d7e0f2;
    --fg: #1a2138;
    --muted: #5b6786;
    --accent: #3a6fd8;
    --accent-2: #8a4fd0;
    --danger: #e0524a;
    --success: #2fae5d;
    --card: rgba(255, 255, 255, 0.7);
    --card-border: rgba(60, 80, 130, 0.18);
    --btn-bg: rgba(255, 255, 255, 0.85);
    --btn-border: rgba(60, 80, 130, 0.22);
    --glow: rgba(58, 111, 216, 0.18);
    --floor: rgba(58, 111, 216, 0.10);
    color-scheme: light;
  }
}

html[data-theme="dark"] {
  --bg-0: #070912;
  --bg-1: #0d1120;
  --bg-2: #141a30;
  --fg: #eef1f8;
  --muted: #8892ad;
  --accent: #6ea8ff;
  --accent-2: #b07cff;
  --danger: #ff6b6b;
  --success: #4dd97a;
  --card: rgba(20, 26, 48, 0.55);
  --card-border: rgba(120, 140, 200, 0.18);
  --btn-bg: rgba(30, 38, 66, 0.7);
  --btn-border: rgba(140, 160, 210, 0.25);
  --glow: rgba(110, 168, 255, 0.22);
  --floor: rgba(110, 168, 255, 0.08);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg-0: #eef2fb;
  --bg-1: #e3e9f6;
  --bg-2: #d7e0f2;
  --fg: #1a2138;
  --muted: #5b6786;
  --accent: #3a6fd8;
  --accent-2: #8a4fd0;
  --danger: #e0524a;
  --success: #2fae5d;
  --card: rgba(255, 255, 255, 0.7);
  --card-border: rgba(60, 80, 130, 0.18);
  --btn-bg: rgba(255, 255, 255, 0.85);
  --btn-border: rgba(60, 80, 130, 0.22);
  --glow: rgba(58, 111, 216, 0.18);
  --floor: rgba(58, 111, 216, 0.10);
  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  overflow: hidden;
  touch-action: manipulation;
  background:
    radial-gradient(1200px 800px at 20% 0%, var(--bg-2) 0%, transparent 55%),
    radial-gradient(900px 700px at 90% 100%, var(--bg-1) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 8px;
  padding: 14px 16px 18px;
  max-width: 720px;
  margin: 0 auto;
}

/* ---------- Header ---------- */
header {
  text-align: center;
  padding-top: 4px;
}
h1 {
  margin: 0;
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* ---------- Stage ---------- */
.stage {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 30%, rgba(255,255,255,0.04), transparent 60%),
    linear-gradient(180deg, rgba(20,26,48,0.35), rgba(7,9,18,0.55));
  border: 1px solid var(--card-border);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 18px 40px rgba(0,0,0,0.35);
  touch-action: none;
  cursor: grab;
  min-height: 0;
}
.stage.grabbing { cursor: grabbing; }

.glow {
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 60%;
  background: radial-gradient(50% 60% at 50% 40%, var(--glow), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
}

.floor {
  position: absolute;
  left: 50%;
  bottom: 14%;
  width: 240px;
  height: 60px;
  transform: translateX(-50%);
  background: radial-gradient(50% 50% at 50% 50%, var(--floor), transparent 70%);
  filter: blur(8px);
  pointer-events: none;
}

#cube-container {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1100px;
  perspective-origin: 50% 45%;
}

#cube {
  position: relative;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

/* ---------- Cubies ---------- */
.cubie {
  position: absolute;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.face {
  position: absolute;
  width: 56px;
  height: 56px;
  left: -28px;
  top: -28px;
  border-radius: 9px;
  border: 2px solid #0a0c14;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.12),
    inset 0 3px 6px rgba(255,255,255,0.18),
    inset 0 -4px 8px rgba(0,0,0,0.25);
  backface-visibility: hidden;
}

.face-inner {
  background: #0a0c14 !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn {
  flex: 1;
  max-width: 200px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease, opacity 0.18s ease;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}
.btn:active {
  transform: translateY(0);
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-scramble {
  background: linear-gradient(135deg, rgba(110,168,255,0.25), rgba(176,124,255,0.25));
  border-color: rgba(110,168,255,0.4);
}
.btn-scramble:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(110,168,255,0.4), rgba(176,124,255,0.4));
}

.btn-solve {
  background: linear-gradient(135deg, rgba(77,217,122,0.2), rgba(110,168,255,0.2));
  border-color: rgba(77,217,122,0.4);
}
.btn-solve:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(77,217,122,0.35), rgba(110,168,255,0.35));
}

/* ---------- Status ---------- */
.status {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 0 2px;
}
.status::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  margin-right: 8px;
  vertical-align: middle;
  box-shadow: 0 0 8px var(--success);
}

@media (max-width: 380px) {
  .app { padding: 10px 10px 14px; }
  .btn { padding: 11px 12px; font-size: 14px; }
  .sub { font-size: 11.5px; }
}
