/* Swiped — Block Puzzle. Page chrome only; the board itself is canvas-drawn. */
:root {
  --bg1: #2b1055;
  --bg2: #7597de;
  --ink: #ffffff;
  --muted: #ffffffb3;
  --panel: #ffffff1a;
  --panel-strong: #ffffff26;
  /* Native device UI font (San Francisco / Segoe UI / Roboto) */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  /* Lock the page: no scroll/zoom/pull-to-refresh fighting the drag */
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  transition: background 600ms ease;
  /* fill the viewport incl. notches; fall back gracefully */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#app {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ---- HUD ---- */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.hud-right {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-left: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand .logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  box-shadow: 0 4px 14px #0000004d;
  flex: none;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
  gap: 4px;
}
.wordmark {
  font-weight: 800;
  font-size: 24px;
  letter-spacing: 0.2px;
  background: linear-gradient(180deg, #ffffff, #ffffffcc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.scores {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.score-box {
  position: relative;
  background: linear-gradient(180deg, #ffffff26, #ffffff12);
  border: 1px solid #ffffff2e;
  border-top-color: #ffffff4d;
  border-radius: 14px;
  padding: 7px 13px;
  min-width: 74px;
  text-align: center;
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  box-shadow: 0 4px 12px #00000026;
}
.score-box .label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin-bottom: 1px;
}
.score-box .value {
  font-size: 23px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.score-box.best .value { color: #ffe06a; }
.combo {
  position: absolute;
  top: -9px; right: -7px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #ff5d8f, #ff2d6f);
  box-shadow: 0 2px 8px #ff2d6f80;
  border-radius: 999px;
  padding: 2px 8px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 160ms, transform 160ms;
}
.combo.on { opacity: 1; transform: scale(1); }
.hud-btns {
  display: flex;
  gap: 6px;
}
.icon-btn {
  background: linear-gradient(180deg, #ffffff26, #ffffff12);
  border: 1px solid #ffffff2e;
  color: var(--ink);
  border-radius: 13px;
  width: 44px;
  height: 100%;
  min-height: 44px;
  font-size: 20px;
  cursor: pointer;
  transition: background 150ms, transform 100ms;
}
.icon-btn.muted { opacity: 0.55; }
.icon-btn:hover { background: var(--panel-strong); }
.icon-btn:active { transform: scale(0.92); }

/* ---- Stage / canvas ---- */
#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#game {
  display: block;
  touch-action: none;
  /* Never let the canvas visually overflow the stage (JS also height-fits it) */
  max-width: 100%;
  max-height: 100%;
}
.banner {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translate(-50%, -8px);
  background: #000000aa;
  color: #fff;
  font-weight: 800;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 15px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms, transform 220ms;
  white-space: nowrap;
}
.banner.show { opacity: 1; transform: translate(-50%, 0); }

.hint {
  text-align: center;
  font-size: 12px;
  /* High-contrast over the lighter theme gradients (WCAG AA) */
  color: #ffffffe6;
  text-shadow: 0 1px 2px #00000099;
  margin: 8px 4px 2px;
}

/* ---- Game-over overlay ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: #00000099;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.overlay.show { display: flex; animation: fade 200ms ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.card {
  background: linear-gradient(160deg, #2a2150, #1a1430);
  border: 1px solid #ffffff1f;
  border-radius: 20px;
  padding: 26px 24px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 20px 60px #00000080;
}
.card h2 { margin: 0 0 4px; font-size: 26px; }
.card .sub { margin: 0 0 18px; color: var(--muted); }
.final {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 22px;
}
.final > div {
  background: var(--panel);
  border-radius: 14px;
  padding: 12px 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.final .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted);
}
.final .big { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.primary {
  width: 100%;
  background: linear-gradient(90deg, #ff5d8f, #b366ff);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 15px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 100ms, filter 150ms;
}
.primary:hover { filter: brightness(1.07); }
.primary:active { transform: scale(0.97); }
.future-note { margin: 14px 0 0; font-size: 11px; color: #ffffff80; }
.ghost-btn {
  width: 100%;
  margin-top: 10px;
  background: transparent;
  color: var(--muted);
  border: 1px solid #ffffff33;
  border-radius: 14px;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms, color 150ms;
}
.ghost-btn:hover { background: #ffffff14; color: #fff; }
.ghost-btn:active { transform: scale(0.97); }

/* Shrink HUD so it stays on one row on small phones */
@media (max-width: 390px) {
  .brand .logo { width: 34px; height: 34px; }
  .wordmark { font-size: 21px; }
  .score-box { min-width: 60px; padding: 6px 9px; }
  .score-box .value { font-size: 20px; }
  .icon-btn { width: 40px; min-height: 40px; font-size: 18px; }
  .hud-right { gap: 6px; }
  .scores { gap: 6px; }
}

/* Honor reduced-motion: kill the CSS chrome animations. (The canvas effects
   are skipped separately in game.js via the same media query.) */
@media (prefers-reduced-motion: reduce) {
  body { transition: none; }
  .combo, .banner, .ghost-btn, .icon-btn, .primary { transition: none; }
  .overlay.show { animation: none; }
}
