/* Falling Blocks — Banked Clears. Mobile-first, flat dark theme.
 * Works at 320px. No Tetris-like theming. */

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

:root {
  --bg: #0a0a12;
  --panel: #15151f;
  --panel-light: #20202e;
  --text: #e8e8f0;
  --text-dim: #8888a0;
  --accent: #2ec4b6;
  --accent-hot: #ffbf69;
  --danger: #ef476f;
  --radius: 8px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  touch-action: manipulation;
}

.wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 10px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* ---- Header ---- */
.header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.title .accent { color: var(--accent); }

.subtitle {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 400;
  margin-top: 2px;
}

/* ---- Stats bar ---- */
.stats {
  width: 100%;
  display: flex;
  gap: 6px;
}

.stat {
  flex: 1;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 6px 8px;
  text-align: center;
  border: 1px solid var(--panel-light);
}

.stat-label {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 1px;
}

.stat-value {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat.queued .stat-value { color: var(--accent-hot); }
.stat.mult .stat-value { color: var(--accent); }

/* ---- Game area ---- */
.game-area {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}

#fb-canvas {
  display: block;
  border-radius: var(--radius);
  border: 2px solid var(--panel-light);
  background: var(--panel);
  touch-action: none;
  max-width: 100%;
  height: auto;
}

/* ---- Bank button ---- */
.bank-btn {
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #0a0a12;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s, transform 0.06s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.bank-btn:active {
  transform: scale(0.98);
  background: #25a99c;
}

.bank-btn:disabled {
  background: var(--panel-light);
  color: var(--text-dim);
  cursor: default;
}

.bank-hint {
  width: 100%;
  text-align: center;
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: -2px;
}

/* ---- Popup ---- */
.popup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(10, 10, 18, 0.92);
  color: var(--accent-hot);
  font-size: 1rem;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
  text-align: center;
  z-index: 5;
}

.popup.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ---- Game over overlay ---- */
.message {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(10, 10, 18, 0.85);
  border-radius: var(--radius);
  z-index: 10;
}

.message.visible { display: flex; }

.message-text {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  padding: 0 16px;
}

.retry-btn {
  padding: 10px 28px;
  font-size: 1rem;
  font-weight: 700;
  color: #0a0a12;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.retry-btn:active { transform: scale(0.97); }

/* ---- Controls hint ---- */
.controls {
  width: 100%;
  font-size: 0.68rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
}

.controls kbd {
  display: inline-block;
  background: var(--panel-light);
  color: var(--text);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.65rem;
  font-family: inherit;
}

.restart-link {
  color: var(--text-dim);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  font-size: inherit;
  font-family: inherit;
}

/* ---- Footer ---- */
.footer {
  width: 100%;
  margin-top: 8px;
  font-size: 0.65rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.6;
}

.footer a { color: var(--text-dim); text-decoration: underline; }

/* ---- Responsive: 320px ---- */
@media (max-width: 340px) {
  .wrap { padding: 8px 6px 16px; gap: 8px; }
  .title { font-size: 1.15rem; }
  .stat { padding: 5px 4px; }
  .stat-label { font-size: 0.55rem; }
  .stat-value { font-size: 0.9rem; }
  .bank-btn { padding: 12px; font-size: 0.95rem; }
  .controls { font-size: 0.62rem; }
}
