.page-hero { padding: 18px 20px 6px; text-align: center; }
.page-hero h1 { font-size: 2rem; margin: 0 0 8px; }
.page-hero p { color: var(--text-muted); margin: 0; max-width: 480px; margin: 0 auto; }

.screen { padding: 18px 0 28px; }
/* The game screen is a fixed, non-scrolling single view (see body.no-scroll
   below) — generous marketing-page padding plus the footer would push the
   tray off the bottom of shorter phone viewports with no way to reach it,
   so this screen gets a tight padding budget and the footer is hidden
   for its duration (toggled in app.js). */
.screen.game-screen { padding: 10px 0 6px; }
.hero-block { text-align: center; margin-bottom: 16px; }
.hero-block h1 { font-size: 2.2rem; margin: 0 0 8px; }
.hero-block p { color: var(--text-muted); }
.title-block { padding-top: 18px; }
.title-icon { font-size: 3rem; line-height: 1; margin-bottom: 8px; }
.title-credit { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 18px; }

/* --- score bar --- */
.score-bar {
  max-width: 420px;
  margin: 20px auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.score-box { display: flex; flex-direction: column; align-items: flex-start; }
.score-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.score-value { font-size: 1.8rem; font-weight: 800; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1.1; }
.best-box { display: flex; flex-direction: column; gap: 2px; font-size: 0.78rem; color: var(--text-muted); text-align: right; }
.best-box strong { color: var(--text); }

/* --- board --- */
.board-wrap {
  display: flex;
  justify-content: center;
  padding: 0 12px;
}
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 3px;
  width: min(94vw, 420px);
  aspect-ratio: 1 / 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px;
  touch-action: none;
  position: relative;
}
.cell {
  border-radius: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  transition: background-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
.cell.filled {
  border-color: transparent;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18), inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
.cell.preview-ok {
  background: color-mix(in srgb, var(--accent) 45%, var(--bg));
  border-color: var(--accent);
}
.cell.preview-bad {
  background: color-mix(in srgb, #e5484d 35%, var(--bg));
  border-color: #e5484d;
}
.cell.clearing {
  animation: cellFlash 0.24s ease-in-out;
  box-shadow: 0 0 0 2px #fff, 0 0 14px 4px rgba(255, 255, 255, 0.8);
  z-index: 2;
}
@keyframes cellFlash {
  0% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.12); filter: brightness(1.6); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* --- tray --- */
.tray {
  display: flex;
  justify-content: center;
  gap: 10px;
  max-width: 420px;
  margin: 18px auto 40px;
  padding: 0 12px;
}
.tray-slot {
  flex: 1 1 0;
  aspect-ratio: 1 / 1;
  max-width: 132px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.tray-slot.empty::after {
  content: "";
}
.tray-slot.dragging-source { opacity: 0.25; }
.tray-piece-grid {
  display: grid;
  touch-action: none;
  cursor: grab;
}
.tray-piece-grid.grabbing { cursor: grabbing; }
.piece-cell {
  border-radius: 4px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18), inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
.piece-cell.empty { visibility: hidden; }

/* Applied to <body> permanently for the whole page — this is a fixed-layout
   game screen that never needs to scroll, and locking it stops mobile
   browsers from rubber-banding/pull-to-refreshing during a fast drag. */
body.no-scroll {
  overflow: hidden;
  height: 100vh;
  overscroll-behavior: none;
  touch-action: none;
}

/* --- drag ghost (follows pointer, snaps to grid over the board) --- */
.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  display: grid;
  pointer-events: none;
  z-index: 300;
  transition: left 0.05s ease, top 0.05s ease;
  will-change: left, top;
}
.drag-ghost .piece-cell {
  opacity: 0.92;
}
.drag-ghost.invalid .piece-cell {
  filter: grayscale(0.5) brightness(0.85);
}

/* --- modals --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 16, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 250;
  padding: 24px;
}
.modal {
  max-width: 380px;
  width: 100%;
  padding: 28px;
  text-align: center;
}
.modal h2 { margin: 0 0 12px; }
.modal-score { font-size: 1.05rem; margin: 0 0 4px; }
.modal-score strong { font-size: 1.3rem; color: var(--accent); }
.modal-best { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 20px; }
.modal .btn { width: 100%; justify-content: center; }
.howto-list {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.92rem;
  color: var(--text);
}
.howto-list li { line-height: 1.4; }

@media (max-width: 380px) {
  .score-value { font-size: 1.5rem; }
  .best-box { font-size: 0.7rem; }
}

/* The piece tray reaches the bottom edge on a phone, so the shared
   fullscreen button collides with it during play. Hiding it there was the
   first attempt and simply meant the button could not be found at all —
   moving it to the opposite corner keeps it reachable the whole time. */
body:has(#main-screen:not([hidden])) .game-fs-btn {
  bottom: auto !important;
  top: max(66px, calc(env(safe-area-inset-top) + 66px)) !important;
}
