/* ==========================================================================
   Playable logo puzzle — /play
   Layered on top of css/logo-puzzle.css, which owns the board itself. Both
   stylesheets are needed; this one adds the input states and the page UI.
   ========================================================================== */

.tbyp--game {
  --tbyp-step: 190ms; /* snap, rather than the loader's stroll */

  /* White case, white seams, and the dead cell the same white as both — so
     the gap reads as genuinely empty rather than as one more dark tile. No
     recess shading on it either, or it would give itself away. */
  --tbyp-frame: #ffffff;
  --tbyp-tray: #ffffff;
  --tbyp-hole: #ffffff;
  --tbyp-recess: none;
  --tbyp-shadow: 0 1px 2px rgba(0, 0, 0, 0.16),
    inset 0 0 0 1px rgba(0, 0, 0, 0.1);

  /* Without this a vertical drag scrolls the page instead of moving a piece. */
  touch-action: none;
  cursor: default;
  /* The case is white on a white page, so it needs its own edge. */
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.09),
    inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* The tray's recess shadow reads as a smudge once the tray is white. */
.tbyp--game .tbyp__board {
  box-shadow: none;
}

.tbyp--game:focus-visible {
  outline: 3px solid #1f1e1c;
  outline-offset: 5px;
}

/* Only the pieces beside the hole can move; the cursor says which. */
.tbyp--game .tbyp__tile.is-movable {
  cursor: grab;
}

.tbyp--game .tbyp__tile.is-dragging {
  z-index: 2;
  cursor: grabbing;
}

/* The piece in motion turns coral (the brand's second colour), so it is
   obvious which one is travelling — and so it can never be mistaken for the
   empty cell now that the empty cell is white. */
.tbyp--game .tbyp__tile.is-moving .tbyp__face {
  background-image: none;
  background-color: #ff6b57;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Held rather than merely sliding: a little more lift. Ordered after the rule
   above because the two selectors are equally specific. */
.tbyp--game .tbyp__tile.is-dragging .tbyp__face {
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.28);
}

/* Poking a piece that has nowhere to go. */
.tbyp--game .tbyp__tile.is-stuck .tbyp__face {
  animation: tbyp-stuck 260ms ease;
}

@keyframes tbyp-stuck {
  0%,
  100% {
    transform: scale(var(--tbyp-seam));
  }
  25% {
    transform: scale(calc(var(--tbyp-seam) - 0.05));
  }
  60% {
    transform: scale(calc(var(--tbyp-seam) - 0.02));
  }
}

@media (prefers-reduced-motion: reduce) {
  .tbyp--game .tbyp__tile.is-stuck .tbyp__face {
    animation: none;
  }
}

/* ---------- page ---------- */

.play-stage {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
}

.play-hud {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 24px 0 0;
  font-variant-numeric: tabular-nums;
}

.play-hud div {
  text-align: center;
}

.play-hud dt {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  color: #6a6359;
}

.play-hud dd {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  color: #1f1e1c;
}

.play-hud dd small {
  font-size: 15px;
  font-weight: 500;
  color: #8a8378;
}

/* Past a limit the discount is gone; say so without shouting. Only the value
   turns, not the limit beside it. */
.play-hud .is-over {
  color: #c2412f;
}

/* ---------- the conditions ---------- */

.play-terms {
  width: 100%;
  max-width: 420px;
  margin: 26px auto 0;
  border-collapse: collapse;
  font-size: 14px;
}

.play-terms caption {
  caption-side: bottom;
  padding-top: 12px;
  font-size: 12px;
  /* Looser than the hint: this one wraps, and it was cramped. */
  line-height: 1.65;
  color: #8a8378;
  text-align: center;
}

.play-terms th,
.play-terms td {
  padding: 9px 10px;
  border-bottom: 1px solid #ece6d8;
  text-align: right;
  font-weight: 400;
  color: #4c463d;
}

.play-terms thead th {
  font-size: 11px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  color: #6a6359;
}

.play-terms th[scope='row'] {
  text-align: left;
  font-weight: 600;
  color: #1f1e1c;
}

