@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Space+Grotesk:wght@300;400;500;600;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #9d4edd;
  --secondary: #ff6b9d;
  --accent: #ffe66d;
  --bg-dark: #1a1a2e;
  --bg-darker: #0f0f1a;
  --text: #f0f0f0;
  --text-dim: #a0a0b0;
}

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.app-container {
  position: relative;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
}

/* Particles */
.particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--primary);
  opacity: 0.3;
  animation: float-particle 10s infinite linear;
}

@keyframes float-particle {
  0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
  10% { opacity: 0.3; }
  90% { opacity: 0.3; }
  100% { transform: translateY(-10vh) rotate(360deg); opacity: 0; }
}

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

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confetti-fall 2s forwards;
}

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

/* Header */
.header {
  background: linear-gradient(90deg, #9d4edd 0%, #ff6b9d 50%, #ff9a5c 100%);
  padding: 1.5rem 1rem;
  text-align: center;
  position: relative;
  z-index: 10;
}

.title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.8rem, 3vw, 1.5rem);
  color: white;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.3);
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.9);
}

/* Main content */
.main-content {
  padding: 1rem;
  position: relative;
  z-index: 10;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

@media (min-width: 1024px) {
  .content-grid {
    grid-template-columns: 300px 1fr 280px;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .content-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Control Panel */
.control-panel {
  background: rgba(255,255,255,0.03);
  border: 2px solid rgba(157,78,221,0.3);
  border-radius: 12px;
  padding: 1.25rem;
  backdrop-filter: blur(10px);
}

.input-section {
  margin-bottom: 1.25rem;
}

.input-label {
  display: block;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.concept-input {
  width: 100%;
  min-height: 80px;
  background: var(--bg-darker);
  border: 2px solid var(--primary);
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  resize: none;
  transition: all 0.3s;
  box-shadow: 0 0 10px rgba(157,78,221,0.2), inset 0 0 20px rgba(0,0,0,0.3);
}

.concept-input:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 20px rgba(255,107,157,0.3), inset 0 0 20px rgba(0,0,0,0.3);
}

.char-count {
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* Parameters */
.param-section {
  margin-bottom: 1rem;
}

.param-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.genre-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.genre-pill {
  padding: 0.4rem 0.8rem;
  border: 2px solid var(--primary);
  background: transparent;
  color: var(--text);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.genre-pill:hover {
  background: rgba(157,78,221,0.2);
}

.genre-pill.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 0 15px rgba(157,78,221,0.5);
}

.difficulty-toggles {
  display: flex;
  gap: 0.5rem;
}

.diff-toggle {
  flex: 1;
  padding: 0.5rem;
  border: 2px solid var(--secondary);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.7rem;
  transition: all 0.2s;
}

.diff-toggle:hover {
  background: rgba(255,107,157,0.2);
}

.diff-toggle.active {
  background: var(--secondary);
  color: white;
}

.style-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.style-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.style-btn:hover {
  background: rgba(255,230,109,0.1);
}

.style-btn.active {
  background: var(--accent);
  color: var(--bg-dark);
}

.style-icon {
  font-size: 1.2rem;
}

.style-name {
  font-size: 0.6rem;
  margin-top: 0.25rem;
  text-transform: capitalize;
}

.speed-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #4ade80 0%, #fbbf24 50%, #ef4444 100%);
  -webkit-appearance: none;
  cursor: pointer;
}

.speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* Buttons */
.button-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.generate-btn {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border: none;
  border-radius: 12px;
  color: white;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.3s;
  animation: pulse-glow 2s infinite;
  box-shadow: 0 4px 20px rgba(157,78,221,0.4);
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 4px 20px rgba(157,78,221,0.4); }
  50% { box-shadow: 0 4px 30px rgba(255,107,157,0.6); }
}

.generate-btn:hover:not(:disabled) {
  transform: scale(1.02);
}

.generate-btn:disabled {
  animation: none;
  opacity: 0.8;
}

.generate-btn.generating {
  animation: slot-spin 0.5s linear infinite;
}

@keyframes slot-spin {
  0% { transform: rotateX(0deg); }
  100% { transform: rotateX(360deg); }
}

.loading-text {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.lucky-btn {
  padding: 0.75rem;
  background: transparent;
  border: 2px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.lucky-btn:hover:not(:disabled) {
  background: var(--accent);
  color: var(--bg-dark);
}

/* Game Panel */
.game-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.6rem, 2vw, 1rem);
  color: var(--accent);
  text-shadow: 2px 2px 0 var(--primary);
  margin-bottom: 1rem;
  text-align: center;
}

.canvas-container {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 4/3;
  border: 4px solid var(--primary);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 
    0 0 0 2px var(--bg-dark),
    0 0 30px rgba(157,78,221,0.3),
    inset 0 0 60px rgba(0,0,0,0.5);
  background: var(--bg-darker);
}

.game-canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.canvas-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-dim);
}

