.tetris-shell-page {
  --tetris-bg-top: #09111d;
  --tetris-bg-mid: #101b30;
  --tetris-bg-bottom: #070d18;
  --tetris-panel: rgba(10, 17, 30, 0.84);
  --tetris-panel-strong: rgba(12, 20, 34, 0.94);
  --tetris-border: rgba(125, 167, 255, 0.18);
  --tetris-soft-border: rgba(255, 255, 255, 0.08);
  --tetris-ink: #eff6ff;
  --tetris-muted: #9baed1;
  --tetris-accent: #54d2ff;
  --tetris-accent-2: #ff915a;
  --tetris-good: #6bebb0;
  --tetris-warn: #ffd463;
  --tetris-danger: #ff718b;
  color: var(--tetris-ink);
  background:
    radial-gradient(circle at 14% 10%, rgba(84, 210, 255, 0.16), transparent 20%),
    radial-gradient(circle at 84% 12%, rgba(255, 145, 90, 0.16), transparent 22%),
    linear-gradient(180deg, var(--tetris-bg-top) 0%, var(--tetris-bg-mid) 45%, var(--tetris-bg-bottom) 100%);
}

.tetris-shell-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.8), transparent 88%);
  pointer-events: none;
}

.tetris-shell-page .navbar,
.tetris-shell-page .mobile-toolbar {
  --f7-bars-bg-color: rgba(6, 11, 20, 0.82);
  --f7-navbar-bg-color: rgba(6, 11, 20, 0.82);
  --f7-toolbar-bg-color: rgba(6, 11, 20, 0.88);
  border-color: rgba(255, 255, 255, 0.08);
}

.tetris-shell-page .navbar .title,
.tetris-shell-page .navbar .link,
.tetris-shell-page .mobile-toolbar .link-active {
  color: var(--tetris-ink);
}

.tetris-shell-page .mobile-toolbar .link {
  color: var(--tetris-muted);
}

.tetris-page-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.tetris-shortcuts,
.tetris-fallback-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.tetris-shortcut-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.tetris-head .page-kicker,
.tetris-head .page-copy,
.tetris-shell-page .hero-copy,
.tetris-shell-page .page-copy,
.tetris-shell-page .card-tag,
.tetris-shell-page .powerup-list,
.tetris-shell-page .info-card p,
.tetris-shell-page .control-hint,
.tetris-shell-page .panel-hint {
  color: var(--tetris-muted);
}

.tetris-head h1,
.tetris-shell-page .info-card h2,
.tetris-controls-head h2,
.panel-head h2 {
  color: var(--tetris-ink);
}

.tetris-stage-card,
.tetris-info-card,
.tetris-panel,
.tetris-shell-page .info-card {
  border: 1px solid var(--tetris-border);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.06), transparent 26%),
    linear-gradient(180deg, rgba(10, 17, 30, 0.96), rgba(8, 14, 24, 0.92));
  box-shadow:
    0 20px 48px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(16px);
}

.tetris-stage-card {
  padding: 18px;
  border-radius: 32px;
}

.tetris-topbar,
.tetris-play-grid,
.tetris-controls-head,
.status-strip,
.panel-head {
  display: flex;
  gap: 14px;
}

