@font-face { font-family: "Unbounded"; src: url(../assets/fonts/unbounded.woff2) format("woff2"); font-weight: 200 900; font-display: swap; }
@font-face { font-family: "Archivo"; src: url(../assets/fonts/archivo.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --blue: #2800dc;
  --blue-bright: #3d3df0;
  --blue-deep: #17007f;
  --red: #ff0409;
  --gold: #ffbc02;
  --cream: #fff8e1;
  --sun: #ffe7a3;
  --amber: #f6c04a;
  --display: "Unbounded", "Arial Black", sans-serif;
  --body: "Archivo", "Segoe UI", Roboto, Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sun);
  color: var(--blue-deep);
  font-family: var(--body);
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: calc(18px + var(--safe-top)) 16px calc(20px + var(--safe-bottom));
  text-align: center;
  overflow: hidden;
}
.screen.active { display: flex; }
.screen > * { position: relative; z-index: 1; }

/* ── Sunburst backdrop ──────────────────────── */
.sunny {
  background: radial-gradient(circle at 50% var(--sun-y), var(--cream) 0, var(--sun) 35%, var(--amber) 100%);
}
.sunny { --sun-y: 30%; }
#screen-welcome { --sun-y: calc(var(--safe-top) + 18px + 42px); }
.sunny .rays {
  position: absolute;
  z-index: 0;
  left: 50%; top: var(--sun-y);
  width: 260vmax; height: 260vmax;
  margin: -130vmax 0 0 -130vmax;
  background: repeating-conic-gradient(rgba(255,255,255,.5) 0deg 6.43deg, transparent 6.43deg 12.86deg);
  -webkit-mask-image: radial-gradient(circle, #000 0, rgba(0,0,0,.6) 12%, transparent 34%);
  mask-image: radial-gradient(circle, #000 0, rgba(0,0,0,.6) 12%, transparent 34%);
  animation: turn 140s linear infinite;
  pointer-events: none;
}
.sunny::after {
  content: "";
  position: absolute; z-index: 0;
  left: 50%; top: var(--sun-y);
  width: 70vmin; height: 70vmin;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255,255,255,.9), transparent 65%);
  pointer-events: none;
}
@keyframes turn { to { transform: rotate(360deg); } }

.waves {
  position: absolute !important;
  z-index: 0 !important;
  left: 0; right: 0; bottom: 0;
  width: 100%;
  height: calc(12vh + var(--safe-bottom));
}

/* ── Welcome ────────────────────────────────── */
#screen-welcome { justify-content: flex-start; gap: 24px; }
#screen-welcome .hero { margin-top: auto; }
#screen-welcome .actions { margin-bottom: auto; }

/* OWWA seal as a sticker: deep-blue outline, dropped depth, white halo.
   It sits where the sunburst rays meet, so the logo reads as the sun. */
.seal {
  --size: 84px;
  display: grid; place-items: center;
  flex: none;
  width: var(--size); height: var(--size);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #fff 40%, #f1efff);
  box-shadow:
    0 0 0 calc(var(--size) * .035) var(--blue-deep),
    0 calc(var(--size) * .05) 0 calc(var(--size) * .035) var(--blue-deep),
    0 calc(var(--size) * .1) calc(var(--size) * .2) calc(var(--size) * .03) rgba(23,0,127,.35),
    0 0 calc(var(--size) * .5) calc(var(--size) * .35) rgba(255,255,255,.85);
}
.seal img { width: 83%; height: auto; margin-top: 2%; }
.seal.big { --size: 120px; }

.hero { display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; }
#wordmark { width: min(88vw, 400px); height: auto; filter: drop-shadow(0 6px 14px rgba(23,0,127,.18)); }

.ribbon {
  margin: 0;
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 22px 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--blue-bright), var(--blue));
  border: 2px solid rgba(255,255,255,.85);
  box-shadow: 0 5px 0 var(--blue-deep), 0 12px 24px rgba(23,0,127,.25);
  color: #fff;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(15px, 4.6vw, 20px);
  letter-spacing: .01em;
}
.ribbon small {
  font-family: var(--body);
  font-weight: 900;
  font-size: .72em;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold);
}

.actions { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }

.privacy {
  margin: 0;
  max-width: 300px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.hint { font-size: 13px; font-weight: 600; color: var(--blue-deep); opacity: .75; margin: 10px 0 0; }

.notice {
  background: rgba(255,255,255,.82);
  border: 2px solid #fff;
  border-radius: 18px;
  padding: 14px 18px;
  max-width: 360px;
  font-size: 15px;
  line-height: 1.4;
  box-shadow: 0 8px 22px rgba(23,0,127,.15);
}
.notice p { margin: 0 0 8px; }
.notice p:last-child { margin-bottom: 0; }
.notice.warn { border-color: var(--red); }
.notice .big-text { font-family: var(--display); font-size: 17px; font-weight: 700; color: var(--blue); }

/* ── Buttons ─────────────────────────────── */
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 800;
  color: #fff;
  background: var(--blue);
  padding: 13px 22px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s ease, box-shadow .12s ease, opacity .2s;
}
.btn:focus-visible, .tab:focus-visible, .icon-btn:focus-visible, .shutter:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}
.btn:disabled { opacity: .45; }
.btn.big {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  padding: 18px 34px;
  min-width: 260px;
  border: 2px solid rgba(255,255,255,.85);
  background: linear-gradient(180deg, var(--blue-bright), var(--blue));
  box-shadow: 0 7px 0 var(--blue-deep), 0 14px 26px rgba(23,0,127,.3);
}
.btn.big:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--blue-deep), 0 8px 16px rgba(23,0,127,.3); }
.btn.ghost {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 3px 0 rgba(23,0,127,.25);
}
.btn.ghost:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(23,0,127,.25); }
.btn.small { padding: 9px 14px; font-size: 14px; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ── Camera ─────────────────────────────── */
#screen-camera { padding: 0; background: var(--blue-deep); color: #fff; justify-content: space-between; }
#video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: all .35s ease;
}
#video.mirror { transform: scaleX(-1); }

