:root {
  --ink-950: #0b1622;
  --ink-800: #14324a;
  --ink-700: #215275;
  --cyan-500: #58d5ff;
  --amber-500: #ffbf69;
  --mint-500: #8cff8a;
  --panel: rgba(245, 251, 255, 0.9);
  --line: rgba(11, 22, 34, 0.18);
  --shadow: 0 20px 46px rgba(11, 22, 34, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Saira", sans-serif;
  color: var(--ink-950);
  background:
    radial-gradient(circle at 18% 12%, rgba(88, 213, 255, 0.36), transparent 30%),
    radial-gradient(circle at 84% 14%, rgba(255, 191, 105, 0.44), transparent 34%),
    linear-gradient(145deg, #c9eef9, #dff4ea 58%, #ffe4c2);
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to right, rgba(11, 22, 34, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(11, 22, 34, 0.06) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.62), transparent 86%);
}

.tetris-shell {
  width: min(1240px, 94vw);
  margin: 20px auto 34px;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 2.1fr) minmax(280px, 1fr);
  position: relative;
  z-index: 1;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  animation: rise-in 0.5s ease both;
}

.top-panel,
.stats-panel {
  grid-column: 1 / -1;
}

.top-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
}

.kicker {
  margin: 0;
  color: var(--ink-700);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.76rem;
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Righteous", cursive;
  letter-spacing: 0.02em;
  color: #1d4868;
}

h1 {
  margin-top: 4px;
  font-size: clamp(1.5rem, 2.8vw, 2.2rem);
  line-height: 1.1;
}

.subtitle {
  margin: 8px 0 0;
  color: #2f5f84;
  max-width: 56ch;
}

.action-btn {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  background: linear-gradient(95deg, #44c7f3, #7ce1ff);
  color: #08314b;
  font-family: "Righteous", cursive;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease;
}

.action-btn:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
}

.stats-panel {
  padding: 10px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.stat {
  border: 1px solid rgba(11, 22, 34, 0.12);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.58);
}

.stat span {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #3a6489;
  font-weight: 700;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.04rem;
}

.arena-panel {
  position: relative;
  overflow: hidden;
  padding: 12px;
}

#tetrisCanvas {
  display: block;
  width: min(100%, 520px);
  max-height: 76vh;
  margin: 0 auto;
  border-radius: 12px;
  border: 1px solid rgba(11, 22, 34, 0.24);
  background: #10283c;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.overlay {
  position: absolute;
  inset: 12px;
  display: none;
  place-items: center;
  text-align: center;
  border-radius: 12px;
  background: rgba(8, 23, 36, 0.78);
  color: #eef9ff;
  padding: 20px;
}

.overlay.show {
  display: grid;
}

.overlay h2 {
  font-size: clamp(1.2rem, 2.8vw, 1.85rem);
  color: #b4fbff;
}

.overlay p {
  margin-top: 8px;
  max-width: 38ch;
}

.side-panel {
  padding: 16px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.preview-stack {
  display: grid;
  gap: 10px;
}

.preview-panel {
  border: 1px solid rgba(11, 22, 34, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.54);
  padding: 10px;
}

#nextCanvas,
#holdCanvas {
  display: block;
  width: 100%;
  max-width: 180px;
  margin-top: 8px;
  border-radius: 10px;
  border: 1px solid rgba(11, 22, 34, 0.18);
  background: #122a3f;
}

.side-copy {
  margin: 7px 0 0;
  color: #2f587b;
  line-height: 1.34;
}

.touch-controls {
  border-top: 1px solid rgba(11, 22, 34, 0.16);
  padding-top: 14px;
}

.touch-grid {
  margin-top: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.touch-btn {
  border: 0;
  border-radius: 10px;
  padding: 11px;
  font-family: "Saira", sans-serif;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  color: #1a3f5f;
  background: linear-gradient(120deg, #d7f5ff, #d2f8dc);
}

.touch-btn.strong {
  background: linear-gradient(120deg, var(--amber-500), #ffd59a);
  color: #4d2b09;
}

@keyframes rise-in {
  from {
    transform: translateY(10px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 1040px) {
  .tetris-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-row: 4;
  }

  .preview-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #nextCanvas,
  #holdCanvas {
    max-width: 220px;
  }
}

@media (max-width: 860px) {
  .top-panel {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #tetrisCanvas {
    max-height: none;
  }
}
