/* scratch — 刮刮樂 */

.app {
  max-width: 640px;
  padding-bottom: 32px;
}

/* ── HUD ───────────────────────────────────────────────── */
.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}
.hud-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.hud-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.5px; }
.hud-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-value.win  { color: #2e9e4a; }
.hud-value.lose { color: #e53935; }
.hud-value.small { font-size: 14px; line-height: 26px; }
.hud-value.hud-pulse { animation: hud-pulse 0.5s ease; }
@keyframes hud-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ── Shop ──────────────────────────────────────────────── */
.shop {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.shop-card {
  border-radius: var(--radius-md);
  padding: 10px 6px;
  text-align: center;
  color: #fff;
  box-shadow: var(--shadow-sm);
  border: 2px solid transparent;
  min-width: 0;
}
.shop-card.s-lucky7 { background: linear-gradient(160deg, #e53935, #8e1b1b); }
.shop-card.s-pairs  { background: linear-gradient(160deg, #1e88e5, #0d3c7a); }
.shop-card.s-gold   { background: linear-gradient(160deg, #c79100, #6d4c00); }
.shop-card.current  { border-color: #fff; box-shadow: 0 0 0 2px var(--accent), var(--shadow-sm); }
.shop-name { font-weight: 900; font-size: 16px; }
.shop-top  { font-size: 12px; margin: 2px 0 8px; color: #fff6d8; }
.buy-btn {
  background: rgba(255,255,255,0.95);
  color: #222;
  min-width: 0;
  width: 100%;
  max-width: 120px;
}
.buy-btn:hover:not(:disabled) { background: #fff; }
.buy-btn:disabled { background: rgba(0,0,0,0.35); color: rgba(255,255,255,0.75); }

/* ── Stage / ticket ────────────────────────────────────── */
.stage { min-height: 200px; }
.stage-empty {
  text-align: center;
  padding: 50px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-strong);
}
.stage-empty[hidden] { display: none; }

.ticket {
  margin: 0 auto;
  max-width: 460px;
  border-radius: 14px;
  padding: 12px;
  color: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  position: relative;
}
.ticket.t-lucky7 { background: repeating-linear-gradient(135deg, #c62828 0 14px, #b71c1c 14px 28px); }
.ticket.t-pairs  { background: repeating-linear-gradient(135deg, #1565c0 0 14px, #0d47a1 14px 28px); }
.ticket.t-gold   { background: radial-gradient(circle at 30% 0%, #ffe082, #b8860b 60%, #6d4c00); color: #2b1d00; }
.ticket-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ticket-name { font-size: 22px; font-weight: 900; letter-spacing: 1px; }
.ticket-price { font-size: 13px; font-weight: 700; }
.ticket-rule { font-size: 13px; margin: 4px 0 10px; }

.scratch-area {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #fffdf5;
  color: #222;
  padding: 10px;
  user-select: none;
  -webkit-user-select: none;
}
.scratch-coat {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  z-index: 2;
}
.scratch-coat.gone { display: none; }

.cell {
  border-radius: 8px;
  background: #fff;
  border: 2px solid #e7e0cc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.revealed .cell.won {
  background: #fff3b0;
  border-color: #f9a825;
  box-shadow: 0 0 0 2px #f9a825, 0 0 12px rgba(249,168,37,0.8);
  animation: won-pulse 0.9s ease-in-out 2;
}
@keyframes won-pulse {
  50% { transform: scale(1.08); }
}

/* Lucky 7 */
.l7-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.l7-cell { height: 72px; }
.l7-mark { font-size: 12px; color: #c62828; }
.l7-cell .amt { font-size: 24px; color: #222; }

/* Match Up */
.pairs-label { font-size: 12px; font-weight: 800; color: #0d47a1; margin: 2px 0 4px; }
.pairs-row { display: grid; gap: 6px; margin-bottom: 8px; }
.win-row  { grid-template-columns: repeat(3, 1fr); max-width: 260px; margin-left: auto; margin-right: auto; }
.mine-row { grid-template-columns: repeat(5, 1fr); margin-bottom: 0; }
.pn { height: 58px; font-size: 22px; }
.win-num { background: #e3f2fd; border-color: #90caf9; color: #0d47a1; }
.mine .num { font-size: 22px; line-height: 1.1; }
.mine .amt { font-size: 12px; color: #555; font-weight: 800; }

/* Golden Jackpot */
.gold-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 300px; margin: 0 auto; }
.gold-cell { aspect-ratio: 1 / 1; font-size: 36px; }
.gold-cell .sym { line-height: 1; }
.gold-cell.star .sym { color: #e6a100; text-shadow: 0 0 6px rgba(230,161,0,0.6); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.gold-legend {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px;
  margin-top: 8px; font-size: 13px; font-weight: 800; color: #2b1d00;
}

/* ── Result / actions ──────────────────────────────────── */
.result-banner {
  text-align: center;
  margin: 12px auto 0;
  max-width: 460px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: #2a2140;
  color: #fff;
  animation: banner-pop 0.35s cubic-bezier(.2,1.4,.5,1);
}
.result-banner[hidden] { display: none; }
.banner-head { font-size: 22px; font-weight: 900; }
.banner-sub  { font-size: 13px; margin-top: 2px; color: #e6e0f5; }
.result-banner.win  .banner-head { color: #ffd54f; }
.result-banner.lose .banner-head { color: #ffab9f; }
.result-banner.big { box-shadow: 0 0 18px rgba(255,215,0,0.7); }
@keyframes banner-pop {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.action-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
}
.action-row[hidden], .action-row .btn[hidden] { display: none; }
.action-row .btn.primary {
  background: linear-gradient(180deg, #d81b60, #a0124a);
  color: #fff;
  font-weight: 800;
  min-width: 120px;
}
.action-row .btn.primary:disabled { background: var(--btn-disabled); color: rgba(255,255,255,0.7); }
.scratch-progress { text-align: center; font-size: 12px; color: var(--text-strong); min-height: 18px; margin-top: 6px; }

/* ── Prize tables ──────────────────────────────────────── */
.prize-tables {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  color: var(--text-strong);
}
.prize-tables summary { cursor: pointer; font-weight: 800; text-align: center; }
.pt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 8px; }
.pt-card h3 { font-size: 14px; margin: 0 0 4px; }
.pt-card table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.pt-card th, .pt-card td { border-bottom: 1px solid var(--border); padding: 2px 3px; text-align: left; }
.pt-card td:nth-child(2), .pt-card th:nth-child(2) { text-align: right; }
.pt-card td:nth-child(3), .pt-card th:nth-child(3) { text-align: right; white-space: nowrap; }
.pt-card p { font-size: 12px; margin: 4px 0 0; font-weight: 700; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 520px) {
  .hud-value { font-size: 18px; }
  .shop { gap: 6px; }
  .shop-name { font-size: 14px; }
  .ticket { padding: 10px; }
  .ticket-name { font-size: 18px; }
  .l7-cell { height: 62px; }
  .l7-cell .amt { font-size: 20px; }
  .pn { height: 52px; font-size: 18px; }
  .mine .num { font-size: 18px; }
  .gold-cell { font-size: 30px; }
}

:where(body:not(.dark)) .hud-value { color: color-mix(in srgb, var(--accent) 55%, #000); }
