:root {
  --red: #A9232A;
  --red-dark: #74171D;
  --cream: #F6E7D5;
  --paper: #F2E1CE;
  --ink: #2E1A18;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: #160C0D;
  color: var(--cream);
  font-family: Arial, Helvetica, sans-serif;
}
body {
  min-height: 100dvh;
  overflow: hidden;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }

#app {
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
}
.screen {
  position: absolute;
  inset: 0;
  display: none;
  min-height: 100dvh;
  overflow-y: auto;
}
.screen--active { display: flex; }

.noise,
.camera-grain {
  pointer-events: none;
  position: absolute;
  inset: 0;
  opacity: .16;
  mix-blend-mode: soft-light;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.25) 0 1px, transparent 1.4px),
    radial-gradient(circle at 70% 60%, rgba(0,0,0,.32) 0 1px, transparent 1.4px);
  background-size: 7px 7px, 11px 11px;
  animation: grain .28s steps(2) infinite;
}
@keyframes grain {
  0% { transform: translate(0,0); }
  25% { transform: translate(-1%,1%); }
  50% { transform: translate(1%,-1%); }
  75% { transform: translate(1%,1%); }
}

.primary-button,
.secondary-button {
  min-height: 50px;
  border: 1px solid var(--cream);
  padding: 12px 16px;
  letter-spacing: .12em;
  font-size: 11px;
}
.primary-button {
  color: var(--red-dark);
  background: var(--cream);
  font-weight: 700;
}
.secondary-button {
  color: var(--cream);
  background: transparent;
}
.primary-button--large {
  width: min(72vw, 320px);
  min-height: 58px;
  font-size: 13px;
  margin: 2px auto 0;
  display: block;
}

.home-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: calc(22px + var(--safe-top)) 18px calc(22px + var(--safe-bottom));
  background:
    linear-gradient(rgba(22,10,11,.10), rgba(22,10,11,.76)),
    repeating-linear-gradient(90deg, #982128 0 5px, var(--red) 5px 10px);
}
.brand {
  position: relative;
  z-index: 2;
  width: min(58vw, 245px);
  text-align: center;
}
.brand-logo {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}
.subtitle {
  margin: 10px 0 0;
  font-size: 10px;
  letter-spacing: .28em;
  padding-left: .34em;
}
.home-machine {
  width: min(72vw, 320px);
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2;
  filter: drop-shadow(0 20px 22px rgba(0,0,0,.3));
}
.privacy-note {
  z-index: 2;
  max-width: 330px;
  margin-top: 6px;
  margin: 0;
  text-align: center;
  font-size: 10px;
  line-height: 1.5;
  opacity: .7;
}

