/* Scratch-off modal — below fixed navbar (72px), same idea as profiler_modal / card modal */

/* Scroll only inside .modal-body, not Bootstrap’s full-screen .modal (avoids background scroll / pull-to-refresh chaining) */
#scratchOffModal.modal {
  overflow-x: hidden;
  overflow-y: hidden;
  overscroll-behavior: none;
}

#scratchOffModal .modal-dialog.scratch-off-modal__dialog {
  --scratch-off-modal-top-offset: calc(72px + env(safe-area-inset-top));
  margin-top: calc(var(--scratch-off-modal-top-offset) + 0.5rem);
  margin-bottom: 0.5rem;
  margin-left: auto;
  margin-right: auto;
  max-width: min(42rem, calc(100vw - 1.5rem));
}

#scratchOffModal .modal-dialog.scratch-off-modal__dialog.modal-dialog-centered {
  align-items: flex-start;
  min-height: auto;
}

#scratchOffModal .modal-content.scratch-off-modal__content {
  max-height: calc(100dvh - var(--scratch-off-modal-top-offset) - 1.5rem);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-secondary, var(--bs-modal-bg));
  border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.12));
  color: var(--text-primary, inherit);
  box-shadow: var(--shadow-xl, none);
}

#scratchOffModal .scratch-off-modal__header {
  flex-shrink: 0;
  padding-right: 3rem;
  z-index: 2;
  background: var(--bg-tertiary, var(--bs-modal-header-bg, var(--bs-modal-bg)));
  border-bottom: 1px solid var(--border-primary, rgba(255, 255, 255, 0.12));
  color: var(--text-primary, inherit);
}

#scratchOffModal .scratch-off-modal__header .modal-title {
  color: var(--text-primary, inherit);
}

#scratchOffModal .scratch-off-modal__header-meta {
  max-width: min(62vw, 26rem);
}

#scratchOffModal .scratch-off-modal__session-totals {
  color: var(--text-primary, inherit);
}

#scratchOffModal .scratch-off-modal__close {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 0.75rem;
  margin: 0;
  filter: invert(1);
  opacity: 0.75;
}

#scratchOffModal .scratch-off-modal__close:hover {
  opacity: 1;
}

#scratchOffModal .scratch-off-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-secondary, transparent);
  color: var(--text-primary, inherit);
}

.scratch-off-modal__body {
  /* Bootstrap .row uses negative margins; keep paint inside rounded modal */
  min-width: 0;
}

.scratch-off-modal__frame {
  min-width: 0;
}

/* Extra breathing room when the panel is inside the modal (full-page uses .container) */
.scratch-off-modal .scratch-off-panel {
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.scratch-off-modal .scratch-off-header {
  padding-right: 0.25rem;
}

/* Scratch-off play page */
.scratch-off-page .scratch-off__cell {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.08));
  min-height: 7rem;
  transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

/* Finished panel — prize bbox (see JS) mostly cleared */
.scratch-off__cell.scratch-off__cell--done {
  box-shadow: 0 0 0 2px var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.55) !important;
}

.scratch-off__cell--done .scratch-off__canvas {
  opacity: 0.48;
  transition: opacity 0.2s ease;
}

.scratch-off__prize {
  z-index: 0;
  pointer-events: none;
  color: var(--text-primary);
  font-size: clamp(1.85rem, 5vw, 2.35rem);
  line-height: 1.2;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  max-width: 100%;
  padding: 0 0.25rem;
}

.scratch-off__claim-title {
  font-weight: 600;
}

.scratch-off__claim-total {
  font-size: inherit;
  font-weight: 700;
  opacity: 0.95;
}

.scratch-off__grid-wrap {
  min-height: 0;
}

/* Unstarted ticket: grid stays sharp; matte veil handles dimming */
.scratch-off--awaiting-start .scratch-off__grid {
  pointer-events: none;
  user-select: none;
}

.scratch-off__start-gate {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  border-radius: var(--bs-border-radius, 0.375rem);
  isolation: isolate;
}

/* Flat matte cover — same palette as modals/cards, no blur or highlight sheen */
.scratch-off__start-gate::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: color-mix(in srgb, var(--bg-secondary) 78%, transparent);
  border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
}

.scratch-off__start-gate .btn {
  position: relative;
  z-index: 1;
  min-width: 11rem;
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.35));
}

.scratch-off__start-gate[hidden] {
  display: none !important;
}

.scratch-off--awaiting-start .scratch-off__canvas {
  pointer-events: none;
}

.scratch-off__canvas {
  position: relative;
  z-index: 1;
  display: block;
  touch-action: none;
  pointer-events: auto;
  /* Do not set background-color: the silver layer is drawn in JS. A CSS background would sit
     under the bitmap and stay visible when destination-out clears pixels — hiding the prize. */
  background-color: transparent;
}

/* Scrollable modal body can steal touch scrolling; keep scratch gestures on the cells */
.scratch-off-modal .scratch-off__cell {
  touch-action: none;
}

/* Lightweight “up next” row — no scratch canvas until this play is first in the stack */
.scratch-off-stack-item--queued {
  background: var(--bg-tertiary, rgba(0, 0, 0, 0.2));
  border-style: dashed !important;
  border-color: var(--border-primary, rgba(255, 255, 255, 0.15)) !important;
  color: var(--text-secondary, var(--bs-secondary-color));
}

