* {
  box-sizing: border-box;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--bg-color);
  color: var(--text-color);
  font-family: "Courier New", monospace;
  display: flex;
  justify-content: center;
  /* ÄNDERUNG: Startet oben, damit Padding/Margin wirken können */
  align-items: flex-start;
  height: 100vh;
  /* ÄNDERUNG: Erlaubt Scrollen, falls das Handy sehr klein ist, verhindert aber hässliche Balken */
  overflow-y: auto;
  overflow-x: hidden;
  transition: background 0.3s;
  /* Ein Grund-Abstand nach oben für alle Geräte */
  padding-top: 10px;
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 450px;
  padding: 10px;
  /* Damit der Footer wirklich unten landet, wenn Platz da ist */
  min-height: calc(100vh - 60px);

  /* GLOBALER SCHUTZ GEGEN MARKIERUNGEN */
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

#ui-top {
  display: flex;
  gap: 15px;
  margin-bottom: 10px;
  width: 100%;
  justify-content: center;
}

.stat-box {
  text-align: center;
  min-width: 70px;
}

.label {
  font-size: 0.7rem;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 2px;
}

#stage {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: center;
}

#canvas-wrapper {
  position: relative;
  border: 4px solid var(--text-color);
  background: var(--grid-color);
}

canvas#tetris {
  display: block;
  /* Etwas verkleinert, damit auf Handys mehr Platz für Buttons bleibt */
  max-height: 55vh;
  width: auto;
}

#next-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--button-bg);
  padding: 8px;
  border-radius: 5px;
  border: 1px solid var(--text-color);
}

#next-preview canvas {
  background: var(--grid-color);
  margin-top: 4px;
  border: 1px solid var(--text-color);
}

#pause-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

#start-btn {
  padding: 15px 30px;
  font-size: 1.2rem;
  background: var(--text-color);
  color: var(--bg-color);
  border: none;
  cursor: pointer;
  font-weight: bold;
  font-family: inherit;
  border-radius: 4px;
}

#mobile-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 15px;
  width: 100%;
  max-width: 340px;
}

.ctrl-btn {
  background: var(--button-bg);
  border: 2px solid var(--text-color);
  color: var(--text-color);
  padding: 18px; /* Leicht reduziert für mehr Platz */
  font-size: 1.6rem;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

#btn-down {
  grid-column: 2;
}

#menu {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  width: 100%;
  justify-content: center;
}

.menu-btn {
  background: var(--button-bg);
  border: 1px solid var(--text-color);
  color: var(--text-color);
  font-size: 0.9rem;
  padding: 10px 15px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  user-select: none;
  -webkit-user-select: none;
}

#game-footer {
  margin-top: 10px; /* Expliziter Abstand nach oben */
  padding: 10px 0 20px 0;
  font-size: 0.65rem;
  opacity: 0.6;
  text-align: center;
  width: 100%;
}
