:root {
  --primary: #4CAF50;
  --secondary: #2196F3;
  --accent: #fff;
  --text-dark: #2c3e50;
  --shadow: 0 4px 12px rgba(44,62,80,0.15);
  --gradient-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --glass-bg: rgba(255,255,255,0.1);
  --glass-border: rgba(255,255,255,0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--gradient-bg);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: var(--accent);
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 300;
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
  text-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.hint {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  opacity: 0.8;
  margin-bottom: 1rem;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.stats {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 0.8rem 1.5rem;
  display: inline-flex;
  gap: 2rem;
  font-weight: 500;
  box-shadow: var(--shadow);
}

.stats span {
  font-size: 1.1rem;
}

main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.cube-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: clamp(0.5rem, 1.5vw, 1rem);
  width: 100%;
  max-width: 1200px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(15px);
  backdrop-filter: blur(15px);
  border: 1px solid var(--glass-border);
  border-radius: 25px;
  padding: clamp(1rem, 3vw, 2rem);
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.cube {
  width: 100%;
  aspect-ratio: 1;
  perspective: 600px;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  touch-action: manipulation;
  border-radius: 12px;
  transition: transform 0.2s;
}

.cube:hover {
  transform: scale(1.05);
}

.cube:focus {
  outline: 3px solid rgba(255,255,255,0.7);
  outline-offset: 3px;
}

.cube-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.7s cubic-bezier(.68,-0.55,.27,1.55);
  transform-style: preserve-3d;
}

.cube.flipped .cube-inner {
  transform: rotateY(180deg);
}

.cube.solved {
  animation: celebrate 0.6s ease-out;
}

@keyframes celebrate {
  0% { transform: scale(1); }
  25% { transform: scale(1.1) rotate(3deg); }
  50% { transform: scale(1.15) rotate(-3deg); }
  75% { transform: scale(1.1) rotate(2deg); }
  100% { transform: scale(1); }
}

.cube-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.9rem, 2.5vw, 1.4rem);
  font-weight: 600;
  backface-visibility: hidden;
  transition: all 0.3s;
  text-align: center;
  line-height: 1.2;
}

.front {
  background: linear-gradient(135deg, var(--primary) 0%, #43e97b 100%);
  color: var(--accent);
  transform: translateZ(1px);
}

.back {
  background: linear-gradient(135deg, var(--secondary) 0%, #6dd5ed 100%);
  color: var(--accent);
  transform: rotateY(180deg) translateZ(1px);
}

footer {
  text-align: center;
}

.reset-btn {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  color: var(--accent);
  border: none;
  border-radius: 15px;
  padding: 0.8rem 2rem;
  font-size: 1.1rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(231, 76, 60, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.reset-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.reset-btn:hover::before {
  left: 100%;
}

.reset-btn:hover, .reset-btn:focus {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 25px rgba(231, 76, 60, 0.4);
  outline: none;
}

.reset-btn:active {
  transform: translateY(-1px) scale(1.02);
}

/* Responsive Design */
@media (max-width: 900px) {
  .cube-grid {
    grid-template-columns: repeat(5, 1fr);
    max-width: 95vw;
  }
  
  .stats {
    flex-direction: column;
    gap: 0.5rem;
  }
}

@media (max-width: 500px) {
  body {
    padding: 0.5rem;
  }
  
  .cube-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
    padding: 1rem;
  }
  
  .cube-face {
    font-size: 0.8rem;
  }
  
  h1 {
    font-size: 1.5rem;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --gradient-bg: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .cube-face {
    border: 2px solid var(--accent);
  }
  
  .reset-btn {
    border: 2px solid var(--accent);
  }
}

/* Animation für gelöste Aufgaben */
.cube.just-solved {
  animation: success-glow 1s ease-out;
}

@keyframes success-glow {
  0% { 
    box-shadow: 0 0 0 rgba(76, 175, 80, 0.7);
  }
  50% { 
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.7);
  }
  100% { 
    box-shadow: 0 0 0 rgba(76, 175, 80, 0);
  }
}
