/* ============================================================
   Blockdrop — eigenständiger Graphit-Dark-Look (Regel: Spiele
   dürfen ein eigenes Design haben). Lokale Palette überschreibt
   die Site-Theme-Variablen, damit das Spiel in jedem Site-Theme
   identisch und lesbar aussieht.
   ============================================================ */
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

body {
  /* --- Blockdrop-Palette --- */
  --bd-bg-0: #1a1a1a;
  --bd-bg-1: #242128;
  --bd-panel: rgba(38, 34, 46, 0.52);
  --bd-panel-soft: rgba(255, 255, 255, 0.05);
  --bd-glass-border: rgba(255, 255, 255, 0.11);
  --bd-glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.09);
  --bd-glass-blur: blur(20px) saturate(1.35);
  --bd-line: rgba(162, 76, 255, 0.24);
  --bd-line-strong: rgba(162, 76, 255, 0.42);
  --bd-accent: #a24cff;
  --bd-accent-2: #7b2ff7;
  --bd-gold: #c084fc;
  --bd-text: #ececec;
  --bd-text-dim: #9f9f9f;
  --bd-font-pixel: 'Press Start 2P', 'Courier New', monospace;

  /* Site-Variablen lokal auf den Blockdrop-Look mappen */
  --primary: var(--bd-accent);
  --text-color: var(--bd-text);
  --card-bg: var(--bd-panel);
  --card-border: 1px solid var(--bd-line);

  font-family: 'Chakra Petch', 'Segoe UI', Tahoma, sans-serif;
  color: var(--bd-text);
  background-color: var(--bd-bg-0);
  background-image:
    radial-gradient(ellipse 70% 55% at 50% 0%, rgba(162, 76, 255, 0.13), transparent 62%),
    radial-gradient(ellipse 80% 70% at 50% 45%, var(--bd-bg-1), var(--bd-bg-0) 72%),
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: auto, auto, 44px 44px, 44px 44px;
}

/* Globalen Site-Hintergrund (main.css body::before) durch das
   eigene dunkle Ambiente ersetzen — gilt für alle Site-Themes */
body::before {
  background-color: var(--bd-bg-0);
  background-image:
    radial-gradient(ellipse 70% 55% at 50% 0%, rgba(162, 76, 255, 0.13), transparent 62%),
    radial-gradient(ellipse 80% 70% at 50% 45%, var(--bd-bg-1), var(--bd-bg-0) 72%),
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: auto, auto, 44px 44px, 44px 44px;
}

/* Site-Effekt-Layer (Sterne/Schnee) ausblenden — sie zeichnen sonst
   über das Blockdrop-Ambiente und lassen die Seite wie gefiltert wirken */
#star-canvas,
#snow-canvas {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

/* Sehr dezente Textur, ohne Neon-Schimmer */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -9998;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.016) 0px,
    rgba(255, 255, 255, 0.016) 1px,
    transparent 1px,
    transparent 4px
  );
  pointer-events: none;
}


#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1500;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  image-rendering: auto;
  max-width: none;
  max-height: none;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 10, 0.42);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.modal-content {
  position: relative;
  background: linear-gradient(160deg, rgba(58, 50, 72, 0.5), rgba(32, 29, 40, 0.55));
  backdrop-filter: var(--bd-glass-blur);
  -webkit-backdrop-filter: var(--bd-glass-blur);
  padding: 30px 36px;
  border-radius: 24px;
  border: 1px solid var(--bd-glass-border);
  text-align: left;
  /* Überschriften linksbündig wie im Timer */
  box-shadow:
    var(--bd-glass-highlight),
    0 20px 60px rgba(0, 0, 0, 0.55);
  animation: settingsSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  width: 95%;
  max-width: 450px;
}

/* Keine Glanzleiste oben auf Dialogen */
.modal-content::before {
  content: none;
  display: none;
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 24px;
  font-family: var(--bd-font-pixel);
  font-size: 1.15em;
  line-height: 1.5;
  color: var(--bd-text);
  text-align: center;
  text-shadow: none;
}

