/* =======================
   Root Theme Variables (Dark as Default)
========================== */
:root {
  --bg-color: linear-gradient(135deg, #000000 0%, #121212 100%);
  --text-color: #e0e0e0;
  --accent-color: #9b59b6;
  --canvas-glow: rgba(155, 89, 182, 0.4);
  --border-radius: 12px;
  --font-main: 'Segoe UI', sans-serif;
  --canvas-bg: rgba(255, 255, 255, 0.04);
  --arena-color: #555;
  --paddle-color: #66bb6a;
  --ball-color: var(--accent-color);
  --score-color: #81c784;
  --gameover-color: #ef9a9a;
  --highscore-color: var(--accent-color);
}

/* =======================
   Light Theme
========================== */
html[data-theme="light"] {
  --bg-color: linear-gradient(135deg, #fefefe 0%, #a6c9ff 100%);
  --text-color: #222;
  --accent-color: #4a90e2;
  --canvas-glow: rgba(74, 144, 226, 0.3);
  --canvas-bg: rgba(0, 0, 0, 0.04);
  --arena-color: #cccccc;
  --paddle-color: #4caf50;
  --score-color: #4caf50;
  --gameover-color: #e53935;
  --highscore-color: var(--accent-color);
}

/* =======================
   Dark Theme
========================== */
html[data-theme="dark"] {
  --bg-color: linear-gradient(135deg, #000000 0%, #121212 100%);
  --text-color: #e0e0e0;
  --accent-color: #9b59b6;
  --canvas-glow: rgba(155, 89, 182, 0.4);
  --canvas-bg: rgba(255, 255, 255, 0.04);
  --arena-color: #555;
  --paddle-color: #66bb6a;
  --score-color: #81c784;
  --gameover-color: #ef9a9a;
  --highscore-color: var(--accent-color);
}

/* =======================
   Colorful Theme
========================== */
html[data-theme="colorful"] {
  --bg-color: linear-gradient(135deg, #fcb69f 0%, #ffecd2 100%);
  --text-color: #2d2d2d;
  --accent-color: #ff9800;
  --canvas-glow: rgba(255, 152, 0, 0.4);
  --canvas-bg: rgba(255, 235, 59, 0.15);
  --arena-color: #ff4081;
  --paddle-color: #00e676;
  --score-color: #ff4081;
  --gameover-color: #d50000;
  --highscore-color: var(--accent-color);
}

/* =======================
   Base Layout
========================== */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: var(--bg-color);
  overflow: hidden;
  font-family: var(--font-main);
}

body {
  position: relative;
  background-size: cover;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* =======================
   Typography and Links
========================== */
a {
  color: var(--accent-color);
  text-decoration: none;
  transition: color 0.3s ease;
  cursor: pointer;
}

a:hover {
  text-decoration: underline;
  color: var(--text-color);
}

a:visited {
  color: var(--accent-color);
}

/* =======================
   Buttons
========================== */
button {
  background: var(--accent-color);
  color: var(--text-color);
  border: none;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: bold;
  border-radius: var(--border-radius);
  cursor: pointer;
  box-shadow: 0 0 12px var(--accent-color);
  transition: all 0.3s ease;
}

button:hover {
  background: var(--text-color);
}

.square-btn {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* =======================
   Modal Layout
========================== */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  padding: 1rem;
}

.modal.show {
  display: flex;
}

/* =======================
   Canvas Settings
========================== */
canvas {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  display: block;
  background: var(--canvas-bg);
  border-radius: 50%;
  width: 90vmin;
  height: 90vmin;
  max-width: 600px;
  max-height: 600px;
  box-shadow: 0 0 20px var(--canvas-glow);
}

/* =======================
   Fade-In Animation
========================== */
.fade-in {
  animation: fadeInScale 1.5s ease-out forwards;
}

@keyframes fadeInScale {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* =======================
   Footer
========================== */
#site-footer {
  position: fixed;
  bottom: 1rem;
  left: 0;
  right: 0;
  width: 100%;
  pointer-events: none;
  font-size: 0.85rem;
  z-index: 1000;
}

.footer-center {
  text-align: center;
  color: var(--text-color);
  opacity: 0.6;
  pointer-events: auto;
}

.footer-impressum {
  position: absolute;
  right: 1rem;
  bottom: 0;
  opacity: 0.6;
  pointer-events: auto;
}

/* =======================
   Impressum Modal
========================== */
#impressumModal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1500;
  padding: 1rem;
  flex-direction: column;
}

#impressumModal.show {
  display: flex;
}

#impressumModal .modal-content {
  background: var(--bg-color);
  color: var(--text-color);
  padding: 2rem;
  border-radius: var(--border-radius);
  max-width: 600px;
  width: 90%;
  text-align: left;
}

/* =======================
   Starfield Animation
========================== */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.star {
  position: absolute;
  z-index: 2;
  width: 2px;
  height: 2px;
  background: var(--accent-color);
  opacity: 0.2;
  border-radius: 50%;
  animation: blinkStar 3s infinite ease-in-out;
}

@keyframes blinkStar {
  0%, 100% { opacity: 0.1; }
  50% { opacity: 0.8; }
}

/* =======================
   Responsive Styles
========================== */
@media (max-width: 768px) {
  #intro h1 {
    font-size: 1.6rem;
  }

  .subnote {
    font-size: 0.9rem;
    padding: 0 1rem;
  }

  .typewriter {
    width: 100%;
    font-size: 0.95rem;
  }

  canvas {
    width: 90vmin;
    height: 90vmin;
    max-width: 100vw;
    max-height: 100vw;
  }

  button {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
  }

  .controls {
    flex-direction: column;
    gap: 0.5rem;
  }

  #theme-toggle {
    top: 0.5rem !important;
    left: 0.5rem !important;
  }

  #impressumModal .modal-content {
    padding: 1rem;
    font-size: 0.95rem;
  }

  #site-footer {
    font-size: 0.75rem;
    bottom: 0.5rem;
  }

  .footer-impressum {
    right: 0.5rem;
  }

  .square-btn {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 0.85rem;
  }
}

/* =======================
   Hover Enhancements
========================== */
@media (hover: hover) {
  button:hover {
    background: var(--text-color);
  }

  .icon-btn:hover {
    opacity: 1;
    background: var(--bg-color);
    box-shadow: 0 0 6px var(--accent-color);
  }
}
