* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --aero-sky: #87CEEB;
  --aero-green: #7FFFD4;
  --aero-white: #f0f8ff;
  --aero-chrome: #c0c0c0;
  --aero-orange: #FF8C42;
  --aero-magenta: #FF69B4;
  --aero-glass: rgba(255,255,255,0.25);
  --aero-glass-border: rgba(255,255,255,0.5);
  --ds-body: #d1d5db;
  --ds-body-dark: #9ca3af;
  --ds-bezel: #1a1a2e;
  --screen-w: 256px;
  --screen-h: 192px;
}

body {
  font-family: 'Quicksand', sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
  background: linear-gradient(160deg, #a8e6cf 0%, #87CEEB 30%, #dceefb 50%, #7FFFD4 70%, #f0f8ff 100%);
  background-attachment: fixed;
}

.aero-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bubble {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(ellipse at 30% 30%, rgba(255,255,255,0.8), rgba(135,206,235,0.15) 60%, transparent 70%);
  border: 1px solid rgba(255,255,255,0.4);
  animation: float-up linear infinite;
}

@keyframes float-up {
  0% { transform: translateY(100vh) scale(0.5); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 0.7; }
  100% { transform: translateY(-20vh) scale(1.2); opacity: 0; }
}

.aurora {
  position: absolute;
  width: 200%;
  height: 300px;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(127,255,212,0.15), 
    rgba(135,206,235,0.2), 
    rgba(255,105,180,0.1), 
    transparent
  );
  filter: blur(60px);
  animation: aurora-drift 12s ease-in-out infinite alternate;
}

@keyframes aurora-drift {
  0% { transform: translateX(-30%) rotate(-3deg); }
  100% { transform: translateX(10%) rotate(3deg); }
}

.lens-flare {
  position: absolute;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, transparent 70%);
  animation: flare-pulse 6s ease-in-out infinite alternate;
}

@keyframes flare-pulse {
  0% { opacity: 0.3; transform: scale(0.8); }
  100% { opacity: 0.7; transform: scale(1.3); }
}

/* DS Device */
.ds-device {
  position: relative;
  perspective: 1200px;
  z-index: 10;
}

.ds-body-top {
  background: linear-gradient(180deg, #bfc7d0 0%, #a8b0b8 50%, #959da5 100%);
  border-radius: 16px 16px 0 0;
  padding: 12px 16px 6px 16px;
  box-shadow: 
    0 -4px 20px rgba(0,0,0,0.15),
    inset 0 1px 0 rgba(255,255,255,0.5),
    inset 0 -1px 0 rgba(0,0,0,0.1);
  position: relative;
}

.ds-body-top::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
}

.ds-hinge {
  height: 10px;
  background: linear-gradient(180deg, #888 0%, #aaa 20%, #ddd 40%, #bbb 60%, #999 80%, #777 100%);
  border-left: 2px solid #666;
  border-right: 2px solid #666;
  position: relative;
  z-index: 5;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3), inset 0 -2px 4px rgba(0,0,0,0.2);
}

.ds-body-bottom {
  background: linear-gradient(180deg, #959da5 0%, #a8b0b8 50%, #bfc7d0 100%);
  border-radius: 0 0 20px 20px;
  padding: 6px 16px 16px 16px;
  box-shadow: 
    0 8px 30px rgba(0,0,0,0.25),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -1px 0 rgba(0,0,0,0.05);
  position: relative;
}

.screen-bezel {
  background: #111827;
  border-radius: 6px;
  padding: 4px;
  position: relative;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.5);
}

.screen {
  width: var(--screen-w);
  height: var(--screen-h);
  background: #1a1a2e;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  image-rendering: pixelated;
}

.screen-glass {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 40%, transparent 60%, rgba(255,255,255,0.05) 100%);
  pointer-events: none;
  z-index: 20;
  border-radius: 3px;
}

.power-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e, 0 0 12px rgba(34,197,94,0.5);
  animation: led-pulse 3s ease-in-out infinite;
}

@keyframes led-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Buttons */
.dpad-container {
  position: relative;
  width: 56px;
  height: 56px;
}

.dpad-btn {
  position: absolute;
  background: linear-gradient(180deg, #555 0%, #333 100%);
  border: 1px solid #222;
  cursor: pointer;
  transition: all 0.1s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}

.dpad-btn:active {
  transform: scale(0.95);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), inset 0 2px 4px rgba(0,0,0,0.2);
}

