:root {
  --color-bg-start:    #f3e8ff;
  --color-bg-end:      #ffffff;
  --color-surface:     rgba(255,255,255,0.92);
  --color-text:        #151515;
  --color-muted:       #666666;
  --color-border:      #151515;
  --color-action-dark: #fbbf0e;
  --color-action-light:#ffe082;
  --color-accent-light:#dbc1f6;
  --radius-lg:         16px;
  --radius-full:       999px;
  --stroke:            1.5px;
  --shadow-card:       4px 4px 0 0 #151515;
  --shadow-btn:        3px 3px 0 0 rgba(0,0,0,0.15);
  --shadow-btn-active: -1px -1px 0 0 rgba(0,0,0,0.15);
  --font-display:      'Figtree', sans-serif;
  --font-body:         'Outfit', sans-serif;
  --cell:              30px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  color: var(--color-text);
  background: linear-gradient(to bottom, var(--color-bg-start), var(--color-bg-end));
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── Nav ─────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--color-action-dark);
  border-bottom: var(--stroke) solid var(--color-border);
  box-shadow: 0 3px 0 0 rgba(0,0,0,0.12);
}

.nav__inner {
  max-width: 960px;
  margin-inline: auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav__back {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.3px;
  opacity: 0.8;
  transition: opacity .12s;
}
.nav__back:hover { opacity: 1; }

.nav__title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* ── Page ────────────────────────────────────────── */
.game-page {
  max-width: 960px;
  margin-inline: auto;
  padding: 40px 24px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

/* ── Main grid ───────────────────────────────────── */
.grid {
  box-sizing: content-box;
  width: calc(var(--cell) * 10);
  height: calc(var(--cell) * 20);
  display: flex;
  flex-wrap: wrap;
  border: var(--stroke) solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  background-color: #f8f4ff;
  background-image:
    linear-gradient(rgba(21,21,21,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21,21,21,0.07) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
}

.grid div {
  width: var(--cell);
  height: var(--cell);
}

.tetromino {
  outline: 1.5px solid rgba(0,0,0,0.15);
  outline-offset: -1.5px;
}

/* ── Sidebar ─────────────────────────────────────── */
.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 160px;
}

.sidebar-panel {
  background: var(--color-surface);
  border: var(--stroke) solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px 20px;
}

.sidebar-label {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: 10px;
}

.sidebar-value {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1;
}

/* ── Mini grid (next piece) ──────────────────────── */
.mini-grid {
  box-sizing: content-box;
  width: calc(var(--cell) * 4);
  height: calc(var(--cell) * 4);
  display: flex;
  flex-wrap: wrap;
  border: var(--stroke) solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  background-color: #f8f4ff;
  background-image:
    linear-gradient(rgba(21,21,21,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21,21,21,0.07) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
}

.mini-grid div {
  width: var(--cell);
  height: var(--cell);
}

/* ── Button ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  border: var(--stroke) solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-action-dark);
  color: var(--color-text);
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: margin .12s ease, background-color .12s ease, box-shadow .12s ease;
}
.btn:hover { background: var(--color-action-light); }
.btn:active {
  margin: 2px 0 0 2px;
  box-shadow: var(--shadow-btn-active);
}

/* ── Controls hint ───────────────────────────────── */
.controls-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-muted);
}

.control-row kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 2px 6px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  background: white;
  border: var(--stroke) solid var(--color-border);
  border-radius: 4px;
  box-shadow: 0 2px 0 0 rgba(21,21,21,0.4);
  flex-shrink: 0;
}

/* ── Dev note ────────────────────────────────────── */
.dev-note.unfocused {
  filter: blur(2px);
  opacity: 0.4;
  transition: filter 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

.dev-note {
  margin-top: 40px;
  max-width: 640px;
  background: var(--color-surface);
  border: var(--stroke) solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dev-note__label {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.dev-note__body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text);
}

.dev-note__body code {
  font-family: monospace;
  font-size: 13px;
  background: var(--color-accent-light);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 600px) {
  :root { --cell: 22px; }
  .game-layout { flex-direction: column; align-items: center; }
  .game-sidebar { flex-direction: row; flex-wrap: wrap; min-width: unset; width: calc(var(--cell) * 10); }
  .sidebar-panel { flex: 1; min-width: 120px; }
}