.tetris-topbar {
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.tetris-stat-card {
  padding: 14px 16px;
  border-radius: 22px;
  border: 1px solid var(--tetris-soft-border);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.tetris-stat-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  color: var(--tetris-muted);
}

.tetris-stat-card strong {
  font-size: clamp(1.35rem, 4vw, 1.9rem);
  line-height: 1;
  color: #ffffff;
}

.tetris-stat-card.best-card {
  background: linear-gradient(135deg, rgba(84, 210, 255, 0.14), rgba(255, 145, 90, 0.12));
}

.tetris-action-stack {
  flex: 0 0 136px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tetris-shell-page .touch-button {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
  color: var(--tetris-ink);
  box-shadow: none;
}

.tetris-shell-page .touch-button.secondary {
  background: linear-gradient(135deg, rgba(84, 210, 255, 0.16), rgba(90, 135, 255, 0.16));
}

.tetris-shell-page .touch-button.accent {
  background: linear-gradient(135deg, #54d2ff, #3a86ff);
  color: #06111d;
}

.tetris-shell-page .touch-button.hard-drop {
  background: linear-gradient(135deg, rgba(255, 145, 90, 0.92), rgba(255, 105, 140, 0.92));
  color: #17080d;
}

.status-strip {
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(84, 210, 255, 0.2);
  background: rgba(84, 210, 255, 0.12);
  color: #bdf0ff;
  font-size: 0.78rem;
  font-weight: 800;
}

.status-pill[data-tone="good"] {
  border-color: rgba(107, 235, 176, 0.22);
  background: rgba(107, 235, 176, 0.14);
  color: #baf9d7;
}

.status-pill[data-tone="warn"] {
  border-color: rgba(255, 212, 99, 0.24);
  background: rgba(255, 212, 99, 0.14);
  color: #ffe9a0;
}

.status-pill[data-tone="danger"] {
  border-color: rgba(255, 113, 139, 0.24);
  background: rgba(255, 113, 139, 0.16);
  color: #ffc1cf;
}

.stage-copy {
  margin: 0;
  flex: 1 1 220px;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--tetris-muted);
}

.tetris-play-grid {
  align-items: stretch;
  margin-bottom: 16px;
}

.tetris-stage-shell {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 620px;
  padding: 14px;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    radial-gradient(circle at top, rgba(84, 210, 255, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(6, 11, 20, 0.92), rgba(5, 10, 18, 0.98));
  overflow: hidden;
}

.tetris-stage {
  width: 100%;
  height: min(72vh, 680px);
  min-height: 560px;
  touch-action: none;
}

.tetris-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.tetris-stage-overlay {
  position: absolute;
  inset: 14px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: rgba(4, 8, 14, 0.42);
  backdrop-filter: blur(8px);
}

.tetris-stage-overlay.hidden {
  display: none;
}

.tetris-overlay-card {
  width: min(100%, 320px);
  padding: 22px;
  border-radius: 26px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at top, rgba(84, 210, 255, 0.16), transparent 34%),
    linear-gradient(180deg, rgba(10, 17, 30, 0.98), rgba(8, 14, 24, 0.96));
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

.tetris-overlay-tag {
  margin: 0 0 8px;
  color: #bfefff;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tetris-overlay-card h2 {
  margin: 0 0 10px;
  font-size: 1.5rem;
  line-height: 1.1;
}

.tetris-overlay-card p {
  margin: 0;
  color: var(--tetris-muted);
  line-height: 1.65;
}

.tetris-overlay-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.tetris-side-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 180px;
}

.tetris-panel {
  padding: 16px;
  border-radius: 24px;
}

.tetris-fallback-card {
  padding: 16px;
  border-radius: 24px;
  border: 1px solid rgba(255, 113, 139, 0.24);
  background:
    radial-gradient(circle at top, rgba(255, 113, 139, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(34, 11, 20, 0.96), rgba(18, 8, 14, 0.94));
}

.tetris-fallback-card h2 {
  margin: 0 0 10px;
  color: #ffffff;
}

.tetris-fallback-card p {
  margin: 0;
  color: #d9b7c0;
  line-height: 1.6;
}

.panel-head {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 2px 0 0;
  font-size: 1.05rem;
}

.panel-hint {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tetris-next-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.tetris-next-cell {
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.tetris-next-cell.is-filled {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.03)),
    var(--piece-color, rgba(84, 210, 255, 0.6));
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow:
    0 0 18px rgba(84, 210, 255, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.compact-list li:last-child {
  margin-bottom: 0;
}

.tetris-controls-card {
  padding: 18px;
  border-radius: 26px;
  border: 1px solid var(--tetris-soft-border);
  background: rgba(255, 255, 255, 0.04);
}

.tetris-controls-head {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

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

.control-button {
  min-height: 54px;
}

#tetrisSoftDropButton {
  grid-column: span 1;
}

#tetrisHardDropButton {
  grid-column: span 2;
}

.tetris-info-grid {
  display: grid;
  gap: 16px;
}

.tetris-info-card {
  border-radius: 28px;
}

@media (min-width: 768px) {
  .tetris-info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .tetris-topbar,
  .tetris-play-grid {
    flex-direction: column;
  }

  .tetris-action-stack,
  .tetris-side-stack {
    width: 100%;
  }

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

@media (max-width: 520px) {
  .tetris-stage-card {
    padding: 14px;
  }

  .tetris-stage-shell {
    min-height: 0;
    padding: 10px;
  }

  .tetris-stage {
    height: min(66vh, 620px);
    min-height: 480px;
  }

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

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

  #tetrisHardDropButton,
  #tetrisSoftDropButton {
    grid-column: span 1;
  }
}

@media (max-width: 430px) {
  .tetris-page-content {
    gap: 14px;
  }

  .tetris-shortcuts,
  .tetris-fallback-actions {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 12px;
  }

  .tetris-stage-card {
    padding: 12px;
    border-radius: 24px;
  }

  .tetris-topbar,
  .status-strip,
  .tetris-play-grid {
    gap: 10px;
  }

  .tetris-stat-card {
    padding: 12px;
    border-radius: 18px;
  }

  .tetris-action-stack {
    flex: 0 0 112px;
  }

  .tetris-stage-shell {
    padding: 10px;
    border-radius: 22px;
  }

  .tetris-stage {
    height: min(58vh, 540px);
    min-height: 420px;
  }

  .tetris-side-stack {
    gap: 10px;
  }

  .tetris-panel {
    padding: 12px;
    border-radius: 18px;
  }
}