.scratch-off-stack-item--queued .text-body-secondary {
  color: var(--text-primary, inherit) !important;
}

.scratch-off-stack__session {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Roulette Spinner: colored cell backgrounds show through foil while scratching */
.scratch-off--roulette-spinners .scratch-off__cell--has-foil-art {
  min-height: 7rem;
}

.scratch-off--roulette-spinners .scratch-off__cell--has-foil-art > .scratch-off__canvas {
  position: absolute;
  inset: 0;
  height: 7rem !important;
  width: 100%;
}

.scratch-off--roulette-spinners .scratch-off__foil-art {
  z-index: 2;
}

.scratch-off--roulette-spinners .scratch-off__foil-main {
  z-index: 3;
}

.scratch-off--roulette-spinners .scratch-off__cell--spin .scratch-off__prize {
  font-size: clamp(1.85rem, 5vw, 2.35rem);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.scratch-off--roulette-spinners .scratch-off__cell--spin {
  background: linear-gradient(145deg, rgba(250, 204, 21, 0.45), rgba(180, 130, 20, 0.35)) !important;
}

.scratch-off--roulette-spinners .scratch-off__cell--roulette-red {
  background: linear-gradient(145deg, rgba(220, 38, 38, 0.72), rgba(127, 29, 29, 0.85)) !important;
}

.scratch-off--roulette-spinners .scratch-off__cell--roulette-black {
  background: linear-gradient(145deg, rgba(55, 65, 81, 0.88), rgba(17, 24, 39, 0.95)) !important;
}

.scratch-off--roulette-spinners .scratch-off__cell--roulette-green {
  background: linear-gradient(145deg, rgba(22, 163, 74, 0.72), rgba(21, 128, 61, 0.88)) !important;
}

.scratch-off--roulette-spinners .scratch-off__cell--roulette-red .scratch-off__prize,
.scratch-off--roulette-spinners .scratch-off__cell--roulette-black .scratch-off__prize,
.scratch-off--roulette-spinners .scratch-off__cell--roulette-green .scratch-off__prize,
.scratch-off--roulette-spinners .scratch-off__cell--spin .scratch-off__prize {
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
}

/* Done ring uses each cell's color (not default cyan) */
.scratch-off--roulette-spinners .scratch-off__cell--spin.scratch-off__cell--done {
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.55);
  border-color: rgba(250, 204, 21, 0.65) !important;
}

.scratch-off--roulette-spinners .scratch-off__cell--roulette-red.scratch-off__cell--done {
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.55);
  border-color: rgba(248, 113, 113, 0.75) !important;
}

.scratch-off--roulette-spinners .scratch-off__cell--roulette-black.scratch-off__cell--done {
  box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.55);
  border-color: rgba(75, 85, 99, 0.8) !important;
}

.scratch-off--roulette-spinners .scratch-off__cell--roulette-green.scratch-off__cell--done {
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.55);
  border-color: rgba(74, 222, 128, 0.65) !important;
}

.scratch-off-stack-item--session-done {
  background: rgba(25, 135, 84, 0.09);
  border-color: rgba(25, 135, 84, 0.4) !important;
}

/* Finished ticket stays visible above the next scratcher; interaction disabled via pointer-events */
.scratch-off-stack-item--finished {
  background: rgba(25, 135, 84, 0.06);
  border-color: rgba(25, 135, 84, 0.35) !important;
  pointer-events: none;
}

.scratch-off-stack-item--finished .scratch-off__canvas {
  pointer-events: none;
}

.scratch-off-stack-item--outline {
  border-color: var(--border-primary, rgba(255, 255, 255, 0.18)) !important;
  background: var(--bg-tertiary, rgba(0, 0, 0, 0.08));
}

/* Placeholder scratcher: same 2×3 layout as playable, non-interactive foil cells */
.scratch-off-modal .scratch-off__cell--placeholder,
.scratch-off-page .scratch-off__cell--placeholder {
  touch-action: auto;
  pointer-events: none;
  min-height: 7rem;
  filter: grayscale(0.2);
  opacity: 0.88;
}

.scratch-off__placeholder-surface {
  height: 7rem;
  background: linear-gradient(145deg, rgba(196, 200, 208, 0.55), rgba(148, 154, 168, 0.45));
  background-image:
    repeating-linear-gradient(
      -32deg,
      rgba(255, 255, 255, 0.07),
      rgba(255, 255, 255, 0.07) 3px,
      transparent 3px,
      transparent 7px
    ),
    linear-gradient(145deg, rgba(196, 200, 208, 0.65), rgba(130, 136, 150, 0.5));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.scratch-off__placeholder-lock {
  opacity: 0.45;
  font-size: clamp(1.25rem, 4vw, 1.65rem);
  filter: grayscale(1);
}

.scratch-off--placeholder {
  pointer-events: none;
}

.scratch-off-stack-item--done {
  opacity: 0.9;
}

.scratch-off-stack-item--done .scratch-off__canvas {
  pointer-events: none;
}
