/* Inlay's own styles, prefixed p-, built from Bench's tokens. Bench itself is untouched. */

:root {
  /* A warm stone board in light mode, so it sits with the paper rather than reading as concrete. */
  --p-board-a: color-mix(in srgb, var(--surface-sunken) 30%, var(--border-strong) 70%);
  --p-board-b: color-mix(in srgb, var(--surface-sunken) 55%, var(--border-strong) 45%);
  --p-board-edge: color-mix(in srgb, var(--surface-sunken) 10%, var(--border-strong) 90%);
  /* The lines a drop would clear: a copper wash over the blocks, and an outline round each line. */
  --p-lit: color-mix(in srgb, var(--accent) 22%, transparent);
  --p-lit-edge: var(--accent);
  /* One accent family: the confirm buttons take the marble's brown instead of Bench's green. */
  --confirm: #7a4520;
  --confirm-ink: #6e3d1b;
  --on-confirm: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* Warmed slightly with the accent, so the stone sits with the brown marble. */
    --p-board-a: var(--p-dark-board-a);
    --p-board-b: var(--p-dark-board-b);
    --p-board-edge: var(--p-dark-board-edge);
    --confirm: #d39a5e;
    --confirm-ink: #e0ae78;
    --on-confirm: #1c1208;
  }
}
/* The same, when the theme is set to Dark in Settings rather than by the phone. */
:root[data-theme="dark"] {
  --p-board-a: var(--p-dark-board-a);
  --p-board-b: var(--p-dark-board-b);
  --p-board-edge: var(--p-dark-board-edge);
  --confirm: #d39a5e;
  --confirm-ink: #e0ae78;
  --on-confirm: #1c1208;
}
/* The dark board: a lighter, warm stone so it doesn't read as near-black (Bench's ink is light in
   dark mode, so more ink means lighter). */
:root {
  --p-dark-board-a: color-mix(in srgb, color-mix(in srgb, var(--surface-sunken) 48%, var(--ink) 52%) 94%, var(--accent));
  --p-dark-board-b: color-mix(in srgb, color-mix(in srgb, var(--surface-sunken) 55%, var(--ink) 45%) 94%, var(--accent));
  --p-dark-board-edge: color-mix(in srgb, var(--surface-sunken) 40%, var(--ink) 60%);
}

/* Numbers in the sans face with even-width figures: monospace read like a terminal. */
.p-num {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

html, body {
  overscroll-behavior: none;
}

.p-page {
  max-width: 560px;
  margin-inline: auto;
}
/* Bench widens the page padding on laptops; the game keeps it constant so the board sizing holds. */
.b-page.p-page {
  padding: var(--space-4);
}

.p-header-logo {
  width: 24px;
  height: 24px;
  margin-left: var(--space-3);
  border-radius: var(--radius-sm);
  flex: none;
}

.p-panel {
  margin-top: var(--space-4);
}

.p-error {
  color: var(--decline-ink);
}

/* ---- Who's playing ---- */

.p-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding-top: var(--space-8);
  text-align: center;
}
.p-welcome form, .p-known {
  width: 100%;
  max-width: 320px;
  text-align: left;
}
.p-logo {
  border-radius: var(--radius-lg);
}
.p-known .b-btn {
  min-height: 56px;
  font-size: 17px;
}

/* A one-line text field, matching Bench's textarea. */
.p-input {
  width: 100%;
  min-height: var(--size-target);
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
.p-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

/* ---- The game: a column pinned to the bottom, so the board and tray sit in thumb reach ---- */

.p-game {
  position: relative;
  width: 100%;
  min-height: calc(100dvh - var(--size-header) - var(--space-8));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.p-scores {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}
.p-scores > div {
  display: flex;
  flex-direction: column;
}
.p-score {
  font-size: 32px;
  line-height: 38px;
}
.p-best {
  font-size: 20px;
  line-height: 28px;
}
.p-scores .b-label {
  line-height: 16px;
}
.p-right {
  align-items: flex-end;
}
.p-beaten {
  color: var(--accent-ink);
}

.p-board-wrap {
  position: relative;
}
.p-board {
  display: block;
  border-radius: var(--radius-lg);
  background: var(--p-board-edge);
  touch-action: none;
}

/* Points rise from the line that cleared: the total, and what earned it underneath. */
.p-popup {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  white-space: nowrap;
  color: var(--accent-ink);
  text-shadow: 0 0 8px color-mix(in srgb, var(--surface) 90%, transparent), 0 0 2px var(--surface);
  opacity: 0;
}
.p-popup__points {
  font-size: 26px;
  line-height: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.p-popup__why {
  font-size: 15px;
  line-height: 18px;
  font-weight: 600;
}
.p-popup--show {
  animation: p-rise 900ms ease-out;
}
@keyframes p-rise {
  0% { opacity: 0; transform: translate(-50%, -50%); }
  12% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, calc(-50% - 32px)); }
}

.p-tray {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  width: 100%;
  touch-action: none;
}
.p-tray {
  margin-top: var(--space-1);
}
/* Each slot is a faint well, so three slots read as three even when some are empty. Script sets
   the height from the space available. */
.p-slot {
  display: block;
  width: 100%;
  height: 112px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--border) 45%, transparent);
  touch-action: none;
  cursor: grab;
}

.p-under {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 72px;
}
.p-hold {
  position: relative;
}
.p-slot--hold {
  width: 96px;
  height: 72px;
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  box-shadow: inset 0 0 0 1px var(--border);
}
.p-hold__label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.p-slot--target {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.p-streak {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
}
.p-streak__left {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
}
.p-pulse {
  animation: p-pulse 200ms ease-out;
}
@keyframes p-pulse {
  50% { transform: scale(1.12); }
}

.p-hint {
  text-align: center;
  margin: 0;
}

/* The piece under your finger. */
.p-drag {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 10;
  transform-origin: 0 0;
}
.p-drag--moving {
  transition: transform 100ms ease-out;
}
.p-drag--return {
  transition: transform 180ms ease-out;
}

/* ---- Game over: a sheet over the lower half, with the board still visible above ---- */

.p-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-3);
  padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgb(0 0 0 / 0.18);
  animation: p-sheet 250ms ease-out;
  z-index: 5;
}
@keyframes p-sheet {
  from { transform: translateY(100%); }
}
.p-newbest {
  color: var(--accent-ink);
}
.p-final {
  font-size: 48px;
  line-height: 56px;
}
.p-sheet__head {
  display: flex;
  flex-direction: column;
}

/* ---- Stats ---- */

.p-setting {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.p-setting__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.p-player {
  font-size: 20px;
  font-weight: 650;
}
.p-games-head {
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
}
.p-stats-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.p-list {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-6);
}
.p-list li::marker {
  color: var(--ink-muted);
  font-size: 13px;
}
.p-list li {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}
.p-list__score {
  display: block;
  font-size: 20px;
  line-height: 26px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.p-list__meta {
  display: block;
  color: var(--ink-muted);
  font-size: 13px;
}
.p-options {
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
}

@media (prefers-reduced-motion: reduce) {
  .p-popup--show, .p-pulse, .p-sheet { animation-duration: 1ms; }
  .p-drag--moving, .p-drag--return { transition-duration: 1ms; }
}

/* Bench sets key/value figures in mono; the game uses the sans figures throughout. */
.b-kv dd.p-num {
  font-family: var(--font-sans);
}

/* The nudge when the only way on is to park the last piece, beside the hold it points at. */
.p-under__left {
  flex: 1;
  padding-right: var(--space-3);
}
.p-stuck {
  margin: 0;
  color: var(--accent-ink);
  font-weight: 600;
}
