/* 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__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;
}

.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));
  opacity: 0.92;
}

/* 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;
}
