:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #070713;
  font-family: Arial, Helvetica, sans-serif;
}

button {
  font: inherit;
}

.experience {
  position: relative;
  width: min(100vw, 430px, calc(100vh * 9 / 16));
  width: min(100vw, 430px, calc(100dvh * 9 / 16));
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: #070713;
}

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

.screen[hidden],
[hidden] {
  display: none !important;
}

.screen-media,
.screen-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
}

.screen-media {
  background: #070713;
}

.sound-toggle {
  position: absolute;
  z-index: 18;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  width: 46px;
  height: 46px;
  min-width: 44px;
  min-height: 44px;
  padding: 7px;
  border: 1px solid rgba(245, 207, 119, .92);
  border-radius: 50%;
  color: #f5cf77;
  background: rgba(50, 16, 24, .76);
  box-shadow: 0 2px 12px rgba(0, 0, 0, .42);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sound-toggle:active,
.sound-toggle.is-pressed {
  transform: scale(.94);
}

.sound-toggle:focus-visible {
  outline: 2px solid #fff2bf;
  outline-offset: 2px;
}

.sound-icon {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.sound-icon__speaker {
  fill: currentColor;
}

.sound-icon__waves,
.sound-icon__slash {
  fill: none;
  stroke: currentColor;
  stroke-width: 3.5;
  stroke-linecap: round;
  transition: opacity 160ms ease;
}

.sound-icon__slash { opacity: 0; }
.sound-toggle.is-muted .sound-icon__waves { opacity: 0; }
.sound-toggle.is-muted .sound-icon__slash { opacity: 1; }
body.is-checkin-open .sound-toggle { display: none; }

.intro-skip {
  position: absolute;
  z-index: 7;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  min-width: 72px;
  min-height: 44px;
  padding: 6px 16px;
  border: 1px solid rgba(245, 207, 119, 0.9);
  border-radius: 999px;
  color: #f5cf77;
  background: rgba(50, 16, 24, 0.72);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.intro-skip:active {
  transform: scale(0.96);
}

.intro-skip:focus-visible {
  outline: 2px solid #fff2bf;
  outline-offset: 2px;
}

.dialogue-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.dialogue-art {
  position: absolute;
  width: 82%;
  height: auto;
}

.dialogue-art--left {
  left: 1%;
  top: 49%;
}

.dialogue-art--right {
  right: 1%;
  top: 60%;
}

.art-button {
  position: absolute;
  z-index: 5;
  left: 50%;
  width: 78%;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translateX(-50%);
  cursor: pointer;
  touch-action: manipulation;
}

.art-button img {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 50% 50%;
}

.art-button--start,
.art-button--continue,
.art-button--search,
.art-button--puzzle,
.art-button--return {
  bottom: calc(-7% + env(safe-area-inset-bottom));
}

.puzzle-screen .art-button--final-start {
  width: 45.25%;
  bottom: calc(9% + env(safe-area-inset-bottom));
}

.media-screen[data-media-screen="intro"] .art-button--start {
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
}

.art-button:focus-visible {
  outline: 3px solid #f5cf77;
  outline-offset: -20px;
}

.puzzle-grid {
  position: absolute;
  z-index: 2;
  left: 6.6%;
  top: 23.8%;
  width: 86.8%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  background: #c88a55;
}

.victory-animation {
  position: absolute;
  z-index: 5;
  left: 6.6%;
  top: 23.8%;
  width: 86.8%;
  aspect-ratio: 1;
  object-fit: contain;
  pointer-events: none;
}

.victory-end-frame {
  position: absolute;
  z-index: 4;
  left: 6.6%;
  top: 23.8%;
  width: 86.8%;
  aspect-ratio: 1;
  object-fit: contain;
  opacity: 0;
  pointer-events: none;
}

.puzzle-tile,
.puzzle-empty {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid #63351f;
  border-radius: 0;
  background: #c88a55;
}

.puzzle-tile {
  background-repeat: no-repeat;
  background-size: 300% 300%;
  cursor: pointer;
  touch-action: manipulation;
}

.puzzle-empty {
  display: block;
  box-shadow: inset 0 0 28px rgba(87, 38, 14, 0.25);
}

.puzzle-grid.is-complete .puzzle-tile {
  cursor: default;
}

.puzzle-restore {
  position: absolute;
  z-index: 5;
  top: 74.5%;
  left: 50%;
  min-width: 34%;
  min-height: 42px;
  padding: 8px 20px;
  transform: translateX(-50%);
  border: 2px solid #d9a657;
  border-radius: 999px;
  color: #ffe7a5;
  background: linear-gradient(#7a3e1d, #3d190d);
  box-shadow: 0 3px 0 #1d0b06, inset 0 0 0 2px rgba(255, 222, 145, .18);
  font: 700 16px/1 sans-serif;
  text-shadow: 0 1px 2px #1d0b06;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.puzzle-restore:active { transform: translateX(-50%) scale(.96); }
.puzzle-restore:disabled { opacity: .55; cursor: default; }
.puzzle-restore:focus-visible { outline: 2px solid #fff2bf; outline-offset: 2px; }

.puzzle-status {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 16%;
  margin: 0;
  transform: translateX(-50%);
  color: #ffe6a6;
  font-weight: 700;
  text-shadow: 0 2px 5px #32160f;
}

.puzzle-status:empty {
  display: none;
}

@media (max-height: 620px) {
  .art-button {
    width: 70%;
  }

  .puzzle-status {
    bottom: 14%;
  }
}

.art-button.is-ready img {
  animation: button-breathe 1600ms ease-in-out infinite;
}

.art-button.is-offset img {
  animation-delay: 400ms;
}

.art-button.is-pressed img {
  animation: none;
  transform: scale(.97);
}

@keyframes button-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.screen {
  opacity: 1;
  transition: opacity var(--scene-duration, 300ms) ease;
}

.screen.is-fading {
  opacity: 0;
  pointer-events: none;
}

.scene-transition {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  background: #070713;
  transition: opacity var(--scene-duration, 300ms) ease;
}

.scene-transition.is-visible { opacity: 1; }

.puzzle-grid {
  transition: opacity 350ms ease, filter 450ms ease, box-shadow 450ms ease;
}

.puzzle-grid.is-entering {
  opacity: 0;
  pointer-events: none;
}

.puzzle-grid.is-celebrating {
  filter: brightness(1.12);
  box-shadow: 0 0 24px 8px rgba(255, 205, 105, .78);
  pointer-events: none;
}

.final-actions {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom);
  width: 100%;
  height: 16%;
}

.final-actions .art-button {
  position: absolute;
  top: 50%;
  bottom: auto;
}

.final-actions .art-button--return {
  left: 50%;
  width: 78%;
  transform: translate(-50%, -50%);
}

.final-actions .art-button--share {
  left: auto;
  right: 4%;
  width: 15%;
  transform: translateY(-50%);
}

.share-guide {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  align-content: start;
  justify-items: end;
  gap: 14px;
  padding: max(28px, env(safe-area-inset-top)) 22px 28px;
  color: #ffe3a0;
  background: rgba(5, 6, 17, .76);
  opacity: 0;
  transition: opacity 200ms ease;
}

.share-guide.is-visible { opacity: 1; }
.share-guide__arrow { font-size: 64px; line-height: 1; color: #efbb59; }
.share-guide p { margin: 0; font-size: clamp(20px, 6vw, 28px); font-weight: 700; }

.share-guide__close {
  position: absolute;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  border: 0;
  color: #fff2ce;
  background: transparent;
  text-decoration: underline;
}

.checkin-overlay,
.checkin-save-preview {
  position: fixed;
  z-index: 40;
  inset: 0;
  width: min(100vw, 430px, calc(100vh * 9 / 16));
  width: min(100vw, 430px, calc(100dvh * 9 / 16));
  margin: auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  background: rgba(7, 3, 13, .82);
}

.checkin-overlay {
  display: grid;
  place-items: center;
}

.checkin-dialog {
  position: relative;
  width: 100%;
  max-height: 94%;
  overflow: auto;
  padding: 20px 18px 18px;
  border: 2px solid #bd843d;
  border-radius: 22px;
  color: #fff0c5;
  background: linear-gradient(180deg, rgba(91, 18, 33, .98), rgba(35, 8, 18, .98));
  box-shadow: 0 14px 42px rgba(0, 0, 0, .62), inset 0 0 24px rgba(244, 185, 88, .16);
  text-align: center;
  -webkit-overflow-scrolling: touch;
}

.checkin-dialog h2 {
  margin: 0 0 6px;
  color: #f4c76f;
  font-size: clamp(23px, 7vw, 30px);
}

.checkin-lead {
  margin: 6px 0 12px;
  font-size: 15px;
  line-height: 1.45;
}

.checkin-photo-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.checkin-control,
.checkin-primary,
.checkin-secondary {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid #e8bb69;
  border-radius: 999px;
  color: #3b140c;
  background: linear-gradient(#ffe39a, #d99c43);
  font-weight: 700;
  cursor: pointer;
}

.checkin-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.checkin-crop-frame {
  position: relative;
  width: min(64%, 230px);
  aspect-ratio: 662 / 867;
  margin: 0 auto 12px;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background: #fff;
}

.checkin-crop-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.checkin-crop-hint {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  margin: 0;
  padding: 7px 5px;
  color: #fff7dc;
  background: rgba(0, 0, 0, .55);
  font-size: 12px;
}

.checkin-primary,
.checkin-secondary {
  width: 100%;
  margin-top: 10px;
}

.checkin-secondary {
  color: #ffeab7;
  background: rgba(68, 15, 27, .82);
}

.checkin-primary:disabled {
  cursor: default;
  filter: grayscale(.7);
  opacity: .48;
}

.checkin-skip {
  min-height: 44px;
  margin-top: 8px;
  border: 0;
  color: #e7c98d;
  background: transparent;
  text-decoration: underline;
}

.sticker-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.sticker-card {
  position: relative;
  padding: 0;
  aspect-ratio: 3 / 4;
  overflow: visible;
  border: 0;
  border-radius: 10px;
  background: transparent;
  perspective: 900px;
  transition: transform 320ms ease, filter 320ms ease, box-shadow 320ms ease;
}

.sticker-card__inner {
  position: absolute;
  inset: 0;
  display: block;
  transform-style: preserve-3d;
  transition: transform var(--flip-duration, 180ms) cubic-bezier(.22, .72, .2, 1) var(--flip-delay, 0ms);
}

.sticker-card__front,
.sticker-card__back {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  border: 2px solid #d5a451;
  border-radius: 10px;
  backface-visibility: hidden;
  box-shadow: inset 0 0 0 4px rgba(255, 216, 123, .14);
}

.sticker-card__back {
  background-color: #621426;
  background-image: url('assets/ui/sticker-card-back.webp');
  background-position: center;
  background-size: cover;
}

.sticker-card__front {
  background: #f3dfad;
  transform: rotateY(180deg);
}

.sticker-card__front img {
  position: absolute;
  inset: 5%;
  width: 90%;
  height: 90%;
  object-fit: contain;
}

.sticker-card.is-flipping .sticker-card__inner { will-change: transform; }
.sticker-card.is-revealed .sticker-card__inner { transform: rotateY(180deg); }
.sticker-card.is-selected {
  z-index: 2;
  transform: scale(1.1);
  box-shadow: 0 0 18px 5px rgba(255, 212, 85, .82);
}
.sticker-card.is-selected .sticker-card__front { border-color: #fff0a8; }
.sticker-card.is-dimmed { filter: brightness(.45) saturate(.55); }

@media (prefers-reduced-motion: reduce) {
  .sticker-card__inner {
    transition-property: opacity;
    transition-duration: 180ms !important;
    transition-delay: var(--flip-delay, 0ms) !important;
  }

  .sticker-card.is-revealed .sticker-card__inner {
    transform: rotateY(180deg);
  }
}

.checkin-result-image {
  display: block;
  width: min(66%, 230px);
  aspect-ratio: 662 / 867;
  margin: 0 auto;
  object-fit: contain;
  border: 2px solid #e5b85e;
  border-radius: 10px;
  background: #13080e;
}

.checkin-save-preview {
  z-index: 50;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  justify-items: center;
  color: #fff3c6;
  background: rgba(3, 2, 7, .96);
}

.checkin-save-preview p { margin: 0; font-weight: 700; }
.checkin-save-preview img { width: auto; max-width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.checkin-save-preview button {
  min-width: 112px;
  min-height: 44px;
  border: 1px solid #e0b55f;
  border-radius: 999px;
  color: #fff0bf;
  background: #63182b;
}

.curtain-transition {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  overflow: hidden;
}

.curtain-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 52%;
  background: linear-gradient(90deg, #35050e, #7a1426 48%, #3a0711);
  transition: transform 600ms cubic-bezier(.65, 0, .35, 1);
}

.curtain-panel--left { left: 0; transform: translateX(-100%); }
.curtain-panel--right { right: 0; transform: translateX(100%); }
.curtain-transition.is-closed .curtain-panel { transform: translateX(0); }

@media (prefers-reduced-motion: reduce) {
  .art-button.is-ready img { animation: none; }
  .screen,
  .scene-transition,
  .puzzle-grid,
  .share-guide,
  .curtain-panel { transition-duration: 1ms !important; }
}
