/* Tactile 3D buttons for the game toolbars and side panels (Cryptograms, Kakuro, Nonogram).
   The raised edge is a solid box-shadow; pressing slides the face down onto it, so the
   button never changes size and nothing around it moves. */
.pv-tactile {
  --tac-face: var(--surface-strong);
  --tac-face-hover: color-mix(in srgb, var(--accent-soft) 55%, var(--surface-strong));
  --tac-border: color-mix(in srgb, var(--accent) 30%, var(--border));
  --tac-edge: color-mix(in srgb, var(--accent) 42%, var(--border));
  --tac-text: var(--accent-strong);
  --tac-icon: var(--accent);
  --tac-depth: 4px;

  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 0;
  min-height: 40px;
  margin: 0 0 var(--tac-depth);
  padding: 0 0.85rem;
  border: 2px solid var(--tac-border);
  border-radius: 13px;
  background: var(--tac-face);
  box-shadow: 0 var(--tac-depth) 0 var(--tac-edge);
  color: var(--tac-text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.1;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.08s ease,
    box-shadow 0.08s ease,
    background-color 0.15s ease;
}
.pv-tactile:hover:not(:disabled) {
  background: var(--tac-face-hover);
  border-color: var(--tac-border);
  color: var(--tac-text);
}
.pv-tactile:active:not(:disabled) {
  transform: translateY(var(--tac-depth));
  box-shadow: 0 0 0 var(--tac-edge);
}
.pv-tactile:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}
.pv-tactile:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pv-tactile__icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--tac-icon);
}
.pv-tactile__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* New puzzle / New game: the one solid action in the bar. */
.pv-tactile--primary {
  --tac-face: #7c3aed;
  --tac-face-hover: #8b4cf3;
  --tac-border: #6d28d9;
  --tac-edge: #4c1d95;
  --tac-text: #fff;
  --tac-icon: #fff;
}