.dpad-center {
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  background: radial-gradient(circle, #444, #333);
  border-radius: 50%;
  border: 1px solid #222;
}

.dpad-up { top: 0; left: 50%; transform: translateX(-50%); width: 18px; height: 22px; border-radius: 4px 4px 0 0; }
.dpad-down { bottom: 0; left: 50%; transform: translateX(-50%); width: 18px; height: 22px; border-radius: 0 0 4px 4px; }
.dpad-left { left: 0; top: 50%; transform: translateY(-50%); width: 22px; height: 18px; border-radius: 4px 0 0 4px; }
.dpad-right { right: 0; top: 50%; transform: translateY(-50%); width: 22px; height: 18px; border-radius: 0 4px 4px 0; }

.face-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  transition: all 0.1s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.15);
  user-select: none;
}

.face-btn:active {
  transform: scale(0.9);
  box-shadow: 0 0 2px rgba(0,0,0,0.3), inset 0 2px 4px rgba(0,0,0,0.3);
}

.btn-a { background: linear-gradient(180deg, #ef4444, #b91c1c); }
.btn-b { background: linear-gradient(180deg, #eab308, #a16207); }
.btn-x { background: linear-gradient(180deg, #3b82f6, #1d4ed8); }
.btn-y { background: linear-gradient(180deg, #22c55e, #15803d); }

.sys-btn {
  width: 32px;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(180deg, #555, #333);
  border: 1px solid #222;
  cursor: pointer;
  transition: all 0.1s;
  font-size: 6px;
  color: rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Quicksand', sans-serif;
  font-weight: 600;
  letter-spacing: 0.5px;
  user-select: none;
}

.sys-btn:active {
  transform: scale(0.95);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.4);
}

/* DS Reflection */
.ds-reflection {
  position: relative;
  height: 80px;
  overflow: hidden;
  opacity: 0.15;
  transform: scaleY(-1);
  mask-image: linear-gradient(to top, transparent, black);
  -webkit-mask-image: linear-gradient(to top, transparent, black);
  pointer-events: none;
}

/* Boot animation */
.boot-overlay {
  position: fixed;
  inset: 0;
  background: white;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: opacity 1s ease-out;
}

.boot-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* App icon styling */
.app-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.app-icon::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.5), rgba(255,255,255,0.1));
  border-radius: 12px 12px 0 0;
  pointer-events: none;
}

.app-icon:active {
  transform: scale(0.9);
}

.app-icon-label {
  font-size: 8px;
  color: white;
  text-align: center;
  margin-top: 2px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  font-family: 'Quicksand', sans-serif;
  font-weight: 600;
}

/* Top screen header */
.top-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 18px;
  background: linear-gradient(180deg, rgba(0,0,0,0.6), rgba(0,0,0,0.3));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-size: 9px;
  color: rgba(255,255,255,0.9);
  z-index: 15;
  font-family: 'Quicksand', sans-serif;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

/* Night theme */
.theme-night {
  --aero-sky: #1a1a3e;
  --aero-green: #2d4a5e;
}

.theme-night body, body.theme-night {
  background: linear-gradient(160deg, #0a0a2e 0%, #1a1a3e 30%, #0d1b2a 50%, #152238 70%, #1b2838 100%) !important;
}

/* Footer glass */
.footer-glass {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.15);
  border-top: 1px solid rgba(255,255,255,0.3);
}

/* Canvas in screens */
.screen canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Responsive */
@media (max-width: 400px) {
  :root {
    --screen-w: 224px;
    --screen-h: 168px;
  }
  .face-btn { width: 20px; height: 20px; font-size: 8px; }
  .dpad-container { width: 48px; height: 48px; }
}

@media (max-width: 320px) {
  :root {
    --screen-w: 192px;
    --screen-h: 144px;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 0; }

/* Smooth screen transitions */
.screen-content {
  position: absolute;
  inset: 0;
  transition: opacity 0.3s ease;
}

/* Star game */
.star {
  position: absolute;
  font-size: 18px;
  cursor: pointer;
  animation: star-fall linear forwards;
  user-select: none;
}

@keyframes star-fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(200px) rotate(360deg); opacity: 0; }
}

/* Drawing colors */
.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}

.color-dot.active {
  border-color: white;
  transform: scale(1.3);
  box-shadow: 0 0 6px rgba(255,255,255,0.5);
}

/* Music visualizer bars */
.viz-bar {
  display: inline-block;
  width: 4px;
  margin: 0 1px;
  background: linear-gradient(0deg, #22c55e, #87CEEB, #FF69B4);
  border-radius: 2px 2px 0 0;
  transition: height 0.1s;
  vertical-align: bottom;
}

/* Settings slider */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(255,255,255,0.2), rgba(135,206,235,0.6));
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff, #87CEEB);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}