:root {
  /* tune these if you want to more closely match global.css */
  --bg: #020617;
  --panel: #050816;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.18);
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --border: rgba(148, 163, 184, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}


body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #020617 0, #000 60%);
  color: var(--text-main);
  display: flex;
  justify-content: center;
  align-items: flex-start;   /* was center */
  padding: 16px;
}

.tetris-page {
  width: 100%;
  max-width: 960px;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.9));
  border-radius: 20px;
  padding: 18px 16px 20px;   /* a bit tighter for small screens */
  border: 1px solid var(--border);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(15, 23, 42, 0.9);
}


.tetris-header {
  text-align: left;
  margin-bottom: 18px;
}

.tetris-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tetris-header p {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tetris-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(220px, 1fr);
  gap: 18px;
  align-items: flex-start;
}

/* Game area card */
.tetris-game-card {
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.16), transparent 55%),
    radial-gradient(circle at bottom right, var(--accent-soft), transparent 60%),
    var(--panel);
  border-radius: 18px;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  display: flex;
  justify-content: center;
  align-items: center;
}

#tetris-canvas {
  width: 100%;
  max-width: 360px;
  height: auto;
  image-rendering: pixelated;
  background: rgba(15, 23, 42, 0.96);
  border-radius: 12px;
}

/* Sidebar */
.tetris-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tetris-panel {
  background: var(--panel);
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.tetris-panel h2 {
  margin: 0 0 4px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
}

#score,
#lines {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--accent);
}

#next-canvas {
  display: block;
  width: 100%;
  max-width: 120px;
  height: auto;
  image-rendering: pixelated;
  background: rgba(15, 23, 42, 0.96);
  border-radius: 10px;
  margin-top: 4px;
}

.tetris-help ul {
  list-style: none;
  padding-left: 0;
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.tetris-help li + li {
  margin-top: 2px;
}

/* Responsive */
@media (max-width: 768px) {
  .tetris-layout {
    grid-template-columns: 1fr;
  }

  .tetris-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .tetris-panel {
    flex: 1 1 140px;
  }

  .tetris-header h1 {
    font-size: 1.2rem;
  }

  .tetris-header p {
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  body {
    padding: 8px;
  }

  .tetris-page {
    padding: 12px 10px 14px;
    border-radius: 14px;
  }

  #tetris-canvas {
    max-width: 100%;
  }
}
/* Touch controls - hidden on desktop by default */
.tetris-touch {
  display: none;
  margin-top: 14px;
  gap: 8px;
  flex-direction: column;
}

.touch-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.touch-btn {
  flex: 1 1 0;
  max-width: 110px;
  padding: 10px 0;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: radial-gradient(circle at top, rgba(34, 197, 94, 0.18), rgba(15, 23, 42, 0.95));
  color: #e5e7eb;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}

.touch-btn:active {
  transform: translateY(1px) scale(0.98);
  background: rgba(34, 197, 94, 0.25);
}

/* Show controls on small screens */
@media (max-width: 768px) {
  .tetris-touch {
    display: flex;
  }
}
/* Back button */
.back-button {
  position: absolute;
  top: 18px;
  right: 22px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid rgba(148,163,184,0.4);
  background: rgba(15,23,42,0.85);
  color: #e5e7eb;
  cursor: pointer;
  z-index: 50;
  transition: 0.15s ease;
  backdrop-filter: blur(4px);
}

.back-button:hover {
  background: rgba(34,197,94,0.25);
  color: #bbf7d0;
  border-color: rgba(34,197,94,0.35);
}

.back-button:active {
  transform: scale(0.97);
}
