:root {
  color-scheme: dark;
  --ivory: #fff0ce;
  --gold: #ecc38b;
  --room-shadow: #23181a;
  --serif: Baskerville, "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --sans: "Segoe UI", Arial, sans-serif;
  font-family: var(--sans);
  color: var(--ivory);
  background: var(--room-shadow);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button { font: inherit; touch-action: manipulation; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.experience {
  --scene-height: 100vh;
  --art-ratio: calc(1672 / 941);
  --scene: url("assets/cam-salon-suslu.webp");
  --art-width: min(calc(var(--scene-height) * var(--art-ratio)), 116vw);
  --art-height: calc(var(--art-width) / var(--art-ratio));
  --side-space: calc(100vw - var(--art-width));
  --art-left: calc(var(--side-space) * .72);
  --art-right: calc(var(--side-space) - var(--art-left));
  --art-top: calc((var(--scene-height) - var(--art-height)) / 2);
  --blend-left: clamp(0px, var(--art-left), 32px);
  --blend-right: clamp(0px, var(--art-right), 32px);
  --blend-y: clamp(0px, var(--art-top), calc(var(--art-height) * .065));
  --blend-bottom: min(var(--blend-y), calc(var(--art-height) * .025));
  position: relative;
  isolation: isolate;
  height: var(--scene-height);
  min-height: 260px;
  overflow: hidden;
  background: var(--room-shadow);
}

@supports (height: 100dvh) {
  .experience { --scene-height: 100dvh; }
}

.world {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(#221e17, #26231c 61%, #271b17 86%, #241819);
  pointer-events: none;
}

.world::before, .world::after {
  content: "";
  position: absolute;
  top: var(--art-top);
  height: var(--art-height);
  transform: scaleX(-1);
  background-repeat: no-repeat;
  mask-image: linear-gradient(transparent, #000 var(--blend-y), #000 calc(100% - var(--blend-bottom)), transparent);
  filter: blur(9px);
}

/* Continue the scenery in wide margins using the tree-free edges of the photograph. */
.world::before {
  left: 0;
  width: max(0px, calc(var(--art-left) + var(--blend-left)));
  background-image: linear-gradient(90deg, #2015181a, #211918ec), var(--scene);
  background-size: 100% 100%, max(var(--art-width), calc(var(--art-left) * 32)) 100%;
  background-position: left center;
}
.world::after {
  right: 0;
  width: max(0px, calc(var(--art-right) + var(--blend-right)));
  background-image: linear-gradient(270deg, #2015181a, #211918ec), var(--scene);
  background-size: 100% 100%, max(var(--art-width), calc(var(--art-right) * 32)) 100%;
  background-position: right center;
}

.tree-stage {
  position: absolute;
  left: var(--art-left);
  top: var(--art-top);
  width: var(--art-width);
  height: var(--art-height);
}

.tree-stage picture { display: block; width: 100%; height: 100%; }

/* Carry the ceiling and rug colors into the margins of extra-tall screens. */
.tree-stage picture::before, .tree-stage picture::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  background-repeat: no-repeat;
  background-size: 100% 100%, 100% calc(var(--art-height) * 12);
  filter: blur(8px);
  pointer-events: none;
}
.tree-stage picture::before {
  bottom: calc(100% - var(--blend-y));
  height: max(0px, calc(var(--art-top) + var(--blend-y)));
  background-image: linear-gradient(#221e17f7, #221e17a8 65%, #221e1760), var(--scene);
  background-position: center top;
}
.tree-stage picture::after {
  top: calc(100% - var(--blend-bottom));
  height: max(0px, calc(var(--art-top) + var(--blend-bottom)));
  background-image: linear-gradient(#2418197a, #241819cb 45%, #241819fa), var(--scene);
  background-position: center bottom;
}
.tree-photo {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
  pointer-events: none;
  mask-image: linear-gradient(90deg, transparent, #000 var(--blend-left), #000 calc(100% - var(--blend-right)), transparent),
    linear-gradient(transparent, #000 var(--blend-y), #000 calc(100% - var(--blend-bottom)), transparent);
  mask-composite: intersect;
}

.game-intro {
  position: absolute;
  z-index: 2;
  top: calc(var(--art-top) + var(--art-height) * .17);
  left: calc(var(--art-left) + var(--art-width) * .385);
  width: calc(var(--art-width) * .276);
  transform: translate(-50%, -50%);
  text-align: center;
  text-shadow: 0 2px 8px #211212ed, 0 5px 24px #271518c9;
  pointer-events: none;
}

.game-intro h1 {
  margin: 0;
  font: 400 clamp(28px, calc(var(--art-width) * .04), 98px) / 1.04 var(--serif);
  letter-spacing: -.055em;
  color: var(--ivory);
}

.game-intro h1 em {
  font-weight: 400;
  font-style: italic;
  color: var(--gold);
}

.game-intro p {
  position: relative;
  margin: clamp(6px, 1.1vh, 15px) 0 0;
  padding-top: clamp(7px, 1.15vh, 16px);
  font: 400 clamp(16px, calc(var(--art-width) * .013), 25px) / 1.5 var(--sans);
  letter-spacing: .018em;
  color: #f4e7d0;
}

.game-intro p::before, .game-intro p::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
}

.game-intro p::before {
  width: clamp(100px, 10vw, 170px);
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, #d2a360 20%, #d2a360 40%, transparent 44% 56%, #d2a360 60%, #d2a360 80%, transparent);
}

.game-intro p::after {
  width: 6px;
  height: 6px;
  background: var(--gold);
  transform: translate(-50%, -43%) rotate(45deg);
}

.demo-label {
  position: absolute;
  z-index: 2;
  bottom: max(23px, env(safe-area-inset-bottom));
  left: max(3.3vw, env(safe-area-inset-left));
  margin: 0;
  color: #ecdbc4;
  text-shadow: 0 1px 5px #211515, 0 0 13px #211515;
  font: 500 12px / 1.4 var(--sans);
  letter-spacing: .04em;
  padding: 6px 12px;
  border: 1px solid #e8c58640;
  border-radius: 20px;
  background: #171e17c9;
  backdrop-filter: blur(8px);
}

.ornaments { position: absolute; z-index: 1; inset: 0; }

.ornament {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: max(44px, var(--w));
  height: max(44px, var(--h));
  transform: translate(-50%, -50%);
  background: none;
  color: var(--ivory);
  border: 0;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

[data-phase="revealing"] .ornament { cursor: default; pointer-events: none; }
.ornament:is(:hover, :focus-visible, .is-selected) { z-index: 1; }

.result-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 41%, #34251bd1, #1c1318f0 74%);
  backdrop-filter: blur(8px);
  animation: reveal-overlay .32s ease-out both;
}
@keyframes reveal-overlay { from { opacity: 0; } to { opacity: 1; } }

.result-card {
  display: grid;
  justify-items: center;
  text-align: center;
  width: min(100%, 660px);
  padding: clamp(24px, 4vh, 44px) 24px;
  border: 1px solid #e8c58652;
  border-radius: 24px;
  background: linear-gradient(145deg, #283025e8, #181f1ae8);
  box-shadow: 0 24px 90px #0008, inset 0 1px 0 #fff2;
}

.result-art {
  position: relative;
  width: clamp(98px, min(28vh, 50vw), 240px);
  aspect-ratio: 1;
  overflow: hidden;
  isolation: isolate;
  border-radius: 50%;
  outline: 1px solid #c99e59;
  outline-offset: 4px;
  box-shadow: 0 4px 44px #f0bd5526, 0 12px 26px #0007;
  background: #2a2818;
}

.result-art::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid #f8d593b3;
  border-radius: inherit;
  box-shadow: inset 0 0 24px 2px #150c04a6;
}

.result-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-ornament {
  margin: clamp(18px, 3vh, 28px) 0 8px;
  font: 600 14px / 1.4 var(--sans);
  color: #e7bd7c;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.result-prize {
  margin: 0;
  font: 400 clamp(34px, min(5.4vw, 7vh), 64px) / 1.12 var(--serif);
  color: #fff0ce;
  letter-spacing: -.045em;
  text-wrap: balance;
}

.result-story { max-width: 36ch; margin: 0 0 22px; color: #e6ddc8; font-size: 16px; line-height: 1.55; text-wrap: balance; }
.result-demo { margin: 10px 0 0; color: #c7bba5; font-size: 12px; letter-spacing: .04em; }
[data-phase="result"] > .demo-label { visibility: hidden; }

.replay {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .85em;
  min-height: 48px;
  margin-top: clamp(20px, 3.5vh, 32px);
  padding: 12px 28px;
  border: 1px solid #ffe7b2;
  border-radius: 999px;
  background: linear-gradient(150deg, #ffe8af, #cba35f);
  box-shadow: inset 0 1px 0 #fff8, 0 6px 24px #0005;
  color: #29251b;
  font: 600 16px / 1.3 var(--sans);
  letter-spacing: .025em;
  cursor: pointer;
}
.replay:focus-visible { outline: 2px solid #fff1c4; outline-offset: 4px; }
@media (hover: hover) {
  .replay:hover { background: linear-gradient(150deg, #fff0c9, #e4bd78); box-shadow: 0 6px 28px #ecc38b30; }
}

@media (max-aspect-ratio: 1/1) {
  .experience {
    --art-ratio: calc(941 / 1672);
    --scene: url("assets/cam-salon-suslu-mobil.webp");
    --art-width: min(calc(var(--scene-height) * var(--art-ratio) * 1.4), 100vw);
    --art-left: calc(var(--side-space) / 2);
    --art-top: max(calc((var(--scene-height) - var(--art-height)) / 2), calc((var(--scene-height) - var(--art-height)) * .35));
    --blend-bottom: var(--blend-y);
  }
  .ornament {
    left: var(--mx);
    top: var(--my);
    width: max(44px, var(--mw));
    height: max(44px, var(--mh));
  }
  .game-intro {
    left: 50%;
    top: max(calc(env(safe-area-inset-top) + 29px), calc(var(--art-top) + var(--art-height) * .125));
    width: 100%;
    padding: 0 12px;
  }
  .game-intro h1 {
    font-size: clamp(32px, min(11.8vw, 7.1vh), 80px);
    line-height: 1.06;
  }
  .game-intro p {
    margin-top: clamp(7px, 1.2vh, 15px);
    padding-top: clamp(8px, 1.35vh, 16px);
    font-size: clamp(16px, 2.7vw, 20px);
  }
  .demo-label {
    bottom: max(14px, env(safe-area-inset-bottom));
    left: 50%;
    width: max-content;
    transform: translateX(-50%);
    text-align: center;
  }
}

/* Let the room fill tall phones while keeping the whole tree in frame. */
@media (max-aspect-ratio: 9/16) {
  .experience { --art-width: min(calc(var(--scene-height) * var(--art-ratio)), 136vw); }
}

@media (min-aspect-ratio: 3/4) and (max-aspect-ratio: 1/1) {
  .experience {
    --art-width: min(calc(var(--scene-height) * var(--art-ratio) * 1.12), 100vw);
  }
  .game-intro {
    top: max(calc(env(safe-area-inset-top) + clamp(29px, 8.8vh, 85px)),
             calc(var(--art-top) + var(--art-height) * .095));
  }
}

@media (max-height: 420px) and (orientation: landscape) {
  .game-intro p { margin-top: 4px; padding-top: 5px; font-size: 12px; }
  .demo-label { bottom: max(10px, env(safe-area-inset-bottom)); }
  .result-art { width: 26vh; }
  .result-ornament { margin-top: 13px; }
  .result-story { margin-bottom: 12px; font-size: 14px; }
  .result-card { padding: 18px; }
  .result-prize { font-size: clamp(28px, 8vh, 40px); }
  .replay { margin-top: 12px; }
}

@media (max-height: 420px) and (orientation: portrait) {
  .game-intro h1 { font-size: clamp(25px, 7.8vh, 32px); }
  .game-intro p { margin-top: 5px; padding-top: 6px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