.modal-subtitle {
  color: #ccc;
  font-weight: bold;
  margin-bottom: 1rem;
  text-transform: uppercase;
  font-size: 0.85em;
  letter-spacing: 1px;
  text-align: left;
}

.modal-content p {
  font-size: 1.2em;
  margin-bottom: 25px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.container {
  display: flex;
  gap: 30px;
  align-items: center;
  position: relative;
  /* Notwendig für z-index */
  z-index: 10;
  /* Stellt sicher, dass das Spiel über dem Konfetti liegt */
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
}

.playfield-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
}

.playfield-shell::before {
  content: '';
  display: none;
}

body.blockdrop-board-tetrominoes .playfield-shell::before {
  display: block;
  position: absolute;
  inset: -7.5% -9%;
  z-index: -1;
  background: url("assets/Tetrominoes/Border.png") center / 100% 100% no-repeat;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.42));
  pointer-events: none;
}

canvas {
  border: 2px solid var(--bd-line-strong);
  background: rgba(20, 18, 26, 0.55);
  image-rendering: pixelated;
  border-radius: 10px;
  /* Hardware acceleration for smoother animations */
  will-change: contents;
  transform: translateZ(0);
}

#tetris {
  height: 85vh;
  width: auto;
  max-width: min(70vw, max(180px, calc(100vw - 330px)));
  /* Verhindert horizontales Überlaufen auf schmalen Screens */
  max-height: 800px;
  /* Optional: Maximale Größe für extrem hohe Bildschirme */
  box-shadow:
    0 0 0 1px rgba(12, 12, 12, 0.95),
    0 26px 60px rgba(0, 0, 0, 0.55);
}

body.blockdrop-asset-theme canvas {
  image-rendering: auto;
}

body.blockdrop-board-tetrominoes #tetris {
  border-color: transparent;
  background: #24678d;
  box-shadow:
    inset 0 0 18px rgba(255, 255, 255, 0.16),
    0 8px 24px rgba(0, 0, 0, 0.34);
}

body.blockdrop-board-tetrominoes #next,
body.blockdrop-board-tetrominoes #hold {
  border-color: rgba(168, 224, 242, 0.9);
  background: #1d587f;
}

.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  width: clamp(208px, 24vw, 252px);
  min-width: 0;
  padding: 16px 14px 14px;
  box-sizing: border-box;
  background: linear-gradient(165deg, rgba(58, 50, 72, 0.42), rgba(30, 27, 38, 0.5));
  backdrop-filter: var(--bd-glass-blur);
  -webkit-backdrop-filter: var(--bd-glass-blur);
  border: 1px solid var(--bd-glass-border);
  border-radius: 16px;
  box-shadow:
    var(--bd-glass-highlight),
    0 18px 44px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

/* Keine Glanzleiste oben auf der Sidebar */
.sidebar::before {
  content: none;
  display: none;
}

.sidebar-card,
.score-group {
  background: var(--bd-panel-soft);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.piece-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
}

.piece-card-label,
.controls-title {
  font-family: var(--bd-font-pixel);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 1.5px;
  line-height: 1;
  text-transform: uppercase;
  color: var(--bd-text-dim);
  text-shadow: none;
}

.piece-card canvas {
  border-width: 1px;
  border-color: var(--bd-line);
  background: rgba(18, 16, 24, 0.42);
}

.score-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}

.sidebar-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 4px 0;
}

.mode-badge,
.level-progress {
  grid-column: 1 / -1;
}

.sidebar .score-stat-label {
  margin-bottom: 0;
  font-family: var(--bd-font-pixel);
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--bd-text-dim);
}