/* Camera */
.camera-screen { background: #080808; }
#cameraVideo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111;
}
#cameraVideo.mirrored { transform: scaleX(-1); }
.camera-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.45), transparent 23%, transparent 72%, rgba(0,0,0,.7)),
    radial-gradient(circle, transparent 45%, rgba(0,0,0,.24));
}
.camera-header {
  position: absolute;
  z-index: 5;
  left: 0; right: 0; top: 0;
  padding: calc(14px + var(--safe-top)) 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.round-button {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.7);
  color: white;
  background: rgba(0,0,0,.28);
  font-size: 25px;
  display: grid;
  place-items: center;
}
.shot-progress {
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.34);
  font-size: 11px;
  letter-spacing: .22em;
}
.camera-guide {
  position: absolute;
  z-index: 3;
  inset: 17% 8% 28%;
  border: 1px solid rgba(255,255,255,.22);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.camera-guide p {
  margin: 0 0 12px;
  font-size: 9px;
  letter-spacing: .2em;
  text-shadow: 0 1px 4px #000;
}
.camera-guide__corners::before,
.camera-guide__corners::after,
.camera-guide::before,
.camera-guide::after {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: white;
  border-style: solid;
}
.camera-guide::before { left: -1px; top: -1px; border-width: 2px 0 0 2px; }
.camera-guide::after { right: -1px; top: -1px; border-width: 2px 2px 0 0; }
.camera-guide__corners::before { left: -1px; bottom: -1px; border-width: 0 0 2px 2px; }
.camera-guide__corners::after { right: -1px; bottom: -1px; border-width: 0 2px 2px 0; }

.countdown {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: Georgia, serif;
  font-size: 44vw;
  font-style: italic;
  color: white;
  text-shadow: 0 6px 30px #000;
  pointer-events: none;
}
.countdown:empty { display: none; }
.flash {
  position: absolute;
  z-index: 10;
  inset: 0;
  opacity: 0;
  background: white;
  pointer-events: none;
}
.flash.fire { animation: flash .34s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

.camera-footer {
  position: absolute;
  z-index: 5;
  left: 0; right: 0; bottom: 0;
  padding: 10px 20px calc(25px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
}
.camera-footer p {
  margin: 0 0 14px;
  font-family: Georgia, serif;
  font-size: 13px;
  font-style: italic;
  text-shadow: 0 2px 4px #000;
}
.shutter {
  width: 78px; height: 78px;
  padding: 6px;
  border-radius: 50%;
  border: 3px solid white;
  background: rgba(255,255,255,.16);
}
.shutter span {
  display: block;
  width: 100%; height: 100%;
  border-radius: 50%;
  background: var(--cream);
}
.shutter:disabled { opacity: .45; }

.error-card {
  z-index: 30;
  padding: 22px 18px;
  color: var(--cream);
  text-align: center;
  background: rgba(55,14,17,.97);
  border: 1px solid var(--cream);
  box-shadow: 0 18px 40px rgba(0,0,0,.35);
}
.camera-screen .error-card {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 28%;
}
.error-card h2 {
  margin: 0 0 8px;
  font-family: Georgia, serif;
}
.error-card p {
  margin: 0 0 16px;
  font-size: 12px;
  line-height: 1.5;
}
.file-button input { display: none; }

/* Develop */
.develop-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: calc(22px + var(--safe-top)) 18px calc(22px + var(--safe-bottom));
  background:
    linear-gradient(rgba(22,10,11,.1), rgba(22,10,11,.78)),
    repeating-linear-gradient(90deg, #982128 0 5px, var(--red) 5px 10px);
}
.develop-copy {
  text-align: center;
  z-index: 4;
}
.develop-copy p {
  margin: 0 0 9px;
  font-size: 10px;
  letter-spacing: .4em;
}
.develop-copy h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: clamp(34px, 10vw, 52px);
  font-style: italic;
  font-weight: 400;
}
.instant-machine {
  position: relative;
  width: min(90vw, 430px);
  min-height: 760px;
}
.instant-machine > img {
  position: absolute;
  z-index: 5;
  left: 0;
  top: 0;
  width: 100%;
  filter: drop-shadow(0 20px 24px rgba(0,0,0,.30));
}
#developCanvas {
  position: absolute;
  z-index: 2;
  left: 53.6%;
  top: 80.8%;
  width: 78.2%;
  height: auto;
  transform: translate(-50%, -96%);
  transform-origin: top center;
  background: var(--paper);
  border-radius: 6px;
  box-shadow:
    0 14px 24px rgba(0,0,0,.30),
    0 2px 0 rgba(255,255,255,.38) inset;
  opacity: 0;
}
#developCanvas.eject {
  animation: eject 2.45s cubic-bezier(.16,.72,.22,1) forwards;
}
@keyframes eject {
  0% {
    transform: translate(-50%, -100%);
    opacity: .06;
    filter: blur(4px) brightness(1.22);
  }
  38% {
    opacity: .65;
    filter: blur(1.4px) brightness(1.08);
  }
  100% {
    transform: translate(-50%, -6%);
    opacity: 1;
    filter: none;
  }
}
.processing-error {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  max-width: 420px;
  margin: auto;
}

/* Result */
.result-screen {
  flex-direction: column;
  padding: calc(12px + var(--safe-top)) 14px calc(24px + var(--safe-bottom));
  background:
    linear-gradient(rgba(22,10,11,.14), rgba(22,10,11,.86)),
    repeating-linear-gradient(90deg, #982128 0 5px, var(--red) 5px 10px);
}
.result-header {
  min-height: 42px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}
.result-header p {
  margin: 0;
  text-align: center;
  font-size: 8px;
  letter-spacing: .2em;
}
.text-button {
  padding: 10px 0;
  border: 0;
  color: var(--cream);
  background: transparent;
  font-size: 10px;
  letter-spacing: .1em;
}
.text-button:last-child { text-align: right; }

.result-stage {
  width: min(84vw, 360px);
  margin: 8px auto 12px;
}
#resultCanvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 16px 28px rgba(0,0,0,.32);
}
.filter-section {
  width: min(100%, 540px);
  margin: 0 auto;
  padding-top: 10px;
  border-top: 1px solid rgba(246,231,213,.18);
}
.filter-section > p {
  margin: 0 0 8px;
  font-size: 8px;
  letter-spacing: .3em;
  opacity: .68;
}
.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid rgba(246,231,213,.45);
  color: var(--cream);
  background: transparent;
  font-size: 9px;
  letter-spacing: .1em;
}
.chip--active {
  color: var(--red-dark);
  background: var(--cream);
  border-color: var(--cream);
}
.result-actions {
  width: min(100%, 540px);
  margin: 12px auto 0;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 9px;
}
.save-note {
  margin: 10px 0 0;
  text-align: center;
  font-size: 10px;
  opacity: .6;
}

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: calc(25px + var(--safe-bottom));
  transform: translate(-50%, 30px);
  opacity: 0;
  pointer-events: none;
  padding: 11px 16px;
  color: var(--red-dark);
  background: var(--cream);
  box-shadow: 0 7px 22px rgba(0,0,0,.35);
  font-size: 11px;
  white-space: nowrap;
  transition: .25s ease;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%,0);
}

@media (min-width: 820px) {
  .brand { width: 250px; }
  .home-machine { width: 340px; }
  .primary-button--large { width: 330px; }
  .instant-machine { width: 440px; }
}
