:root {
  color-scheme: light;
  font-family: Arial, "Helvetica Neue", sans-serif;
  background: #f7f4ef;
  color: #0b0b0b;
  font-synthesis: none;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

.screen {
  display: none;
  position: fixed;
  inset: 0;
  min-height: 100dvh;
}

.screen.is-active {
  display: flex;
}

.landing-screen {
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: calc(44px + var(--safe-top)) max(28px, var(--safe-right)) calc(24px + var(--safe-bottom)) max(28px, var(--safe-left));
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.96) 0 22%, rgba(247, 244, 239, 0) 58%),
    #f7f4ef;
  isolation: isolate;
}

.landing-content {
  position: relative;
  z-index: 2;
  margin: auto 0;
  text-align: center;
}

.eyebrow {
  margin: 0 0 15px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.28em;
}

.landing-content h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(4.6rem, 25vw, 8.2rem);
  font-weight: 400;
  letter-spacing: -0.075em;
  line-height: 0.7;
}

.landing-copy {
  margin: 26px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  font-style: italic;
  letter-spacing: 0.05em;
}

.landing-actions {
  position: relative;
  z-index: 3;
  width: min(100%, 420px);
  margin: 0 auto;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 56px;
  padding: 16px 24px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.primary-button {
  background: #0b0b0b;
  color: #fff;
}

.primary-button:active {
  background: #2a2a2a;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.secondary-button {
  border: 1px solid #0b0b0b;
  background: transparent;
}

.privacy-note {
  margin: 12px 0 0;
  color: #68645f;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-align: center;
}

.landing-art {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.card {
  display: flex;
  position: absolute;
  width: 112px;
  aspect-ratio: 0.7;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid rgba(11, 11, 11, 0.18);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.54);
  box-shadow: 0 18px 42px rgba(15, 13, 10, 0.08);
  font-family: Georgia, serif;
  font-size: 1.6rem;
}

.card i {
  align-self: flex-end;
  font-style: normal;
}

.card-one {
  top: 13%;
  left: -46px;
  transform: rotate(-17deg);
}

.card-two {
  top: 9%;
  right: -50px;
  transform: rotate(13deg);
}

.card-three {
  right: -30px;
  bottom: 24%;
  transform: rotate(-8deg);
}

.camera-screen {
  flex-direction: column;
  background: #090909;
  color: #fff;
}

.camera-header,
.result-header {
  flex: 0 0 auto;
}

.camera-header {
  display: grid;
  min-height: calc(58px + var(--safe-top));
  grid-template-columns: 48px 1fr 48px;
  align-items: end;
  padding: var(--safe-top) max(12px, var(--safe-right)) 10px max(12px, var(--safe-left));
}

.camera-header p {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-align: center;
}

.icon-button,
.control-button {
  cursor: pointer;
  background: transparent;
  color: #fff;
}

.plain-icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
}

.plain-icon-button svg {
  width: 27px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.camera-stage-wrap {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  padding: 0 max(8px, var(--safe-right)) 4px max(8px, var(--safe-left));
}

.camera-stage {
  position: relative;
  width: min(100%, calc((100dvh - 178px - var(--safe-top) - var(--safe-bottom)) * 8 / 9));
  max-height: calc(100dvh - 178px - var(--safe-top) - var(--safe-bottom));
  aspect-ratio: 8 / 9;
  overflow: hidden;
  background: #161616;
}

#cameraVideo {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#previewCanvas,
#frameOverlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#previewCanvas {
  display: block;
}

#frameOverlay {
  z-index: 2;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
}

.camera-message {
  display: flex;
  position: absolute;
  inset: 0;
  z-index: 3;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #151515;
  text-align: center;
}

.camera-message p {
  width: min(80%, 280px);
  margin: 16px auto;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  line-height: 1.7;
}

.camera-message[hidden] {
  display: none;
}

.loading-ring {
  width: 30px;
  height: 30px;
  border: 1px solid #555;
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.text-button {
  border-bottom: 1px solid currentColor;
  padding: 7px 2px;
  cursor: pointer;
  background: transparent;
  color: #fff;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
}

.capture-flash {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.capture-flash.is-flashing {
  animation: flash 220ms ease-out;
}

@keyframes flash {
  0% { opacity: 0; }
  35% { opacity: 0.88; }
  100% { opacity: 0; }
}

.camera-controls {
  display: grid;
  min-height: calc(116px + var(--safe-bottom));
  flex: 0 0 auto;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  padding: 8px max(20px, var(--safe-right)) calc(14px + var(--safe-bottom)) max(20px, var(--safe-left));
}

.control-button {
  display: flex;
  width: 68px;
  min-height: 64px;
  flex-direction: column;
  gap: 7px;
  align-items: center;
  justify-content: center;
  justify-self: center;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
}

.control-button svg {
  width: 26px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.35;
}

.control-button:disabled,
.capture-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.frame-icon {
  display: block;
  width: 22px;
  height: 27px;
  border: 1px solid currentColor;
  box-shadow: inset 0 0 0 4px #090909, inset 0 0 0 5px currentColor;
}

.capture-button {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  justify-self: center;
  border: 2px solid #fff;
  border-radius: 50%;
  padding: 5px;
  cursor: pointer;
  background: transparent;
}

.capture-button span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #fff;
  transition: transform 120ms ease;
}

.capture-button:active span {
  transform: scale(0.9);
}

.result-screen {
  flex-direction: column;
  overflow-y: auto;
  padding: calc(34px + var(--safe-top)) max(24px, var(--safe-right)) calc(24px + var(--safe-bottom)) max(24px, var(--safe-left));
  background: #f7f4ef;
}

.result-header {
  text-align: center;
}

.result-header .eyebrow {
  margin-bottom: 7px;
}

.result-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
  font-weight: 400;
}

.result-image-wrap {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
}

#resultImage {
  display: block;
  width: min(100%, 390px, calc((100dvh - 268px - var(--safe-top) - var(--safe-bottom)) * 8 / 9));
  max-height: calc(100dvh - 268px - var(--safe-top) - var(--safe-bottom));
  aspect-ratio: 8 / 9;
  background: #ddd;
  box-shadow: 0 16px 38px rgba(20, 17, 12, 0.15);
  object-fit: contain;
}

.result-actions {
  width: min(100%, 420px);
  flex: 0 0 auto;
  margin: 0 auto;
}

.result-actions .secondary-button {
  margin-top: 10px;
}

.download-hint {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: #5e5a55;
  font-size: 0.68rem;
  line-height: 1.5;
  text-align: center;
}

.orientation-notice {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  background: #090909;
  color: #fff;
  text-align: center;
}

.orientation-notice span {
  font-size: 2.4rem;
}

.orientation-notice p {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (orientation: landscape) and (max-height: 600px) and (pointer: coarse) {
  .orientation-notice {
    display: flex;
  }
}

@media (min-width: 760px) {
  .card {
    width: 160px;
  }

  .card-one { left: 6%; }
  .card-two { right: 6%; }
  .card-three { right: 12%; }

  .camera-stage {
    width: min(70vw, calc((100dvh - 188px - var(--safe-top) - var(--safe-bottom)) * 8 / 9));
    max-height: calc(100dvh - 188px - var(--safe-top) - var(--safe-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