.sidebar .score-stat-value {
  overflow: hidden;
  color: var(--bd-text);
  font-size: 1.18em;
  font-weight: 700;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.sidebar-stat:first-child .score-stat-value {
  color: var(--bd-gold);
  text-shadow: none;
}

.controls {
  padding: 10px;
  font-size: 11px;
}

.control-hints {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
  margin-top: 8px;
}

.control-hints span {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: var(--bd-text-dim);
  line-height: 1.15;
  white-space: normal;
}

.control-hints kbd {
  min-width: 22px;
  padding: 3px 5px;
  border: 1px solid var(--bd-line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--bd-accent);
  font-family: inherit;
  font-size: 0.85em;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.rainbow {
  animation: rainbow 1s linear infinite;
}

@keyframes rainbow {
  0% {
    border-color: var(--bd-line-strong);
  }

  16% {
    border-color: #777;
  }

  33% {
    border-color: var(--bd-gold);
  }

  50% {
    border-color: var(--bd-accent);
  }

  66% {
    border-color: #6c737a;
  }

  83% {
    border-color: #555;
  }

  100% {
    border-color: var(--bd-line-strong);
  }
}

@keyframes shake {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }

  20% {
    transform: translate(-2px, 2px) rotate(-1deg);
  }

  40% {
    transform: translate(2px, -2px) rotate(1deg);
  }

  60% {
    transform: translate(-2px, 2px) rotate(-1deg);
  }

  80% {
    transform: translate(2px, -2px) rotate(1deg);
  }

  100% {
    transform: translate(0, 0) rotate(0deg);
  }
}

.shake {
  animation: shake 0.3s;
}

#wowMessage {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--bd-font-pixel);
  font-size: 52px;
  color: var(--bd-gold);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 1000;
}

.floating-points {
  position: fixed;
  transform: translate(-50%, 0);
  font-family: var(--bd-font-pixel);
  font-size: 20px;
  color: var(--bd-gold);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.72);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
  z-index: 1000;
}

.floating-combo {
  position: fixed;
  transform: translate(-50%, 0);
  font-family: var(--bd-font-pixel);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease-out, transform 1s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 1001;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
}

.button-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column-reverse;
  gap: 15px;
  z-index: 1001;
}

.game-button {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--bd-panel);
  backdrop-filter: var(--bd-glass-blur);
  -webkit-backdrop-filter: var(--bd-glass-blur);
  border: 1px solid var(--bd-glass-border);
  color: var(--bd-text);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.25s ease;
  font-size: 14px;
  font-weight: bold;
  padding: 0;
  position: relative;
  box-shadow:
    var(--bd-glass-highlight),
    0 10px 26px rgba(0, 0, 0, 0.45);
}

/* Absolute Schnee-Eliminierung inklusive Pseudo-Elementen */
.snow-wrapper .snow-cap,
.snow-wrapper .snow-drip,
.snow-cap,
.snow-drip,
[class*="snow-cap"],
[class*="snow-drip"],
.snow-cap::before,
.snow-cap::after {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  height: 0 !important;
  pointer-events: none !important;
  content: none !important;
}

.snow-wrapper {
  display: inline-block !important;
  transform: none !important;
  margin: 0 !important;
}

/* Entfernt den Standard-Shine der Buttons, falls er stört */
html[data-theme] .game-button::after,
html[data-theme] .rainbow-button::after,
html[data-theme] .btn::after {
  content: none !important;
  display: none !important;
}

.game-button:hover {
  transform: translateY(-2px);
  border-color: var(--bd-accent);
  box-shadow:
    var(--bd-glass-highlight),
    0 12px 28px rgba(0, 0, 0, 0.5);
}

.game-button svg {
  stroke: var(--bd-text);
  transition: all 0.25s ease;
}

.game-button:hover svg {
  stroke: var(--bd-accent);
}

#next {
  width: 6.5rem;
  height: 12rem;
}

#hold {
  width: 6rem;
  height: 6rem;
}

.score-stats {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 25px;
}

.score-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 15px 25px;
  flex: 1;
}

.score-stat-label {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #aaa;
  margin-bottom: 8px;
}

.score-stat-value {
  font-size: 2em;
  font-weight: bold;
  color: var(--text-color);
}

