:root {
  color-scheme: light;
  --page: #f4f2ed;
  --panel: #ffffff;
  --ink: #171717;
  --muted: #66636a;
  --line: #dfddd7;
  --accent: #eb5b2d;
  --accent-dark: #d84e22;
  --board: #09090b;
  --empty: #15151a;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--page);
  color: var(--ink);
  font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
}

button {
  font: inherit;
}

.app {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 24px 18px 36px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 4px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 10px;
  font-size: clamp(34px, 7vw, 52px);
  line-height: 1;
  letter-spacing: 0;
}

.hero p {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px 16px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 390px) minmax(290px, 1fr);
  align-items: start;
  gap: 18px;
}

.board-wrap {
  position: relative;
  width: min(100%, 390px);
  border: 1px solid #27272a;
  border-radius: 8px;
  background: var(--board);
  padding: 8px;
  box-shadow: 0 18px 38px rgb(0 0 0 / 18%);
}

.board {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
}

.cell {
  aspect-ratio: 1;
  border: 1px solid rgb(39 39 42 / 80%);
  border-radius: 3px;
  background: var(--empty);
}

.cell.ghost {
  border-style: dashed;
  background: transparent;
}

.cell.i {
  border-color: #a5f3fc;
  background: #22d3ee;
  box-shadow: inset 0 -3px 0 rgb(8 145 178 / 50%);
}

.cell.j {
  border-color: #bfdbfe;
  background: #3b82f6;
  box-shadow: inset 0 -3px 0 rgb(29 78 216 / 50%);
}

.cell.l {
  border-color: #fde68a;
  background: #fbbf24;
  box-shadow: inset 0 -3px 0 rgb(180 83 9 / 45%);
}

.cell.o {
  border-color: #fef3c7;
  background: #fde047;
  box-shadow: inset 0 -3px 0 rgb(202 138 4 / 45%);
}

.cell.s {
  border-color: #a7f3d0;
  background: #34d399;
  box-shadow: inset 0 -3px 0 rgb(4 120 87 / 45%);
}

.cell.t {
  border-color: #f5d0fe;
  background: #d946ef;
  box-shadow: inset 0 -3px 0 rgb(162 28 175 / 45%);
}

.cell.z {
  border-color: #fecdd3;
  background: #f43f5e;
  box-shadow: inset 0 -3px 0 rgb(190 18 60 / 45%);
}

.cell.ghost.i {
  border-color: rgb(103 232 249 / 65%);
}

.cell.ghost.j {
  border-color: rgb(147 197 253 / 65%);
}

.cell.ghost.l {
  border-color: rgb(252 211 77 / 65%);
}

.cell.ghost.o {
  border-color: rgb(253 224 71 / 65%);
}

.cell.ghost.s {
  border-color: rgb(110 231 183 / 65%);
}

.cell.ghost.t {
  border-color: rgb(240 171 252 / 65%);
}

.cell.ghost.z {
  border-color: rgb(253 164 175 / 65%);
}

.overlay {
  position: absolute;
  inset: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgb(9 9 11 / 78%);
  backdrop-filter: blur(4px);
}

.overlay.hidden {
  display: none;
}

.dialog {
  width: min(230px, 80%);
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
  text-align: center;
  box-shadow: 0 15px 30px rgb(0 0 0 / 25%);
}

.dialog h2 {
  font-size: 21px;
  font-weight: 900;
}

.dialog .button {
  width: 100%;
  margin-top: 16px;
}

.side-panel {
  display: grid;
  gap: 12px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat,
.next-card,
.controls {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stat {
  min-height: 78px;
  padding: 14px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.next-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
}

.next-card h2 {
  font-size: 18px;
  font-weight: 900;
}

.next-card p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.next-piece {
  display: grid;
  flex: 0 0 auto;
  width: 96px;
  height: 96px;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.preview-cell {
  aspect-ratio: 1;
  border: 1px solid transparent;
  border-radius: 3px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 44px 1fr;
  gap: 10px;
  padding: 16px;
}

.rotate {
  grid-column: 2;
}

.left {
  grid-column: 1;
}

.down {
  grid-column: 2;
}

.right {
  grid-column: 3;
}

.start {
  grid-column: 1 / 3;
}

.hard {
  grid-column: 3;
}

.reset {
  grid-column: 3;
}

.button,
.icon-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  transition:
    background 120ms ease,
    transform 120ms ease,
    border-color 120ms ease;
}

.button:hover,
.icon-button:hover {
  background: #f7f7f5;
  border-color: #c9c6bf;
}

.button:active,
.icon-button:active {
  transform: translateY(1px);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.button.primary:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 42px;
  font-size: 24px;
  line-height: 1;
}

@media (max-width: 820px) {
  .app {
    padding: 18px 16px 28px;
  }

  .hero {
    display: block;
  }

  .hero p {
    margin-top: 14px;
  }

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

  .board-wrap {
    justify-self: center;
  }
}

@media (max-width: 430px) {
  .app {
    padding-inline: 14px;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .next-card {
    align-items: flex-start;
  }

  .next-piece {
    width: 86px;
    height: 86px;
    padding: 10px;
  }
}
