:root {
  --block-bg: #10151f;
  --block-panel: #182030;
  --block-line: #2d3a50;
  --block-mint: #58d6b4;
  --block-coral: #ff6f7d;
  --block-gold: #f6c85f;
  --block-blue: #5ba7ff;
  --block-ink: #f8fbff;
}

.play-area {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 12px;
  background:
    radial-gradient(circle at 18% 16%, rgba(88, 214, 180, .28), transparent 24%),
    radial-gradient(circle at 84% 18%, rgba(255, 111, 125, .24), transparent 23%),
    linear-gradient(135deg, #111827 0%, #17202f 48%, #10251f 100%);
  overflow: hidden;
}

.block-stage {
  width: min(100%, 620px);
  height: min(100%, calc(100svh - 94px));
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  gap: 10px;
}

.board-shell {
  position: relative;
  height: 100%;
  max-height: 820px;
  aspect-ratio: 1 / 2;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .03));
  box-shadow: 0 24px 70px rgba(0, 0, 0, .36), inset 0 1px 0 rgba(255, 255, 255, .15);
  overflow: hidden;
}

#game-board {
  display: block;
  width: 100%;
  height: 100%;
  background: #111723;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  background: rgba(12, 17, 27, .78);
  color: var(--block-ink);
  text-align: center;
}

.overlay strong {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

.overlay span {
  color: #c7d3e4;
  font-size: 14px;
}

.stats-panel dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 8px 0 6px;
}

.stats-panel div {
  min-width: 0;
  padding: 8px 6px;
  border: 1px solid #dce6e2;
  border-radius: 8px;
  background: #f7fbf8;
  text-align: center;
}

.stats-panel dt {
  color: #6a7a77;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stats-panel dd {
  margin: 2px 0 0;
  color: #223130;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

#status-text {
  min-height: 34px;
  margin: 5px 0 0;
  color: #607370;
  font-size: 12px;
  line-height: 1.35;
}

.preview-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.preview-card {
  display: grid;
  place-items: center;
  min-height: 66px;
  border: 1px solid #dce6e2;
  border-radius: 8px;
  background: #f8fbff;
}

.preview-card canvas {
  width: 52px;
  height: 52px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.button-row button {
  padding: 9px 10px;
}

.touch-controls {
  display: grid;
  grid-template-columns: repeat(4, 52px);
  gap: 8px;
  justify-content: center;
}

.touch-controls button {
  width: 52px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 8px;
  background: rgba(248, 251, 255, .92);
  color: #162130;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(0, 0, 0, .2);
}

.touch-controls button:active {
  transform: translateY(1px);
}

@media (min-width: 901px) {
  .game-sidebar .panel p {
    font-size: 12px;
    line-height: 1.35;
  }

  .block-stage {
    height: min(100%, calc(100svh - 86px));
  }

  .touch-controls {
    opacity: .92;
  }
}

@media (max-width: 900px) {
  .game-layout > .game-sidebar {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
  }

  .game-sidebar .panel,
  .game-sidebar .button-row,
  .game-sidebar .note,
  .game-sidebar .intro {
    box-sizing: border-box;
    max-width: 100%;
  }

  .game-sidebar .panel {
    overflow: hidden;
  }

  .game-sidebar .panel p {
    overflow-wrap: anywhere;
  }

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

  .stats-panel div {
    padding-inline: 4px;
  }

  .preview-card canvas {
    width: 46px;
    height: 46px;
  }

  .block-stage {
    height: auto;
    width: min(100%, 430px);
  }

  .board-shell {
    width: min(100%, 360px);
    height: auto;
  }
}

@media (max-width: 620px) {
  .game-sidebar .intro,
  .game-sidebar .panel,
  .game-sidebar .button-row,
  .game-sidebar .note {
    width: 350px;
    max-width: 100%;
  }
}

@media (max-width: 430px) {
  .game-sidebar {
    overflow-x: hidden;
  }

  .game-sidebar .panel {
    padding-inline: 10px;
  }

  .button-row {
    gap: 6px;
  }

  .stats-panel dt {
    font-size: 8px;
    letter-spacing: 0;
  }

  .stats-panel dd {
    font-size: 16px;
  }

  .preview-card {
    min-height: 58px;
  }

  .touch-controls {
    grid-template-columns: repeat(4, minmax(42px, 1fr));
    width: 100%;
  }

  .touch-controls button {
    width: auto;
  }
}