.new-highscore-badge {
  background: linear-gradient(135deg, var(--bd-accent), var(--bd-accent-2));
  color: #fff;
  box-shadow: 0 8px 18px rgba(162, 76, 255, 0.22);
  text-align: center;
  border-radius: 20px;
  padding: 5px 15px;
  font-size: 0.8em;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 20px;
  animation: fadeIn 0.5s ease;
}

.gameover-details {
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 12px 16px;
}

.gameover-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.gameover-detail-row:last-child {
  border-bottom: none;
}

.gameover-detail-label {
  font-size: 0.85em;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.gameover-detail-value {
  font-size: 1.1em;
  font-weight: bold;
  color: var(--text-color);
}

.rainbow-button {
  background-image: linear-gradient(90deg, var(--bd-accent), var(--bd-accent-2), #c084fc, var(--bd-accent));
  background-size: 200% auto;
  color: white;
  border: none;
  padding: 15px 30px;
  border-radius: 8px;
  font-size: 1.2em;
  cursor: pointer;
  transition: background-position 0.5s;
}

.rainbow-button:hover {
  background-position: right center;
}

.btn-primary {
  background: linear-gradient(135deg, var(--bd-accent), var(--bd-accent-2)) !important;
  border: none !important;
  color: #fff !important;
  font-weight: 700 !important;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 12px !important;
  border-radius: 10px !important;
  transition: all 0.25s ease !important;
  box-shadow: 0 10px 22px rgba(162, 76, 255, 0.22) !important;
}

.btn-primary:hover {
  filter: brightness(1.06) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 12px 28px rgba(162, 76, 255, 0.32) !important;
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid var(--bd-line) !important;
  color: var(--bd-text) !important;
  font-weight: 600 !important;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 12px !important;
  border-radius: 10px !important;
  transition: all 0.25s ease !important;
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.09) !important;
  border-color: var(--bd-line-strong) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
}

/* ===== Settings Modal ===== */

@keyframes settingsSlideIn {
  from { transform: translateY(30px) scale(0.95); }
  to { transform: translateY(0) scale(1); }
}

@keyframes settingsSlideOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(20px) scale(0.97); }
}

@keyframes settingsOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes settingsTabPanelIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#settingsModal {
  animation: settingsOverlayIn 0.25s ease;
}

.settings-panel {
  background: linear-gradient(160deg, rgba(58, 50, 72, 0.5), rgba(32, 29, 40, 0.55));
  backdrop-filter: var(--bd-glass-blur);
  -webkit-backdrop-filter: var(--bd-glass-blur);
  padding: 28px 32px;
  border-radius: 24px;
  border: 1px solid var(--bd-glass-border);
  box-shadow:
    var(--bd-glass-highlight),
    0 20px 60px rgba(0, 0, 0, 0.5);
  width: 95%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: settingsSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.settings-panel.closing {
  animation: settingsSlideOut 0.25s ease forwards;
}

.settings-panel::before {
  content: none;
  display: none;
}

.settings-panel::-webkit-scrollbar {
  width: 4px;
}

.settings-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* --- Header --- */
.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.settings-header h2 {
  margin: 0;
  font-family: var(--bd-font-pixel);
  font-size: 0.95em;
  line-height: 1.4;
  color: var(--bd-text);
  font-weight: 400;
  text-align: left;
  text-shadow: none;
}

.settings-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.settings-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  transform: rotate(90deg);
}