.canvas-placeholder p:first-child {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.controls-info {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
}

/* Touch controls */
.touch-controls {
  display: none;
  margin-top: 1rem;
}

@media (max-width: 768px) {
  .touch-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
  }
}

.touch-row {
  display: flex;
  gap: 0.25rem;
}

.touch-btn {
  width: 50px;
  height: 50px;
  background: rgba(157,78,221,0.3);
  border: 2px solid var(--primary);
  border-radius: 8px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.touch-btn:active {
  background: var(--primary);
}

.jump-btn {
  background: rgba(255,107,157,0.3);
  border-color: var(--secondary);
}

.game-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.action-btn {
  padding: 0.6rem 1.2rem;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  transform: translateY(-2px);
}

.action-btn.secondary {
  background: transparent;
  border: 2px solid var(--secondary);
  color: var(--secondary);
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (max-width: 1023px) {
  .sidebar {
    grid-column: 1 / -1;
  }
}

.sidebar-section {
  background: rgba(255,255,255,0.03);
  border: 2px solid rgba(157,78,221,0.2);
  border-radius: 12px;
  padding: 1rem;
}

.sidebar-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
  color: var(--accent);
  margin-bottom: 1rem;
}

.no-games {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
}

.recent-games {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.recent-game {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.recent-game:hover {
  background: rgba(157,78,221,0.2);
}

.game-thumb {
  width: 40px;
  height: 40px;
  background: var(--bg-darker);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.game-info {
  flex: 1;
}

.game-name {
  font-size: 0.8rem;
  font-weight: 600;
}

.game-genre {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.tips-toggle {
  width: 100%;
  padding: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.tips-content {
  margin-top: 0.75rem;
}

.tips-content p {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
  border-left: 2px solid var(--primary);
}

/* Footer */
.footer {
  text-align: center;
  padding: 2rem 1rem;
  position: relative;
  z-index: 10;
  border-top: 1px solid rgba(157,78,221,0.2);
}

.footer a {
  color: var(--secondary);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.footer-strawberry {
  cursor: pointer;
  transition: transform 0.2s;
  display: inline-block;
}

.footer-strawberry:hover {
  transform: scale(1.2);
}

/* Secret modal */
.secret-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: 2000;
}

.secret-content {
  background: var(--bg-dark);
  border: 4px solid var(--secondary);
  border-radius: 16px;
  padding: 2rem;
  text-align: center;
  max-width: 400px;
  animation: pop-in 0.3s;
}

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

.secret-content h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 1rem;
}

.secret-game {
  background: rgba(0,0,0,0.3);
  padding: 2rem;
  border-radius: 8px;
  margin: 1rem 0;
}

.secret-score {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  color: var(--accent);
}

.close-secret {
  padding: 0.75rem 1.5rem;
  background: var(--secondary);
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  font-size: 0.9rem;
}

/* Scanlines overlay */
.game-canvas::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.1) 0px,
    rgba(0,0,0,0.1) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
}