/* =====================================
   SCRATCH GAME
===================================== */

.scratch-panel {
  background: #ff69b4;
  perspective: 1000px;
}

.scratch-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
}

.scratch-card-shell {
  max-width: 420px;
  margin: 0 auto;
  background: #ffff00;
  border: 5px solid #000;
  box-shadow: 8px 8px 0 #000;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  transform-style: preserve-3d;
  --scratch-tilt-x: 0deg;
  --scratch-tilt-y: 0deg;
  --scratch-shine-x: 0px;
  --scratch-shine-y: 0px;
  --scratch-shine-opacity: 0;
  transform: rotateX(var(--scratch-tilt-x)) rotateY(var(--scratch-tilt-y));
  transition: transform 180ms ease, box-shadow 180ms ease;
  will-change: transform;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}

.scratch-card-shell * {
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}

.scratch-card-shell.is-tilting {
  transition: none;
  cursor: grabbing;
}

.scratch-card-shell > * {
  position: relative;
  z-index: 2;
}

.scratch-shine {
  position: absolute;
  z-index: 1;
  inset: -4px;
  pointer-events: none;
  opacity: var(--scratch-shine-opacity);
  background:
    radial-gradient(220px 120px at calc(20% + var(--scratch-shine-x)) calc(18% + var(--scratch-shine-y)), rgba(255,255,255,0.55), rgba(255,255,255,0) 68%),
    linear-gradient(115deg, rgba(255,255,255,0) 28%, rgba(255,255,255,0.35) 48%, rgba(255,255,255,0) 64%);
  transition: opacity 160ms ease;
}

.scratch-card-shell.is-tilting .scratch-shine {
  opacity: 1;
}

.scratch-card-shell::before,
.scratch-card-shell::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  background: #ff69b4;
  border: 4px solid #000;
  border-radius: 50%;
}

.scratch-card-shell::before {
  left: -14px;
}

.scratch-card-shell::after {
  right: -14px;
}

.scratch-card-head {
  background: #ff0000;
  border: 4px solid #000;
  box-shadow: 4px 4px 0 #000;
  text-align: center;
  padding: 8px 10px;
}

.scratch-card-head h2 {
  margin: 0;
  font-size: 28px;
  color: #ffff00;
  text-shadow: 2px 2px 0 #000;
}

.scratch-card-head p {
  margin: 4px 0 0;
  font-size: 14px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.scratch-buy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.scratch-buy-btn {
  min-width: 108px;
  border-width: 3px;
  padding: 8px 10px;
}

.scratch-grid {
  margin: 8px auto 2px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 88px));
  gap: 0;
  justify-content: center;
  position: relative;
  border: 4px solid #000;
  box-shadow: 6px 6px 0 #000;
  background: #ffff00;
}

.scratch-cell {
  width: 88px;
  height: 88px;
  background: #ffff00;
  border: 2px solid #000;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #0000ff;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.scratch-cell.is-win {
  background: #00ff00;
}

.scratch-cell:nth-child(1),
.scratch-cell:nth-child(2),
.scratch-cell:nth-child(3) {
  border-top: 0;
}

.scratch-cell:nth-child(1),
.scratch-cell:nth-child(4),
.scratch-cell:nth-child(7) {
  border-left: 0;
}

.scratch-cell:nth-child(3),
.scratch-cell:nth-child(6),
.scratch-cell:nth-child(9) {
  border-right: 0;
}

.scratch-cell:nth-child(7),
.scratch-cell:nth-child(8),
.scratch-cell:nth-child(9) {
  border-bottom: 0;
}

.scratch-value {
  opacity: 1;
  transform: scale(1);
  transition: transform 120ms ease;
  width: 58px;
  height: 58px;
  object-fit: contain;
  pointer-events: none;
}

.scratch-cell.is-revealed .scratch-value {
  transform: scale(1);
}

.scratch-grid-mask {
  position: absolute;
  inset: 0;
  width: calc(100% + 2px);
  height: 100%;
  z-index: 3;
  touch-action: none;
  cursor: crosshair;
}

.scratch-lock-hint {
  color: #ff0000;
  font-weight: 700;
  text-align: center;
}

.scratch-footnote {
  text-align: center;
}

.scratch-key {
  width: 100%;
  max-width: none;
  margin: 12px 0 0;
  padding: 10px;
  background: #00ffff;
  border: 4px solid #000;
  box-shadow: 6px 6px 0 #000;
}

.scratch-key h3 {
  margin: 0 0 8px;
  color: #ff00ff;
  text-shadow: 2px 2px 0 #000;
  text-align: center;
}

.scratch-key-head,
.scratch-key-row {
  display: grid;
  grid-template-columns: 54px repeat(3, minmax(0, 1fr));
  gap: 6px;
  align-items: center;
}

.scratch-key-head {
  padding: 6px 6px;
  border: 3px solid #000;
  background: #ffa500;
  font-size: 14px;
  text-align: center;
}

.scratch-key-row {
  margin-top: 6px;
  padding: 6px;
  border: 3px solid #000;
  background: #ffff00;
  text-align: center;
  font-size: 14px;
}

.scratch-key-row img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  margin: 0 auto;
}

@media (max-width: 560px) {
  .scratch-grid {
    grid-template-columns: repeat(3, minmax(0, 76px));
  }

  .scratch-cell {
    width: 76px;
    height: 76px;
    font-size: 28px;
  }

  .scratch-value {
    width: 48px;
    height: 48px;
  }
}

@media (max-width: 760px) {
  .scratch-panel {
    padding: 10px;
  }

  .scratch-card-shell {
    max-width: 100%;
    padding: 8px;
    gap: 8px;
  }

  .scratch-card-shell::before,
  .scratch-card-shell::after {
    display: none;
  }

  .scratch-card-head {
    padding: 6px 8px;
  }

  .scratch-card-head h2 {
    font-size: 22px;
  }

  .scratch-card-head p {
    font-size: 12px;
    margin-top: 2px;
  }

  .scratch-buy-row {
    gap: 6px;
  }

  .scratch-buy-btn {
    min-width: 92px;
    padding: 6px 8px;
    font-size: 14px;
  }

  .scratch-lock-hint,
  .scratch-footnote {
    font-size: 12px;
  }

  .scratch-key {
    margin-top: 8px;
    padding: 8px;
  }

  .scratch-key h3 {
    margin-bottom: 6px;
    font-size: 18px;
  }

  .scratch-key-head,
  .scratch-key-row {
    grid-template-columns: 34px repeat(3, minmax(0, 1fr));
    gap: 4px;
  }

  .scratch-key-head {
    padding: 4px;
    font-size: 11px;
  }

  .scratch-key-row {
    margin-top: 4px;
    padding: 4px;
    font-size: 11px;
  }

  .scratch-key-row img {
    width: 26px;
    height: 26px;
  }
}

@media (max-width: 980px) {
  .scratch-layout {
    grid-template-columns: 1fr;
  }
}