/* --- Tabs --- */
.settings-tabs {
  position: relative;
  display: flex;
  gap: 6px;
  padding: 5px;
  margin-bottom: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.settings-tab-slider {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 5px;
  width: calc((100% - 22px) / 3);
  border-radius: 10px;
  background: rgba(162, 76, 255, 0.18);
  border: 1px solid rgba(162, 76, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
  z-index: 0;
  pointer-events: none;
}

.settings-tabs.blocks-active .settings-tab-slider {
  transform: translateX(calc(100% + 6px));
}

.settings-tabs.board-active .settings-tab-slider {
  transform: translateX(calc(200% + 12px));
}

.settings-tab {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  padding: 10px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.48);
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.15s ease;
}

.settings-tab:hover {
  color: rgba(255, 255, 255, 0.78);
}

.settings-tab.active {
  color: var(--bd-text);
  transform: translateY(-1px);
}

.settings-tab-panel {
  display: none;
}

.settings-tab-panel.active {
  display: block;
}

.settings-tab-panel.tab-panel-enter {
  animation: settingsTabPanelIn 0.18s ease both;
}

/* --- Sections --- */
.settings-section {
  margin-bottom: 22px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section-label {
  color: rgba(255, 255, 255, 0.4);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7em;
  letter-spacing: 2px;
  margin-bottom: 12px;
  padding-left: 12px;
  border-left: 3px solid var(--primary);
}

/* --- Theme Grid --- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.theme-card {
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px;
  transition: all 0.25s ease;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
}

.theme-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.theme-card.selected {
  border-color: var(--bd-accent);
  background: rgba(162, 76, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(162, 76, 255, 0.12);
}

.theme-card-check {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bd-accent);
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
}

.theme-card-check svg {
  width: 10px;
  height: 10px;
}

.theme-card.selected .theme-card-check {
  display: flex;
}

.theme-preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 3px;
  width: 100%;
  aspect-ratio: 2 / 1;
}

.preview-block {
  width: 100%;
  height: 100%;
  border-radius: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

.preview-block-sprite {
  background-position: center;
  background-repeat: no-repeat;
  background-size: 400% 400%;
}

.board-style-grid {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

.board-style-preview {
  --board-preview-line: rgba(255, 255, 255, 0.12);
  --board-preview-glow: rgba(0, 0, 0, 0);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 1px;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background-color: #211f24;
  background-position: center;
  background-repeat: repeat;
  background-size: 64px 64px;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.28);
  position: relative;
  z-index: 1;
}

.board-style-preview span {
  min-width: 0;
  min-height: 0;
}

.board-style-preview::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.board-style-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, var(--board-preview-glow), transparent 72%);
}

.board-style-preview-tetrominoes {
  border-color: rgba(168, 224, 242, 0.45);
}

.board-style-preview-arcade {
  --board-preview-line: rgba(162, 76, 255, 0.34);
  --board-preview-glow: rgba(162, 76, 255, 0.24);
  box-shadow:
    inset 0 0 0 1px rgba(162, 76, 255, 0.16),
    inset 0 0 22px rgba(162, 76, 255, 0.22);
}

.board-style-preview-arcade::before,
.board-style-preview-deep::before {
  background-image:
    linear-gradient(to right, var(--board-preview-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--board-preview-line) 1px, transparent 1px);
  background-size: calc(100% / 6) calc(100% / 4);
}

.board-style-preview-pixel {
  background-size: 48px 48px;
}

.board-style-preview-deep {
  --board-preview-line: rgba(89, 209, 178, 0.28);
  --board-preview-glow: rgba(89, 209, 178, 0.16);
  border-color: rgba(89, 209, 178, 0.22);
  box-shadow:
    inset 0 0 0 1px rgba(89, 209, 178, 0.08),
    inset 0 0 22px rgba(40, 120, 110, 0.16);
}

.theme-card-name {
  font-size: 0.72em;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
  white-space: nowrap;
  font-weight: 600;
}

.theme-card.selected .theme-card-name {
  color: var(--primary);
}

/* --- Volume Control --- */
.volume-control {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  padding: 14px 18px;
}

.volume-icon-btn {
  font-size: 1.2em;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease;
  user-select: none;
}

.volume-icon-btn:hover {
  transform: scale(1.15);
}

.volume-icon-btn:active {
  transform: scale(0.95);
}

.volume-value {
  font-size: 0.8em;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 600;
  min-width: 38px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  outline: none;
  border: none;
  cursor: pointer;
  flex: 1;
  padding: 0;
}

.volume-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(to right, var(--primary) var(--volume-fill, 10%), rgba(255, 255, 255, 0.1) var(--volume-fill, 10%));
  border-radius: 4px;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  margin-top: -6px;
  box-shadow: 0 0 0 2px var(--primary), 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 0 2px var(--primary), 0 2px 8px rgba(0, 0, 0, 0.48);
}

.volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--primary), 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease;
}

