/* ─── CSS Custom Properties (overridden by card customization) ─── */
:root {
  --bg-1: #0f0c29;
  --bg-2: #302b63;
  --bg-3: #24243e;
  --card-bg-1: #1a1a3e;
  --card-bg-2: #2d1b4e;
  --accent-1: #f6d365;
  --accent-2: #fda085;
  --font-display: "Outfit", sans-serif;
  --card-radius: 20px;
}

/* ─── Reset & Base ─── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  min-height: 100vh;
  background: linear-gradient(
    145deg,
    var(--bg-1) 0%,
    var(--bg-2) 40%,
    var(--bg-3) 100%
  );
  color: #e8e8f0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* ─── Brand Bar (White-label) ─── */
.brand-bar {
  width: 100%;
  padding: 18px 24px;
  text-align: center;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-logo {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-1) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.brand-logo img {
  height: 32px;
  vertical-align: middle;
  margin-right: 8px;
}

.brand-tagline {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 4px;
  letter-spacing: 0.01em;
}

/* ─── Banner Image ─── */
.banner-img {
  width: 100%;
  max-height: 180px;
  overflow: hidden;
}

.banner-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ─── Card Wrapper ─── */
.card-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  width: 100%;
  max-width: 600px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #f8f8ff, #c8c8ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.3;
}

/* ─── Scratch Container ─── */
.scratch-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1.6 / 1;
  border-radius: var(--card-radius);
  overflow: hidden;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.08),
    0 8px 40px rgba(0, 0, 0, 0.5),
    0 0 80px rgba(246, 211, 101, 0.08);
  background: linear-gradient(
    160deg,
    var(--card-bg-1) 0%,
    var(--card-bg-2) 100%
  );
}

.scratch-container.no-card {
  aspect-ratio: auto;
  padding: 48px 24px;
}

.scratch-container.no-card .result-layer {
  position: relative;
}

/* ─── Result Layer (underneath) ─── */
.result-layer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1;
  visibility: hidden; /* Hide until scratch surface is ready */
}

.result-layer.has-custom-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: -1;
}

.result-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
  animation: bounceIn 0.5s ease;
}

.result-message {
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.4;
}

.result-message.win {
  font-size: 1.35rem;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ─── Win Code Box ─── */
.win-code-box {
  display: none;
  margin-top: 20px;
  padding: 16px 24px;
  background: rgba(246, 211, 101, 0.08);
  border: 1px solid rgba(246, 211, 101, 0.25);
  border-radius: 14px;
  text-align: center;
  animation: fadeSlideUp 0.4s ease 0.3s both;
}

.win-code-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 10px;
}

.win-code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.win-code {
  font-family: var(--font-display), monospace;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent-1);
  user-select: all;
}

.btn-copy-code {
  padding: 8px 18px;
  border: 1px solid rgba(246, 211, 101, 0.3);
  border-radius: 10px;
  background: rgba(246, 211, 101, 0.12);
  color: var(--accent-1);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-copy-code:hover {
  background: rgba(246, 211, 101, 0.22);
  border-color: rgba(246, 211, 101, 0.5);
}

.btn-copy-code.copied {
  background: rgba(80, 200, 120, 0.2);
  border-color: rgba(80, 200, 120, 0.4);
  color: #50c878;
}

/* ─── Canvas (scratch overlay) ─── */
#scratchCanvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  cursor: crosshair;
  touch-action: none;
  border-radius: var(--card-radius);
}

/* ─── Scratch Hint ─── */
.scratch-hint {
  position: absolute;
  bottom: 20px;
  right: 20px;
  left: auto;
  transform: none;
  z-index: 6;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.6);
  background: rgba(255, 255, 255, 0.8);
  padding: 8px 16px;
  border-radius: 20px;
  pointer-events: none;
  transition: opacity 0.4s ease;
  animation: pulse 2s ease-in-out infinite;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.scratch-hint span {
  display: inline-block;
  animation: wiggle 1.5s ease-in-out infinite;
}

/* ─── Try Again Button ─── */
.btn-try-again {
  margin-top: 28px;
  padding: 14px 32px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  color: #e0e0e0;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.35s ease;
}

.btn-try-again.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.btn-try-again:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

/* ─── Footer (White-label) ─── */
.brand-footer {
  width: 100%;
  padding: 28px 24px 36px;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: auto;
}

.footer-main {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 12px;
}

.footer-main strong {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.footer-puns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  margin-bottom: 16px;
}

.footer-puns span {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.22);
  font-style: italic;
}

.footer-cta {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.35);
}

.footer-cta a {
  color: var(--accent-1);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.footer-cta a:hover {
  color: var(--accent-2);
}

/* ─── Confetti Canvas ─── */
#confettiCanvas {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  display: none;
}

/* ─── Animations ─── */
@keyframes bounceIn {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  70% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.9;
    transform: translateX(-50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) scale(1.05);
  }
}

@keyframes wiggle {
  0%,
  100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-12deg);
  }
  75% {
    transform: rotate(12deg);
  }
}

/* ─── Responsive ─── */
@media (max-width: 480px) {
  .brand-bar {
    padding: 14px 16px;
  }
  .brand-logo {
    font-size: 1.35rem;
  }
  .card-wrapper {
    padding: 24px 16px;
  }
  .card-title {
    font-size: 1.35rem;
    margin-bottom: 20px;
  }
  .scratch-container {
    border-radius: calc(var(--card-radius) * 0.8);
  }
  #scratchCanvas {
    border-radius: calc(var(--card-radius) * 0.8);
  }
  .result-icon {
    font-size: 2.8rem;
  }
  .result-message {
    font-size: 1rem;
  }
  .result-message.win {
    font-size: 1.15rem;
  }
  .win-code {
    font-size: 1.15rem;
  }
  .win-code-box {
    padding: 12px 16px;
  }
  .footer-puns {
    flex-direction: column;
    gap: 6px;
  }
}

@media (max-width: 360px) {
  .brand-logo {
    font-size: 1.2rem;
  }
  .card-title {
    font-size: 1.15rem;
  }
  .win-code-row {
    flex-direction: column;
    gap: 8px;
  }
}

@media (min-width: 768px) {
  .card-wrapper {
    padding: 48px 24px;
  }
  .card-title {
    font-size: 2rem;
  }
  .scratch-container {
    max-width: 600px;
  }
  .result-icon {
    font-size: 4rem;
  }
}

/* ─── Embed Mode ─── */
body.embed-mode {
  background: transparent !important;
  min-height: auto;
  overflow: hidden;
}
body.embed-mode .brand-bar,
body.embed-mode .brand-footer {
  display: none !important;
}
body.embed-mode .card-wrapper {
  padding: 12px !important;
  width: 100%;
  max-width: 100%;
  justify-content: flex-start;
}
body.embed-mode .card-title {
  margin-top: 0;
  font-size: 1.5rem;
}
body.embed-mode .scratch-container {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  max-width: 100%;
}