.play-terms tbody tr.is-active th,
.play-terms tbody tr.is-active td {
  background: #fff1bf;
  color: #1f1e1c;
}

.play-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
}

.play-levels {
  display: inline-flex;
  padding: 4px;
  border: 1px solid #ece6d8;
  border-radius: 10px;
  background: #fff;
}

.play-levels button,
.play-reset {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #1f1e1c;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 16px;
  cursor: pointer;
}

.play-levels button:hover,
.play-reset:hover {
  background: #f4efe4;
}

.play-levels button[aria-pressed='true'] {
  background: #ffd400;
}

.play-reset {
  border: 1px solid #1f1e1c;
  background: #1f1e1c;
  color: #fbf8f1;
  padding: 11px 20px;
}

.play-reset:hover {
  background: #000;
}

.play-hint {
  margin: 16px 0 0;
  text-align: center;
  font-size: 13px;
  /* Tighter than the template's body leading: two short lines of instruction
     drifted apart at the inherited value. */
  line-height: 1.5;
  color: #8a8378;
}

/* ---------- the reward, kept on the page after the modal is dismissed ---- */

.play-reward {
  max-width: 460px;
  margin: 26px auto 0;
  padding: 18px 20px;
  border: 0;
  border-radius: 12px;
  background: #fff1bf;
  box-shadow: 0 12px 22px -14px rgba(60, 40, 0, 0.5);
  text-align: center;
}

.play-reward p {
  margin: 0 0 12px;
  font-size: 14px;
  color: #3d3831;
}

.play-code {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.play-code code {
  padding: 9px 16px;
  border: 1px dashed rgba(31, 30, 28, 0.4);
  border-radius: 8px;
  background: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: #1f1e1c;
}

.play-copy {
  border: 0;
  border-radius: 8px;
  background: #1f1e1c;
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
}

.play-copy:hover {
  background: #000;
}

.play-copy[data-copied='true'] {
  background: #1c7a3e;
}

/* ---------- the win modal's actions ---------- */

.play-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

/* One box for both, so primary and secondary come out exactly the same size
   rather than inheriting two different button styles from the template. */
.play-modal-actions a {
  flex: 0 0 auto;
  min-width: 178px;
  padding: 14px 24px;
  border: 2px solid transparent;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}

.play-modal-actions .is-primary {
  background: #ffd400;
  border-color: #ffd400;
  color: #1f1e1c;
}

.play-modal-actions .is-primary:hover {
  background: #1f1e1c;
  border-color: #1f1e1c;
  color: #ffd400;
}

.play-modal-actions .is-secondary {
  background: #ffffff;
  border-color: #ece6d8;
  color: #1f1e1c;
}

.play-modal-actions .is-secondary:hover {
  border-color: #1f1e1c;
}

/* Third in the hierarchy, so it reads as a link rather than a third button. */
.play-again {
  display: inline-block;
  margin-top: 20px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 14px;
  color: #625d55;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.play-again:hover {
  color: #1f1e1c;
}

/* ---------- the win dialog (native <dialog>, no Bootstrap) ---------- */

.play-dialog {
  width: min(460px, calc(100% - 32px));
  margin: auto;
  padding: 34px 28px 26px;
  border: 0;
  border-radius: 14px;
  background: #fbf8f1;
  color: #1f1e1c;
  text-align: center;
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.45);
}

.play-dialog::backdrop {
  background: rgba(31, 30, 28, 0.55);
}

.play-dialog h3 {
  margin-bottom: 10px;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.play-dialog p {
  margin-bottom: 18px;
  color: #4c463d;
}

.play-dialog .play-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: #625d55;
  cursor: pointer;
}

.play-dialog .play-close:hover {
  background: #f4efe4;
}

/* The result: moves and time, side by side */
.play-dialog .play-result {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin-bottom: 14px;
  color: #625d55;
  font-variant-numeric: tabular-nums;
}

.play-dialog .play-result b {
  display: block;
  font-size: 30px;
  line-height: 1.1;
  color: #1f1e1c;
}