.volume-slider::-moz-range-track {
  height: 4px;
  background: linear-gradient(to right, var(--primary) var(--volume-fill, 10%), rgba(255, 255, 255, 0.1) var(--volume-fill, 10%));
  border-radius: 5px;
  border: none;
}

/* --- Feature List --- */
.feature-list {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  overflow: hidden;
}

.feature-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.feature-item:last-child {
  border-bottom: none;
}

.feature-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.feature-name {
  font-size: 0.9em;
  color: var(--text-color);
  font-weight: 500;
}

.feature-desc {
  font-size: 0.72em;
  color: rgba(255, 255, 255, 0.35);
}

/* --- Toggle Switch --- */
.toggle-switch {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
  margin: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  width: 48px;
  height: 26px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 26px;
  position: relative;
  transition: all 0.25s ease;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

input:checked + .toggle-track {
  background: var(--bd-accent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

input:checked + .toggle-track .toggle-thumb {
  transform: translateX(22px);
}

@media (max-width: 380px) {
  .settings-panel {
    padding: 20px 24px;
  }

  .theme-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-height: 760px) and (min-width: 601px) {
  .container {
    gap: 18px;
  }

  #tetris {
    height: 85vh;
  }

  .sidebar {
    width: 208px;
    gap: 8px;
    padding: 10px;
  }

  .piece-card {
    gap: 5px;
    padding: 6px;
  }

  .score-group {
    gap: 5px;
    padding: 7px;
  }

  .sidebar-stat {
    padding: 3px 0;
  }

  .sidebar .score-stat-value {
    font-size: 1em;
  }

  .controls {
    padding: 8px;
    font-size: 10px;
  }

  .control-hints {
    gap: 5px 6px;
  }

  #next {
    width: 4.4rem;
    height: 9.6rem;
  }

  #hold {
    width: 4.4rem;
    height: 4.4rem;
  }
}

@media (max-height: 640px) and (min-width: 601px) {
  .controls {
    display: none;
  }
}

@media (max-height: 520px) and (min-width: 601px) {
  .sidebar {
    gap: 6px;
    padding: 8px;
  }

  .piece-card {
    padding: 5px;
  }

  .score-group {
    padding: 6px;
    font-size: 0.82em;
  }

  #next {
    width: 3.7rem;
    height: 7.8rem;
  }

  #hold {
    width: 3.7rem;
    height: 3.7rem;
  }
}

#star-canvas {
  border: none;
}

/* Mode Selection */
.mode-select-options {
  display: flex;
  gap: 16px;
}

.mode-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  color: var(--text-color);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  font-family: inherit;
}

.mode-btn:hover {
  border-color: var(--primary);
  background: rgba(162, 76, 255, 0.12);
  transform: translateY(-3px);
}

.mode-btn-icon {
  font-size: 2.2em;
}

.mode-btn-name {
  font-size: 1.1em;
  font-weight: bold;
}

.mode-btn-desc {
  font-size: 0.78em;
  color: #aaa;
  text-align: center;
}

.mode-btn-hs {
  font-size: 0.82em;
  color: var(--primary);
  font-weight: bold;
  margin-top: 4px;
}

/* Mode badge in sidebar */
.mode-badge {
  font-size: 0.78em;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  opacity: 0.85;
}

/* Level Progress Bar */
.level-progress {
  width: 100%;
  margin-top: 4px;
}

.level-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.level-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease;
  box-shadow: none;
}

.level-progress-text {
  font-size: 0.7em;
  color: #888;
  text-align: center;
  margin-top: 2px;
}

/* Leaderboard Modal */
.bd-close-btn {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 1.2em;
  cursor: pointer;
  opacity: 0.7;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  transition: opacity 0.2s;
}

.bd-close-btn:hover {
  opacity: 1;
}

.bd-lb-tab {
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid transparent;
  border-radius: 20px;
  color: var(--text-color);
  padding: 6px 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9em;
  transition: border-color 0.2s, background 0.2s;
}

