:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #111318;
  color: #151922;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
}

button {
  min-height: 48px;
  border: 1px solid rgba(21, 25, 34, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #151922;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.photo-app {
  position: relative;
  min-height: 100vh;
  background: #f4f5f7;
}

.stage-wrap {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#cameraFeed,
#photoBackground,
#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#cameraFeed,
#photoBackground {
  object-fit: cover;
}

#cameraFeed {
  display: none;
}

#cameraFeed.mirrored {
  transform: scaleX(-1);
}

#photoBackground {
  display: none;
}

#stage {
  display: block;
  touch-action: none;
}

.loading {
  position: absolute;
  inset: 20px;
  display: grid;
  place-content: center;
  gap: 8px;
  color: rgba(21, 25, 34, 0.72);
  text-align: center;
  pointer-events: none;
}

.loading strong {
  font-size: 24px;
}

.loading span {
  font-size: 14px;
}

.loading.hidden {
  display: none;
}

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

.shutter-flash.active {
  animation: shutterFlash 260ms ease-out;
}

@keyframes shutterFlash {
  0% {
    opacity: 0;
  }

  32% {
    opacity: 0.82;
  }

  100% {
    opacity: 0;
  }
}

.controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  gap: 12px;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(14, 17, 24, 0.72), rgba(14, 17, 24, 0));
}

.store-title {
  display: grid;
  gap: 3px;
  color: #fff;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.34);
}

.store-title span {
  font-size: 18px;
  font-weight: 800;
}

.store-title small {
  min-height: 18px;
  font-size: 13px;
  opacity: 0.86;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.quick-actions button {
  min-width: 0;
  padding: 0 10px;
  font-size: 13px;
}

.quick-actions .fallback {
  display: none;
}

.quick-actions .fallback.visible {
  display: block;
}

.transform-actions button {
  min-height: 42px;
}

.shoot-button {
  min-height: 64px;
  border: 0;
  background: #2563eb;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.32);
}

.preview-dialog {
  width: min(92vw, 520px);
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
}

.preview-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.preview-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: #fff;
}

.preview-card img {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  border-radius: 8px;
  background: #f4f5f7;
}

.preview-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.preview-actions .primary {
  border-color: #2563eb;
  background: #2563eb;
  color: #fff;
}

@media (min-width: 760px) {
  .controls {
    left: 50%;
    right: auto;
    width: min(520px, calc(100vw - 48px));
    transform: translateX(-50%);
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  .controls {
    left: auto;
    right: 12px;
    top: auto;
    bottom: 12px;
    width: min(280px, 32vw);
    align-content: end;
    gap: 6px;
    padding: 8px;
    background: linear-gradient(to left, rgba(14, 17, 24, 0.68), rgba(14, 17, 24, 0));
  }

  .store-title {
    position: fixed;
    left: 10px;
    top: 8px;
    max-width: 46vw;
  }

  .store-title span {
    display: none;
  }

  .store-title small {
    font-size: 11px;
    opacity: 0.72;
  }

  .quick-actions {
    grid-template-columns: 1fr 1fr;
    gap: 5px;
  }

  .quick-actions button {
    min-height: 34px;
    font-size: 12px;
  }

  .shoot-button {
    min-height: 46px;
    font-size: 17px;
  }
}

@media (orientation: landscape) and (max-height: 420px) {
  .store-title {
    display: none;
  }

  .controls {
    width: min(250px, 30vw);
  }

  .quick-actions button {
    min-height: 30px;
    font-size: 11px;
  }

  .shoot-button {
    min-height: 42px;
    font-size: 16px;
  }
}
