:root {
  --bg: radial-gradient(circle at 20% 20%, #f0f7ff, #cfd9ff 45%, #9aa8ff 100%);
  --card: #0f1624;
  --accent: #ffbd3d;
  --accent-2: #58f29f;
  --muted: #c7d2e3;
  --shadow: 0 18px 38px rgba(5, 15, 34, 0.25);
}

body.theme-anniversaire {
  --bg: radial-gradient(circle at 30% 20%, #fff1f7, #ffd8e7 40%, #ffc2e0 75%);
  --card: #251029;
  --accent: #ff86b9;
  --accent-2: #ffc94a;
  --muted: #f3d6ec;
  --shadow: 0 18px 38px rgba(37, 16, 41, 0.35);
}

body.theme-noel {
  --bg: radial-gradient(circle at 25% 25%, #ffffff, #f7faf7 45%, #e2f0e5 75%);
  --card: #10311f;
  --accent: #e53935;
  --accent-2: #2ca45a;
  --muted: #d5e6d6;
  --shadow: 0 18px 38px rgba(16, 49, 31, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: #0c1020;
  font-family: "Archivo", "Segoe UI", system-ui, -apple-system, sans-serif;
  padding: 24px;
}

.shell {
  width: min(960px, 100%);
  background: #ffffffaa;
  border: 1px solid #e3e9ff;
  border-radius: 24px;
  padding: clamp(18px, 4vw, 32px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

header {
  /*display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;*/
}

.title {
  z-index: 1;
  position: absolute;
  top: 10px;
  text-align: left;
  width: 100%;
  padding: 0rem 1rem;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: -0.02em;
  color: #f7f9ff;
}

p.sub {
  margin: 0;
  max-width: 520px;
  color: #1c2440;
  line-height: 1.5;
  font-size: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 99px;
  background: #fff7e8;
  color: #6f4b00;
  font-weight: 600;
  font-size: 14px;
  box-shadow: inset 0 0 0 1px #ffe1a3;
}

@media (max-width: 480px) {
  h1 {
    font-size: 22px;
  }
  p.sub {
    font-size: 14px;
  }
  .badge {
    width: 100%;
    justify-content: center;
  }
  .generate {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
  .actions {
    flex-direction: column;
    align-items: stretch;
  }
  .scratch-area {
    min-height: 240px;
    max-height: calc(100vh - 120px);
  }
  .card {
    min-height: 240px;
  }
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(14px, 3vw, 26px);
}

@media (max-width: 820px) {
  .shell {
    padding: 16px;
    border-radius: 16px;
  }
  header {
    flex-direction: column;
    align-items: flex-start;
  }
  .scratch-area {
    min-height: 260px;
    max-height: calc(100vh - 120px);
  }
  .card {
    min-height: 260px;
  }
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 12px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #0f1624;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s ease, box-shadow 0.2s ease;
}

.cta:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

.cta:hover {
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.22);
}

.cta.visible {
  opacity: 1;
  transform: translateY(0);
}

.scratch-area {
  position: relative;
  width: 100%;
  max-width: 100%;
  max-height: calc(100vh - 140px);
  aspect-ratio: var(--scratch-ar, 4 / 3);
  min-height: 280px;
  border-radius: 18px;
  overflow: hidden;
  background: #0f1624;
  box-shadow: var(--shadow);
  border: 1px solid #1e2a40;
  display: grid;
  place-items: center;
  margin: 0 auto;
}

.bg-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease;
  filter: saturate(1.05);
}

.bg-preview.visible {
  opacity: 1;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.scratch-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #0c1020;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  pointer-events: none;
  mix-blend-mode: multiply;
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.8) 0,
    rgba(255, 255, 255, 0.8) 18px,
    rgba(233, 239, 255, 0.8) 18px,
    rgba(233, 239, 255, 0.8) 36px
  );
}

.progress {
  position: absolute;
  bottom: 14px;
  left: 14px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(12, 16, 32, 0.7);
  color: #e9efff;
  font-weight: 600;
  font-size: 14px;
  backdrop-filter: blur(8px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.hint {
  font-size: 14px;
  color: #203157;
}

.reward-overlay {
  position: absolute;
  bottom: 18px;
  left: 16px;
  right: 16px;
  z-index: 2;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.reward-overlay[hidden] {
  display: none;
}

.reward-message {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(12, 16, 32, 0.75);
  color: #f7f9ff;
  backdrop-filter: blur(8px);
  font-size: 14px;
  line-height: 1.5;
}

.cta.inline {
  justify-self: start;
  pointer-events: auto;
}

.panel {
  background: #fffdf8;
  border: 1px solid #f0e4c6;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

.panel h3 {
  margin: 0 0 6px;
  font-size: 17px;
  color: #2a1c00;
}

.panel p {
  margin: 0 0 12px;
  color: #493613;
}

.fields {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 4px;
}

.field label {
  font-weight: 700;
  color: #2a1c00;
  font-size: 14px;
}

.field small {
  color: #5c4926;
}

.field input[type="file"],
.field input[type="email"],
.field input[type="text"],
.field textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #e7d7ac;
  background: #fffaf2;
  padding: 10px;
  font-family: inherit;
  color: #2a1c00;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field textarea {
  resize: vertical;
  min-height: 68px;
}

.field input[type="file"]:focus-visible,
.field input[type="email"]:focus-visible,
.field input[type="text"]:focus-visible,
.field textarea:focus-visible {
  border-color: #ffbd3d;
  box-shadow: 0 0 0 3px rgba(255, 189, 61, 0.28);
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.generate {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  background: linear-gradient(120deg, #ffbd3d, #ff9c3d);
  color: #2a1c00;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(255, 138, 0, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.generate:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(255, 138, 0, 0.32);
}

.generate:active {
  transform: translateY(0);
}

.status {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f7efdd;
  color: #3a2b0f;
  border: 1px solid #eddcb5;
  font-weight: 600;
  font-size: 14px;
  flex: 1;
}

.status[data-tone="warn"] {
  background: #fff2f0;
  color: #7d2014;
  border-color: #f5c3b9;
}

.generated-link {
  margin-top: 8px;
  font-size: 14px;
  color: #2a1c00;
}

.generated-link a {
  color: #6f4b00;
  font-weight: 700;
  text-decoration: underline;
}
