/* Reset & Base Styles */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a25;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --success: #10b981;
  --warning: #f59e0b;
  --border-color: rgba(255, 255, 255, 0.1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Hero Section */
.hero-section {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: radial-gradient(
    ellipse at center,
    #1a1a2e 0%,
    var(--bg-primary) 70%
  );
  overflow: hidden;
}

.hero-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(
      circle at 20% 80%,
      rgba(99, 102, 241, 0.1) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(139, 92, 246, 0.1) 0%,
      transparent 50%
    );
  pointer-events: none;
}

.hero-content {
  text-align: center;
  z-index: 1;
}

.hero-title {
  font-size: clamp(3rem, 10vw, 6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.title-line {
  display: block;
}

.title-line.highlight {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-weight: 300;
}

#hero-cube-container {
  width: 400px;
  height: 400px;
  margin: 0 auto 2rem;
}

@media (max-width: 768px) {
  #hero-cube-container {
    width: 300px;
    height: 300px;
  }
}

.scroll-indicator {
  position: absolute;
  bottom: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  animation: float 2s ease-in-out infinite;
}

.scroll-arrow {
  width: 24px;
  height: 24px;
  border-right: 2px solid var(--text-secondary);
  border-bottom: 2px solid var(--text-secondary);
  transform: rotate(45deg);
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(10px);
  }
}

/* Playground Section */
.playground-section {
  min-height: 100vh;
  padding: 4rem 2rem;
  background: var(--bg-secondary);
}

.playground-header {
  text-align: center;
  margin-bottom: 3rem;
}

.playground-header h2 {
  font-size: 2.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.playground-header p {
  color: var(--text-secondary);
}

.playground-layout {
  display: flex;
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

.cube-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#cube-container {
  width: 600px;
  height: 600px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  position: relative;
  cursor: grab;
  overflow: visible;
}

#cube-container:active {
  cursor: grabbing;
}

.interaction-hints {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.hint svg {
  stroke: var(--accent-primary);
  flex-shrink: 0;
}

@media (max-width: 1200px) {
  #cube-container {
    width: 500px;
    height: 500px;
  }
}

@media (max-width: 768px) {
  #cube-container {
    width: 100%;
    max-width: 400px;
    height: 400px;
  }

  .cube-wrapper {
    width: 100%;
    max-width: 400px;
  }

  .interaction-hints {
    flex-direction: column;
    align-items: center;
  }
}

/* Controls Panel */
.controls-panel {
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 320px;
  box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
  .controls-panel {
    width: 100%;
    max-width: 400px;
  }
}

.control-group {
  margin-bottom: 1.5rem;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-group h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

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

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-accent {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.btn-accent:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
}

.button-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.button-row .btn {
  flex: 1;
  min-width: 90px;
}

/* Face Controls */
.face-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.face-btn-group {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.face-label {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  background: var(--face-color);
  color: #000;
}

.face-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.face-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.face-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

/* Speed Control */
.speed-control {
  padding: 0.5rem 0;
}

#speed-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-secondary);
  appearance: none;
  cursor: pointer;
}

#speed-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-gradient);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.speed-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

/* Stats */
.stats .stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.stats .stat-row:last-child {
  border-bottom: none;
}

.stats .stat-row span:last-child {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Move History */
.move-history {
  max-width: 1400px;
  margin: 2rem auto 0;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
}

.move-history h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

#history-display {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 32px;
}

.move-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.5rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: "Monaco", "Consolas", monospace;
  animation: popIn 200ms ease;
}

@keyframes popIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  position: relative;
  transform: translateY(20px);
  transition: transform var(--transition-normal);
}

.modal.active .modal-content {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.modal-content h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

.instructions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

@media (max-width: 480px) {
  .instructions-grid {
    grid-template-columns: 1fr;
  }
}

.instruction-item {
  text-align: center;
}

.instruction-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 0.75rem;
  background: var(--bg-tertiary);
  border-radius: 50%;
  color: var(--accent-primary);
}

.instruction-icon svg {
  stroke: var(--accent-primary);
}

.instruction-item h4 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.instruction-item p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Help Button */
.help-button {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: white;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-fast);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.help-button:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}

/* Solved Animation */
.solved-celebration {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 3rem;
  text-align: center;
  z-index: 1001;
  animation: celebrateIn 500ms ease;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}

@keyframes celebrateIn {
  from {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }
  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.solved-celebration .celebration-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  background: var(--accent-gradient);
  border-radius: 50%;
  color: white;
}

.solved-celebration .celebration-icon svg {
  stroke: white;
}

.solved-celebration h2 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.solved-celebration p {
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.solved-celebration .time-display {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.solved-celebration .btn {
  min-width: 120px;
}

/* Loading State */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: opacity var(--transition-slow);
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Confetti Container */
#confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  to {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Added UI styles */
.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.theme-dropdown {
  width: 100%;
  padding: 0.5rem;
  border-radius: 8px;
  background: var(--bg-alt);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 0.5rem;
}

.preview-pip {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  width: 270px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.preview-pip.hidden {
  display: none !important;
}

.pip-header {
  background: rgba(255,255,255,0.05);
  padding: 0.6rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.pip-header button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  transition: color var(--transition-fast);
}

.pip-header button:hover {
  color: var(--text-primary);
}

.pip-body {
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#preview-input {
  width: 100%;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.3);
  color: white;
  font-family: monospace;
  font-size: 0.8rem;
  outline: none;
}

#preview-input:focus {
  border-color: var(--accent-primary);
}

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

.preview-pad-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 550;
  padding: 5px 0;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preview-pad-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.15);
}

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

.preview-actions {
  display: flex;
  gap: 6px;
}

.preview-actions button {
  flex: 1;
  padding: 0.4rem 0.5rem;
}

#preview-canvas-container {
  width: 100%;
  height: 160px;
  background: #040406;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.05);
}

/* Ghost Mode PIP */
.ghost-pip {
  position: fixed;
  bottom: 2rem;
  left: 20rem;
  width: 270px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  border: 1px solid rgba(139, 92, 246, 0.35);
  box-shadow: 0 10px 30px rgba(139, 92, 246, 0.2);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(10px);
  transition: all var(--transition-normal);
}

.ghost-pip.hidden {
  display: none !important;
}

.ghost-hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 8px;
  padding: 6px;
  text-align: center;
}

.ghost-hud .hud-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ghost-hud .hud-item.flex-col {
  flex-direction: column;
}

.ghost-hud .hud-item span:first-child {
  color: var(--text-secondary);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.ghost-hud .hud-item span:last-child {
  font-weight: 700;
  font-size: 0.8rem;
  color: #a78bfa;
}

#ghost-canvas-container {
  width: 100%;
  height: 160px;
  background: #040406;
  border-radius: 6px;
  border: 1px solid rgba(139, 92, 246, 0.1);
}

.face-hint-highlight {
  animation: pulse-hint 1s infinite alternate;
}

@keyframes pulse-hint {
  from { opacity: 0.5; }
  to { opacity: 1; filter: brightness(1.5); }
}