/* Toggles (Kakuro Notes, Nonogram Fill / Mark): the active one stays pressed in. */
.pv-tactile.is-on,
.pv-tactile[aria-pressed="true"],
.pv-tactile[aria-checked="true"] {
  --tac-face: color-mix(in srgb, var(--accent-soft) 85%, var(--surface-strong));
  --tac-face-hover: var(--tac-face);
  --tac-border: var(--accent);
  transform: translateY(var(--tac-depth));
  box-shadow:
    0 0 0 var(--tac-edge),
    inset 0 2px 5px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* Kakuro's pad in Notes mode: the digits go small and dashed, ready to pencil in. */
.kk-pad.is-notes .pv-tactile {
  --tac-text: var(--text-muted);
  border-style: dashed;
}

/* Hint after the free hints are used up: an amber edge says it now costs coins. */
.pv-tactile.is-paid-hint {
  --tac-border: #e0b021;
  --tac-edge: #b7860b;
  --tac-icon: #b7860b;
  /* pv-player.css gives paid hints an inset ring; keep the raised edge instead. */
  box-shadow: 0 var(--tac-depth) 0 var(--tac-edge);
}
.pv-tactile.is-paid-hint:active:not(:disabled) {
  box-shadow: 0 0 0 var(--tac-edge);
}

[data-theme="dark"] .pv-tactile {
  --tac-face: #2a2142;
  --tac-face-hover: #352a54;
  --tac-border: #4d3d7d;
  --tac-edge: #171028;
  --tac-text: #f3e8ff;
  --tac-icon: #c4b5fd;
}
[data-theme="dark"] .pv-tactile--primary {
  --tac-face: #7c3aed;
  --tac-face-hover: #8b4cf3;
  --tac-border: #8b5cf6;
  --tac-edge: #3b1784;
  --tac-text: #fff;
  --tac-icon: #fff;
}
[data-theme="dark"] .pv-tactile.is-on,
[data-theme="dark"] .pv-tactile[aria-pressed="true"],
[data-theme="dark"] .pv-tactile[aria-checked="true"] {
  --tac-face: #3d2f6b;
  --tac-face-hover: #3d2f6b;
  --tac-border: #8b5cf6;
}
[data-theme="dark"] .pv-tactile.is-paid-hint {
  --tac-border: #c9971a;
  --tac-edge: #6b4e07;
  --tac-icon: #f5c542;
}

/* Cryptograms' action row under the quote: same buttons, evenly spaced. */
.cg-toolbar .pv-tactile {
  min-width: 6.5rem;
}

/* Phones: four buttons share one row, so the icon sits above a smaller label. */
@media (max-width: 560px) {
  .kk-controls .pv-tactile,
  .ng-controls .pv-tactile,
  .kk-tools .pv-tactile,
  .cg-toolbar .pv-tactile {
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    min-height: 50px;
    padding: 0.35rem 0.15rem;
    border-radius: 12px;
    font-size: 0.78rem;
    letter-spacing: -0.01em; /* "Hinweis (3)" still fits a 360px phone */
  }
  .kk-controls .pv-tactile__label,
  .ng-controls .pv-tactile__label,
  .kk-tools .pv-tactile__label,
  .cg-toolbar .pv-tactile__label {
    max-width: 100%;
  }
  /* Kakuro's tools sit under a 9-key pad: scale the labels on the narrowest phones so
     German "Rückgängig" stays whole. */
  .kk-tools .pv-tactile {
    font-size: min(0.78rem, 3.2vw);
  }
  .cg-toolbar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ---- Hint badge ----
   data-badge holds the free hints left or, once they're used up (data-paid="true"), the coin
   price. Paid hints show it at every size, so the label can stay a short "Hint" instead of
   "Indice (100c)", which doesn't fit a phone or small-tablet button. */
.pv-tactile[data-badge]:not([data-badge=""])::after {
  content: attr(data-badge);
  position: absolute;
  top: -8px;
  right: -8px;
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 2px solid var(--surface-strong);
  border-radius: 999px;
  background: #16a34a;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}
.pv-tactile[data-paid="true"][data-badge]:not([data-badge=""])::after {
  display: flex;
  background: #f59e0b;
  color: #3b2200;
}
.pv-tactile:disabled::after {
  opacity: 0.6;
}

/* ---- Icon-only toolbar on desktop ----
   A button row with .pv-iconbar shows icons only on desktop-width screens, where a mouse
   can hover: the label becomes a tooltip on hover / keyboard focus (and stays the button's
   accessible name), and Hint shows a badge with the free hints left, or the coin price.
   Phones and tablets keep the labelled buttons above, since touch has no hover. */
@media (min-width: 1025px) and (orientation: landscape), (min-width: 1200px) {
  .pv-iconbar .pv-tactile {
    flex: 0 0 auto;
    gap: 0;
    width: 46px;
    min-width: 46px;
    height: 42px;
    min-height: 42px;
    padding: 0;
  }
  .pv-iconbar .pv-tactile__icon {
    width: 21px;
    height: 21px;
  }
  .pv-iconbar .pv-tactile__label {
    position: absolute;
    top: calc(100% + var(--tac-depth) + 8px);
    left: 50%;
    z-index: 25;
    max-width: none;
    padding: 0.3rem 0.55rem;
    border-radius: 7px;
    background: #2a1d4a;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    overflow: visible;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(-3px);
    transition: opacity 0.12s ease, transform 0.12s ease;
  }
  .pv-iconbar .pv-tactile:first-child .pv-tactile__label {
    left: 0;
    transform: translateY(-3px);
  }
  .pv-iconbar .pv-tactile:last-child .pv-tactile__label {
    left: auto;
    right: 0;
    transform: translateY(-3px);
  }
  .pv-iconbar .pv-tactile:hover .pv-tactile__label,
  .pv-iconbar .pv-tactile:focus-visible .pv-tactile__label {
    opacity: 1;
    transform: translateX(-50%);
  }
  .pv-iconbar .pv-tactile:first-child:hover .pv-tactile__label,
  .pv-iconbar .pv-tactile:last-child:hover .pv-tactile__label,
  .pv-iconbar .pv-tactile:first-child:focus-visible .pv-tactile__label,
  .pv-iconbar .pv-tactile:last-child:focus-visible .pv-tactile__label {
    transform: none;
  }
  [data-theme="dark"] .pv-iconbar .pv-tactile__label {
    background: #f3e8ff;
    color: #22133f;
  }

  /* Icon-only: the hint badge is always shown (free hints left, or the coin price). */
  .pv-iconbar .pv-tactile[data-badge]:not([data-badge=""])::after {
    display: flex;
  }

  /* Side panels: the icon buttons share one row across the panel's width. */
  .kk-tools.pv-iconbar,
  .ng-modes.pv-iconbar,
  .ng-tools.pv-iconbar {
    display: flex;
    gap: 0.4rem;
  }
  .kk-tools.pv-iconbar .pv-tactile,
  .ng-modes.pv-iconbar .pv-tactile,
  .ng-tools.pv-iconbar .pv-tactile {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
  }
  /* Nonogram: Fill / Mark and Undo / Check sit side by side, as two groups. */
  .ng-side {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 0.8rem;
  }
  .ng-side > .ng-stats {
    grid-column: 1 / -1;
  }
  .pv-iconbar .ng-mode__ico {
    width: 19px;
    height: 19px;
    font-size: 19px;
  }
}

/* ---- Stat chips (Kakuro, Nonogram): Time / Best / Cells or Filled ----
   Wider screens show the text label. Phones swap the label for an icon so the chip
   stays on one line in every language ("Tiempo: 14:50.3" no longer wraps); the label
   is still read out by screen readers. */
.pv-chip__icon {
  display: none;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: var(--accent);
}
@media (max-width: 560px) {
  .pv-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    min-width: 0;
    white-space: nowrap;
  }
  .pv-chip__icon {
    display: block;
  }
  .pv-chip__label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    border: 0;
  }
}