.bd-lb-tab.active {
  border-color: var(--primary);
  background: rgba(162, 76, 255, 0.14);
}

.bd-lb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.bd-lb-item:last-child {
  border-bottom: none;
}

.bd-lb-item.bd-lb-me {
  background: rgba(162, 76, 255, 0.1);
  border-radius: 8px;
}

.bd-lb-rank {
  width: 28px;
  text-align: right;
  font-size: 0.85em;
  color: #888;
  flex-shrink: 0;
}

.bd-lb-name {
  flex: 1;
  font-weight: bold;
  font-size: 0.95em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bd-lb-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
}

.bd-lb-score {
  font-weight: bold;
  font-size: 1em;
  color: var(--primary);
}

.bd-lb-meta {
  font-size: 0.75em;
  color: #888;
}

@media (max-width: 600px) {
  html,
  body {
    justify-content: flex-start;
  }

  .container {
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    height: 100dvh;
    padding: 6px 6px 195px 6px; /* Platz unten für schwebende Buttons */
    box-sizing: border-box;
    justify-content: space-between;
  }

  .playfield-shell {
    order: 2;
    margin-top: auto;
  }

  #tetris {
    height: auto;
    width: auto;
    max-height: calc(100dvh - 350px);
    max-width: 95vw;
    margin-top: auto;
  }

  .button-container {
    flex-direction: row;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    gap: 12px;
  }

  .game-button {
    width: 46px;
    height: 46px;
  }

  .sidebar {
    order: 1;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: stretch;
    min-width: unset;
    width: 100%;
    flex-shrink: 0;
    padding: 8px;
    box-sizing: border-box;
    gap: 6px;
  }

  .piece-card {
    gap: 5px;
    padding: 6px;
    flex-shrink: 0;
  }

  .piece-card-label {
    font-size: 8px;
    letter-spacing: 1px;
  }

  .piece-card-next {
    order: 1;
  }

  .score-group {
    order: 2;
    flex: 1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    min-width: 0;
    padding: 6px;
    font-size: 0.85em;
    text-align: center;
  }

  .sidebar-stat {
    padding: 5px 4px;
  }

  .sidebar .score-stat-label {
    font-size: 8px;
    letter-spacing: 0.5px;
  }

  .sidebar .score-stat-value {
    font-size: 0.92em;
  }

  .mode-badge {
    font-size: 0.62em;
  }

  .level-progress-text {
    font-size: 0.58em;
  }

  .piece-card-hold {
    order: 3;
  }

  .controls {
    display: none;
  }

  #next {
    width: 4rem;
    height: 8.8rem;
  }

  #hold {
    width: 4rem;
    height: 4rem;
  }
}



#countdownText {
  font-family: var(--bd-font-pixel);
  font-size: 72px;
  color: var(--bd-accent);
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.72);
  animation: countdownPulse 0.6s ease-out infinite;
}

#levelUpMessage {
  font-family: var(--bd-font-pixel);
  font-size: 30px;
  color: var(--bd-accent);
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.72);
}

/* Pause-Menü */
#pauseModal {
  animation: settingsOverlayIn 0.25s ease;
}

.pause-menu {
  max-width: 340px;
  text-align: center;
}

/* Hold-Swap Pulse */
@keyframes holdPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.1); box-shadow: 0 0 18px rgba(162, 76, 255, 0.55); }
  100% { transform: scale(1); }
}

.piece-card-hold.hold-pulse {
  animation: holdPulse 0.25s ease-out;
}

@keyframes countdownPulse {
  0% { transform: scale(0.5); opacity: 0; }
  20% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

/* Mode select footer shortcuts */
.mode-select-footer {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.mode-footer-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  color: rgba(255, 255, 255, 0.6);
  font-family: inherit;
  font-size: 0.82em;
  padding: 7px 16px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.mode-footer-btn:hover {
  border-color: var(--bd-accent);
  color: var(--bd-text);
  background: rgba(162, 76, 255, 0.12);
}
