/* Tetris - responsive layout, desktop + narrow mobile. */

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: radial-gradient(circle at 50% 0%, #1b2340 0%, #0d1021 55%, #070810 100%);
  color: #e8ecf7;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
}

.game {
  width: 100%;
  max-width: 720px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0 auto;
}

.title {
  text-align: center;
  font-size: 28px;
  letter-spacing: 8px;
  text-transform: uppercase;
  margin: 4px 0 0;
  color: #9fb4ff;
  text-shadow: 0 0 18px rgba(96, 130, 255, 0.55);
}

.layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: center;
}

.board-wrap {
  position: relative;
  line-height: 0;
  flex: 0 1 320px;
  min-width: 0;
}

#board {
  width: 100%;
  height: auto;
  display: block;
  background: #0a0d1c;
  border: 2px solid #34406b;
  border-radius: 6px;
  box-shadow: 0 0 24px rgba(70, 100, 220, 0.25), inset 0 0 30px rgba(0, 0, 0, 0.6);
}

.status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 16, 0.72);
  border-radius: 6px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 1px;
  text-align: center;
  padding: 12px;
  line-height: 1.5;
}

.status.hidden {
  display: none;
}

.status.paused {
  color: #ffd76a;
}

.status.over {
  color: #ff6b6b;
}

.side {
  flex: 0 1 220px;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hud {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid #2c3560;
  border-radius: 6px;
  padding: 8px 12px;
}

.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #93a0c9;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.next-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid #2c3560;
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#next {
  background: #0a0d1c;
  border-radius: 4px;
  max-width: 100%;
  height: auto;
}

.controls-desktop .controls-title {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #93a0c9;
}

.controls-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 14px;
}

kbd {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  background: #1c2342;
  border: 1px solid #3a4678;
  border-bottom-width: 3px;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 12px;
  color: #c7d2ff;
}

.scoring {
  font-size: 12px;
  line-height: 1.6;
  color: #8b96bd;
  margin: 0;
}

/* Touch controls: hidden on wide pointers, shown on narrow/touch layouts. */
.touch-controls {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.touch-controls button {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid #3a4678;
  background: #1c2342;
  color: #c7d2ff;
  font-size: 22px;
  touch-action: manipulation;
}

.touch-controls button:active {
  background: #2c3560;
  transform: scale(0.95);
}

.touch-row {
  display: flex;
  gap: 10px;
}

.touch-row #btn-pause {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid #3a4678;
  background: #1c2342;
  color: #c7d2ff;
  font-size: 18px;
}

.touch-row #btn-restart {
  width: auto;
  height: 58px;
  padding: 0 16px;
  border-radius: 29px;
  border: 1px solid #3a4678;
  background: #1c2342;
  color: #c7d2ff;
  font-size: 15px;
}

@media (pointer: coarse), (max-width: 640px) {
  .touch-controls {
    display: flex;
    flex-wrap: wrap;
  }

  .layout {
    flex-direction: column;
    align-items: center;
  }

  .board-wrap {
    flex-basis: auto;
    width: min(92vw, 320px);
  }

  .side {
    flex-basis: auto;
    width: min(92vw, 320px);
  }

  .hud {
    flex-direction: row;
  }

  .stat {
    flex: 1;
    justify-content: center;
    gap: 8px;
  }

  .stat-value {
    font-size: 17px;
  }

  .next-box {
    flex-direction: row;
    justify-content: space-around;
  }

  .controls-desktop .scoring {
    display: none;
  }
}

@media (max-width: 360px) {
  .game {
    padding: 8px;
  }

  .title {
    font-size: 22px;
    letter-spacing: 5px;
  }
}
