@font-face {
  font-family: 'Cubano';
  src: url('assets/fonts/Cubano.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --art-w: 2532;
  --art-h: 1170;
  --stage-ratio: calc(var(--art-w) / var(--art-h));

  /* Coordinates based on the 2532 x 1170 camera artwork. */
  --viewfinder-x: 1120;
  --viewfinder-y: 105;
  --viewfinder-w: 332;
  --viewfinder-h: 180;

  --counter-x: 386;
  --counter-y: 77;
  --counter-w: 158;
  --counter-h: 157;

  --button-x: 1985;
  --button-y: 350;
  --button-w: 353;
  --button-h: 98;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background: #000;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

.app {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  background: #000;
  overflow: hidden;
}

.stage,
.start-screen,
.finished-screen {
  position: relative;
  width: min(100vw, calc(100dvh * var(--stage-ratio)));
  aspect-ratio: var(--art-w) / var(--art-h);
  overflow: hidden;
  background: #050505;
}

.simple-finished-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  aspect-ratio: auto;
  background: #ed1a4e;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  z-index: 999;
}

.simple-finished-screen[hidden] {
  display: none;
}

.simple-finished-screen .retra-logo {
  position: static;
  inset: auto;
  width: min(58vw, 260px);
  height: auto;
  max-height: 120px;
  object-fit: contain;
  display: block;
  margin: 0 0 4px;
  z-index: 2;
}

.simple-finished-screen h1 {
  margin: 0;
  font-family: 'Cubano', system-ui, sans-serif;
  font-size: clamp(42px, 10vw, 72px);
  font-weight: normal;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.simple-finished-screen p {
  max-width: 320px;
  margin: 0;
  font-size: 17px;
  line-height: 1.4;
  opacity: 0.78;
}

.simple-finished-screen .album-form {
  position: static;
  transform: none;
  width: min(88vw, 420px);
  margin-top: 8px;
  background: transparent;
  padding: 0;
  backdrop-filter: none;
}


.homescreen-prompt {
  position: fixed;
  inset: 0;
  z-index: 120;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #000;
  overflow: hidden;
}

.homescreen-prompt img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  pointer-events: none;
}

.homescreen-continue-button {
  position: absolute;
  inset: 0;
  z-index: 5;
  border: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.start-screen img,
.finished-screen img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  pointer-events: none;
  z-index: 1;
}

.album-form {
  position: absolute;
  left: 50%;
  bottom: 7%;
  z-index: 30;
  transform: translateX(-50%);
  width: min(78%, 420px);
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.2vw, 14px);
  padding: clamp(10px, 1.5vw, 18px);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
}

.album-form[hidden] {
  display: none;
}

.album-form input,
.album-form button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-size: clamp(13px, 1.4vw, 17px);
  text-align: center;
}

.album-form input {
  background: #fff;
  color: #111;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

.album-form input::placeholder {
  color: rgba(0, 0, 0, 0.55);
}

.album-form button {
  background: #171717;
  color: #fff;
  font-family: 'Cubano', system-ui, sans-serif;
  font-weight: normal;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  -webkit-tap-highlight-color: transparent;
}

.album-form button:disabled {
  opacity: 0.6;
  cursor: default;
}

#albumStatusMessage {
  margin: 0;
  color: #fff;
  font-size: clamp(12px, 1.2vw, 15px);
  line-height: 1.3;
  text-align: center;
}

#albumStatusMessage[hidden] {
  display: none;
}

#albumStatusMessage.error {
  color: #ff6b6b;
}


.load-camera-button {
  position: absolute;
  inset: 0;
  z-index: 5;
  border: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.loading-state,
.message {
  position: absolute;
  left: 50%;
  bottom: 7%;
  transform: translateX(-50%);
  z-index: 70;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: clamp(12px, 1.5vw, 18px);
  letter-spacing: 0.04em;
}

.camera-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 30;
  pointer-events: none;
}

.viewfinder {
  position: absolute;
  left: calc(var(--viewfinder-x) / var(--art-w) * 100%);
  top: calc(var(--viewfinder-y) / var(--art-h) * 100%);
  width: calc(var(--viewfinder-w) / var(--art-w) * 100%);
  height: calc(var(--viewfinder-h) / var(--art-h) * 100%);
  object-fit: cover;
  z-index: 10;
  background: #111;
}

.counter-wheel {
  position: absolute;
  left: calc(var(--counter-x) / var(--art-w) * 100%);
  top: calc(var(--counter-y) / var(--art-h) * 100%);
  width: calc(var(--counter-w) / var(--art-w) * 100%);
  height: calc(var(--counter-h) / var(--art-h) * 100%);
  object-fit: cover;
  z-index: 20;
  pointer-events: auto;
  border-radius: 999px;
}

.shutter-button {
  position: absolute;
  left: calc(var(--button-x) / var(--art-w) * 100%);
  top: calc(var(--button-y) / var(--art-h) * 100%);
  width: calc(var(--button-w) / var(--art-w) * 100%);
  height: calc(var(--button-h) / var(--art-h) * 100%);
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  z-index: 50;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.shutter-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.shutter-button:disabled {
  opacity: 0.75;
  cursor: default;
}

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

.flash.on { animation: flash-pop 150ms ease-out; }

@keyframes flash-pop {
  0% { opacity: 0; }
  20% { opacity: 0.9; }
  100% { opacity: 0; }
}

.portrait-warning {
  display: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  min-width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: -webkit-fill-available;
  z-index: 100;
  background: #000;
  overflow: hidden;
}

.portrait-warning img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  transform: translate(-50%, -50%);
  display: block;
  pointer-events: none;
}

@media (orientation: portrait) and (max-width: 900px) {
  .portrait-warning { display: block; }
  body.album-mode .portrait-warning { display: none; }
}