#frame-guide {
  position: absolute;
  border: 3px solid #fff;
  border-radius: 16px;
  box-shadow: 0 0 0 100vmax rgba(23,0,127,.6);
  transition: all .35s ease;
  pointer-events: none;
}

.cam-top, .cam-bottom { z-index: 2; width: 100%; display: flex; align-items: center; }
.cam-top { justify-content: space-between; padding: calc(12px + var(--safe-top)) 14px 0; }
.cam-bottom { flex-direction: column; gap: 10px; padding: 0 14px calc(18px + var(--safe-bottom)); }

.pill { background: rgba(0,0,0,.45); padding: 8px 16px; border-radius: 999px; font-family: var(--display); font-weight: 700; font-size: 14px; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.45); color: #fff; font-size: 22px; cursor: pointer;
}
.icon-btn:disabled { opacity: .3; }

.shutter {
  width: 86px; height: 86px; border-radius: 50%;
  border: 6px solid #fff; background: transparent; padding: 6px; cursor: pointer;
}
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--red); transition: transform .2s; }
.shutter:active span { transform: scale(.88); }
.shutter:disabled { opacity: .35; }
.cam-hint { margin: 0; font-size: 14px; font-weight: 700; text-shadow: 0 1px 4px #000; }

#thumbs { display: flex; gap: 8px; }
#thumbs span {
  width: 44px; height: 44px; border-radius: 8px;
  border: 2px solid rgba(255,255,255,.7);
  background: rgba(0,0,0,.35) center/cover;
}
#thumbs span.done { border-color: var(--gold); }

#countdown {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-items: center;
  font-family: var(--display);
  font-size: 40vmin; font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 1.5vmin var(--blue-deep);
  paint-order: stroke fill;
  text-shadow: 0 2vmin 0 var(--blue-deep);
  pointer-events: none;
}
#countdown.pop { animation: pop .9s ease-out; }
@keyframes pop {
  0% { transform: scale(1.6); opacity: 0; }
  20% { transform: scale(1); opacity: 1; }
  100% { transform: scale(.85); opacity: .9; }
}
#flash { position: absolute; inset: 0; z-index: 4; background: #fff; opacity: 0; pointer-events: none; }
#flash.on { opacity: 1; }
#flash.fade { transition: opacity .45s ease-out; opacity: 0; }

/* ── Result ─────────────────────────────── */
#screen-result { justify-content: space-between; gap: 14px; }
.tabs { display: inline-flex; background: #fff; border-radius: 999px; padding: 4px; box-shadow: 0 3px 0 rgba(23,0,127,.2); }
.tab {
  border: 0; background: transparent; color: var(--blue);
  font-family: var(--display); font-weight: 700; font-size: 14px;
  padding: 8px 22px; border-radius: 999px; cursor: pointer;
}
.tab.active { background: var(--blue); color: #fff; }

.preview-wrap {
  flex: 1 1 0; min-height: 0; width: 100%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.preview-wrap img {
  max-width: 100%; max-height: 100%;
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(23,0,127,.35);
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}
.gif-wait { display: flex; flex-direction: column; align-items: center; gap: 12px; font-weight: 700; }
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid rgba(23,0,127,.15); border-top-color: var(--blue);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* Background picker */
.bg-picker {
  display: flex;
  gap: 12px;
  justify-content: center;
  max-width: 100%;
  overflow-x: auto;
  padding: 8px 6px 4px;
  scrollbar-width: none;
}
.bg-picker::-webkit-scrollbar { display: none; }
.bg-chip {
  flex: none;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: 0; background: none; padding: 0; cursor: pointer;
  font: inherit; font-size: 11px; font-weight: 800; color: var(--blue-deep);
}
.bg-chip canvas {
  width: 50px; height: 50px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 0 rgba(23,0,127,.25);
  transition: transform .15s ease, box-shadow .15s ease;
}
.bg-chip[aria-checked="true"] canvas {
  box-shadow: 0 0 0 3px var(--blue), 0 3px 0 3px var(--blue-deep);
  transform: translateY(-2px);
}
.bg-chip[aria-checked="true"] { color: var(--blue); }
.bg-chip:focus-visible { outline: none; }
.bg-chip:focus-visible canvas { outline: 3px solid var(--red); outline-offset: 3px; }
.bg-chip:disabled { opacity: .5; }

.busy {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(255,248,225,.72);
  font-weight: 800;
  border-radius: 12px;
}
.preview-wrap { position: relative; }

.result-actions { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.result-actions .hint { margin: 0; }

/* ── Done ───────────────────────────────── */
#screen-done h1 {
  margin: 8px 0 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(40px, 13vw, 60px);
  color: var(--blue);
  -webkit-text-stroke: 3px #fff;
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--blue-deep);
}
.thanks { margin: 0 0 12px; font-weight: 700; font-size: 17px; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom));
  transform: translate(-50%, 20px);
  background: var(--blue-deep); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 14px;
  opacity: 0; transition: all .25s; pointer-events: none; z-index: 10;
  max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .sunny .rays, #countdown.pop { animation: none; }
  #frame-guide, #video { transition: none; }
}
