:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #050711;
  color: #f8fafc;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 72px 18px 24px;
  background:
    radial-gradient(circle at 20% 12%, rgba(37, 99, 235, 0.35), transparent 28rem),
    radial-gradient(circle at 80% 24%, rgba(34, 211, 238, 0.18), transparent 24rem),
    linear-gradient(145deg, #050711 0%, #0f172a 55%, #111827 100%);
}

.back-link {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(125, 211, 252, 0.38);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  color: #f8fafc;
  text-decoration: none;
  font-weight: 800;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.3);
}

.back-link:hover {
  border-color: #facc15;
  color: #facc15;
}

.tetris-shell {
  width: min(100%, 980px);
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(260px, 1fr);
  gap: 22px;
  align-items: start;
}

.game-panel,
.score-panel {
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.82);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

.game-panel {
  padding: 18px;
}

.game-panel__top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.game-actions {
  display: flex;
  gap: 10px;
  align-items: end;
}

.game-actions label {
  display: grid;
  gap: 6px;
  color: #94a3b8;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.game-actions select {
  height: 44px;
  min-width: 118px;
  border: 1px solid rgba(125, 211, 252, 0.34);
  border-radius: 8px;
  padding: 0 10px;
  background: #020617;
  color: #f8fafc;
  font: inherit;
  font-weight: 800;
  outline: none;
}

.game-panel__top span {
  color: #7dd3fc;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: 2.4rem;
  line-height: 1;
}

h2 {
  color: #e2e8f0;
  font-size: 1rem;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: #facc15;
  color: #111827;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.24);
}

button:active {
  transform: translateY(1px);
}

#board {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1 / 2;
  display: block;
  margin: 0 auto;
  border: 1px solid rgba(125, 211, 252, 0.34);
  border-radius: 8px;
  background: #020617;
}

.score-panel {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.74);
}

.stat span {
  color: #94a3b8;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stat strong {
  color: #fff;
  font-size: 2rem;
}

#next {
  width: 120px;
  height: 120px;
  margin-top: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  background: #020617;
}

.help {
  display: grid;
  gap: 8px;
  color: #cbd5e1;
  line-height: 1.6;
}

.touch-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.touch-controls button {
  padding: 0;
  background: #2563eb;
  color: #fff;
  font-size: 1.1rem;
}

@media (max-width: 760px) {
  body {
    place-items: start center;
    padding: 72px 10px 18px;
  }

  .tetris-shell {
    grid-template-columns: 1fr;
  }

  .game-panel__top {
    align-items: stretch;
    flex-direction: column;
  }

  .game-actions {
    align-items: end;
  }

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

  .score-panel > div:nth-child(n + 4) {
    grid-column: 1 / -1;
  }

  .stat {
    min-height: 58px;
    padding: 10px;
    display: grid;
    gap: 4px;
  }

  .stat strong {
    font-size: 1.45rem;
  }
}
