:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  background: #2b2b2b;
}

body {
  font-family: 'Pangolin', cursive;
  letter-spacing: 0.05em;
  color: #575757;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

a { color: #4a90d9; text-decoration: none; }
a:hover { color: #357ab8; }

button {
  font-family: inherit;
}

#wrapper {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #3a3a3a;
  overflow: hidden;
}

/* The stage is a fixed 390x844 design canvas that scales uniformly to fit
   the viewport (mobile: fills close to edge-to-edge; desktop: centered
   phone-shaped card), so every absolute-position value below stays exact. */
#stage {
  position: relative;
  width: 390px;
  height: 844px;
  flex: 0 0 auto;
  background: #f4f3f0 url('../assets/paper.png') center top / cover no-repeat;
  overflow: hidden;
  transform-origin: center center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.screen {
  position: absolute;
  inset: 0;
}

/* ---- Primary pill button (used on welcome / how / frame) ---- */
.btn-primary {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 40px;
  height: 60px;
  border: none;
  border-radius: 32px;
  background: #26a68c;
  color: #fff;
  font-family: 'Pangolin', cursive;
  font-size: 24px;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.15s ease-in-out;
  z-index: 20;
}
/* :hover only for devices that actually have a pointer that can hover
   (mice/trackpads) — on touch, :hover has no real "unhover" moment, so it
   can visually stick after a tap and be mistaken for a broken press state. */
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: #219079; }
}
/* :active alone is unreliable on touch (iOS Safari won't apply :active on
   tap at all without a touch listener present); .pressed is toggled by JS
   (src/press-states.js) via pointer events for consistent feedback everywhere. */
.btn-primary:active, .btn-primary.pressed { transform: scale(0.97); background: #1f8570; }

/* ---- Image (PNG wordmark) buttons ---- */
.btn-image {
  position: absolute;
  left: 24px;
  right: 24px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.btn-image:active, .btn-image.pressed { transform: scale(0.98); }
.btn-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ---- Title-with-clover wrapper ---- */
.title-wrap {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
}
.title-wrap .rel {
  position: relative;
}
.title-wrap img.clover {
  position: absolute;
  width: 34px;
  height: auto;
}
.title-wrap img.title-img {
  display: block;
}

/* ---- Tabs (Frame Theme screen) ---- */
.tab-btn {
  font-family: 'Pangolin', cursive;
  font-size: 22px;
  letter-spacing: 0.03em;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 2px 4px;
  color: #b3b3b3;
  border-bottom: 2.5px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.tab-btn.active {
  color: #2f2f2f;
  border-bottom: 2.5px solid #2f2f2f;
}

.carousel {
  position: absolute;
  left: 0;
  right: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }
.carousel-row {
  display: flex;
  gap: 16px;
  padding: 6px 24px 14px;
}

.swatch {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  outline: none;
  padding: 0;
  overflow: hidden;
  background-color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.swatch.selected {
  box-shadow: 0 0 0 1px #2f2f2f;
  transform: translateY(-3px);
}
.swatch img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 7px;
}

/* ---- Frame preview / capture stage ---- */
.frame-preview {
  position: absolute;
  overflow: hidden;
}
.frame-preview img.frame-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.photo-overlay {
  position: absolute;
  object-fit: cover;
  z-index: 4;
}

video.live-video {
  position: absolute;
  object-fit: cover;
  transform: scaleX(-1);
  background: #000;
  z-index: 5;
}

/* Decorations that overlap the photo slots (e.g. a frame's stars poking
   over a corner), kept on their own transparent layer so they stay visible
   above captured photos and the live camera instead of getting covered. */
.frame-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 6;
}

/* Same idea, but for a frame whose overlapping decorations are several
   individually-positioned pieces instead of one full-canvas image. */
.frame-overlay-piece {
  position: absolute;
  display: block;
  pointer-events: none;
  z-index: 6;
}

.countdown-overlay {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 72px;
  line-height: 1;
  z-index: 7;
}

.cam-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  font-family: 'Pangolin', cursive;
  font-size: 16px;
  line-height: 1.4;
  padding: 24px;
  cursor: pointer;
  z-index: 8;
}
.cam-fallback:active, .cam-fallback.pressed { background: rgba(0, 0, 0, 0.7); }
.cam-fallback img { width: 48px; height: 48px; }

.shutter-btn {
  position: absolute;
  bottom: 70px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 76px;
  height: 76px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.shutter-btn:active, .shutter-btn.pressed { transform: scale(0.94); }
.shutter-btn img { width: 100%; height: 100%; display: block; }

/* ---- Filter circles ---- */
.filter-circle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
  box-shadow: none;
  transition: box-shadow 0.18s ease, width 0.18s ease, height 0.18s ease;
}
.filter-circle.selected {
  width: 68px;
  height: 68px;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}
.filter-circle img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.filter-circle.selected img {
  width: 58px;
  height: 58px;
}

.filter-name {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 22px;
  color: #2f2f2f;
}

/* ---- Caption input ---- */
.caption-label {
  position: absolute;
  font-size: 20px;
  color: #2f2f2f;
}
.caption-input {
  position: absolute;
  border: 1px solid #d8d6d0;
  border-radius: 12px;
  background: #fbfbf9;
  padding: 0 14px;
  font-family: 'Pangolin', cursive;
  font-size: 16px;
  color: #2f2f2f;
  outline: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.caption-input:focus {
  border-color: #26a68c;
}

/* ---- Done screen overlay text ---- */
.done-text {
  position: absolute;
  color: #ffffff;
  font-size: 13px;
  line-height: 1.45;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  z-index: 10; /* stay above any frame-overlay decorations */
}
.done-text .caption-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 190px;
  text-align: center;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 15px;
  padding: 10px 16px;
  border-radius: 14px;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.toast.visible { opacity: 1; }
