*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand: #0d1117;
  --accent: #e94560;
  --teal: #00d4b8;
  --gold: #f0a500;
  --light: #f5f5f5;
  --font: 'Arial', sans-serif;
}

body {
  background: var(--brand);
  color: var(--light);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 1000px;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Stage ── */
#stage-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

#canvas-container {
  width: 100%;
  display: flex;
  justify-content: center;
}
#canvas-container canvas {
  border-radius: 12px;
  box-shadow: 0 0 40px rgba(233,69,96,0.3);
  max-width: 100% !important;
  height: auto !important;
  aspect-ratio: 4 / 3;
  display: block;
}

/* ── Controls ── */
#controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

#bg-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.5;
}
#bg-thumbs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.bg-thumb {
  width: 72px;
  height: 48px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  object-fit: cover;
  transition: border-color 0.2s, transform 0.15s;
  background: #333;
}
.bg-thumb:hover { transform: scale(1.07); }
.bg-thumb.active { border-color: var(--accent); }

#capture-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 40px;
  padding: 14px 48px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  gap: 10px;
}
#capture-btn:hover { background: #c73652; transform: scale(1.03); }
#capture-btn:active { transform: scale(0.98); }
.icon { font-size: 1.3rem; }

/* ── Result Modal ── */
#result-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
#result-modal.hidden { display: none; }

#result-inner {
  background: #16213e;
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 540px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  box-shadow: 0 0 60px rgba(233,69,96,0.25);
}
#result-inner h2 {
  font-size: 1rem;
  text-align: center;
  color: var(--gold);
  letter-spacing: 0.04em;
}
#result-img {
  width: 100%;
  border-radius: 10px;
  border: 2px solid var(--accent);
}

#qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.qr-label { font-size: 0.72rem; opacity: 0.5; letter-spacing: 0.08em; text-transform: uppercase; }
#qr-code canvas, #qr-code img { border-radius: 6px; }

#modal-actions {
  display: flex;
  gap: 14px;
}
#download-btn {
  background: var(--accent);
  color: #fff;
  border-radius: 30px;
  padding: 10px 28px;
  font-weight: 700;
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.2s;
}
#download-btn:hover { background: #c73652; }
#retake-btn {
  background: transparent;
  color: var(--light);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 30px;
  padding: 10px 28px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s;
}
#retake-btn:hover { border-color: var(--light); }

/* ── Loading ── */
#loading-screen {
  position: fixed;
  inset: 0;
  background: var(--brand);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 200;
}
#loading-screen.hidden { display: none; }
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-screen p { font-size: 0.85rem; opacity: 0.6; letter-spacing: 0.08em; }
