*,
*::before,
*::after { box-sizing: border-box; }

:root {
  --night: #14142b;
  --lavender: #cbb7f0;
  --gold: #f3cf86;
  --cream: #fff8ec;
  --cta: #e9b65c;
}

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

body {
  background: #fff;
  color: var(--cream);
  font-family: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  position: relative;
  max-width: 480px;
  min-height: 100svh;
  margin: 0 auto;
  overflow: hidden;
  background: #fff;
}

.top {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 2;
  padding: max(14px, env(safe-area-inset-top)) 18px 14px;
  background: linear-gradient(rgba(10, 10, 28, 0.55), transparent);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 4.4px;
  height: 24.2px;
  color: var(--cream);
  text-decoration: none;
}

.seal {
  display: grid;
  grid-template-columns: auto;
  align-content: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 2px;
  background: #ce3711;
  color: #fff;
  font-family: "Noto Sans KR", sans-serif;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
}

.wordmark {
  display: block;
  width: auto;
  height: 22px;
}

.hero {
  position: relative;
  min-height: 100svh;
}

.art-frame {
  position: absolute;
  inset: 0;
}

.hero-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.hero-copy {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 1;
  padding: 0 24px max(46px, calc(env(safe-area-inset-bottom) + 24px));
  text-align: center;
}

.hero-copy::before {
  content: "";
  position: absolute;
  inset: -90px 0 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(20, 20, 24, 0), rgba(20, 20, 24, .5) 30%, rgba(20, 20, 24, .8) 65%, rgba(20, 20, 24, .9));
}

.kicker {
  margin: 0;
  line-height: 1.3;
  color: #fff;
  font-family: "Diphylleia", serif;
  font-size: 21px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-shadow: 0 0 10px rgba(137, 44, 96, 0.9), 0 2px 8px rgba(0, 0, 0, 0.6);
}

h1 {
  margin: 0 0 74px;
  color: #fff;
  font-family: "Diphylleia", serif;
  font-size: clamp(64px, 20vw, 88px);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: 0;
  text-shadow:
    0 0 1px #fff,
    0 0 10px rgba(208, 92, 150, 0.8),
    0 0 30px rgba(137, 44, 96, 0.85),
    0 3px 10px rgba(0, 0, 0, 0.55);
}


.sub {
  margin: 0 0 6px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 15px;
  font-weight: 300;
  line-height: 1.5;
  letter-spacing: -0.4px;
  text-align: center;
  white-space: nowrap;
}

.sub-hl {
  font-weight: 680;
}

.sub-love { color: #E8A4B8; }
.sub-money { color: #F1CB81; }

.cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 20px;
  margin: 0 -4px;
  max-width: none;
  width: auto;
  border-radius: 8px;
  background: #f0be5f;
  box-shadow: none;
  color: #261603;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  text-decoration: none;
  transition: filter 0.15s ease;
  position: relative;
  overflow: hidden;
}

.cta:hover {
  filter: brightness(1.06);
  box-shadow: none;
}

.cta:active {
  filter: brightness(0.95);
  box-shadow: none;
}

.cta svg {
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.cta:hover svg {
  transform: translateX(2px);
}



.title-hahmlet {
  display: block;
  width: min(100%, 376px);
  height: auto;
  margin: 10px auto 0;
  filter: drop-shadow(0 0 10px rgba(208, 92, 150, .55));
}

/* Compact phone viewports with browser toolbars visible. */
@media (max-width: 600px) and (max-height: 740px) {
  .kicker { font-size: 19px; }
  .title-hahmlet { width: min(100%, 328px); }
  h1 { margin-bottom: 44px; }
  .sub { margin-bottom: 6px; }
  .hero-copy { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
}

[hidden] { display: none !important; }

/* Steps after 시작하기: one still image, dialogue and inputs at the bottom. */
.top { display: flex; align-items: center; gap: 6px; }

.back {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: -6px 0 -6px -10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--cream);
  cursor: pointer;
}

.flow {
  position: relative;
  min-height: 100svh;
  background: #121a38;
  overflow: hidden;
}

.flow-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  transition: filter 0.5s ease, transform 0.5s ease;
}

/* 시작하기 crossfade: home sits over the greet screen at the same size, then fades out. */
.page.fading .flow { z-index: 0; }
.page.fading .hero {
  position: absolute;
  inset: 0;
  z-index: 1;
  min-height: 0;
  pointer-events: none;
}
.page.fading .back { opacity: 0; }
.page.fade-go .hero { opacity: 0; transition: opacity 0.52s ease; }
.page.fade-go .back { opacity: 1; transition: opacity 0.52s ease; }

.page[data-step="form"] .flow-art,
.page[data-step="hand"] .flow-art,
.page[data-step="camera"] .flow-art {
  filter: blur(14px) brightness(0.45);
  transform: scale(1.08);
}

.step {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  padding: 76px 24px max(28px, calc(env(safe-area-inset-bottom) + 20px));
  animation: step-in 0.4s ease both;
}

@keyframes step-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.step .cta {
  width: auto;
  border: 0;
  font-family: inherit;
  cursor: pointer;
}

.step-greet { justify-content: flex-end; }

.talk {
  position: relative;
  margin-bottom: 30px;
  text-align: center;
}

.talk::before {
  content: "";
  position: absolute;
  inset: -80px -24px -400px;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(18, 22, 44, 0), rgba(18, 22, 44, 0.6) 30%, rgba(18, 22, 44, 0.88) 55%);
}

.line {
  margin: 0;
  color: #fff;
  font-family: "Gowun Batang", serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.65;
  letter-spacing: -0.2px;
  word-break: keep-all;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
  outline: none;
}

.line + .line { margin-top: 14px; }

.step-title {
  margin: 0;
  color: #fff;
  font-family: "Gowun Batang", serif;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -0.3px;
  word-break: keep-all;
  outline: none;
}

.step-form .step-title { margin: 18px 0 34px; }

.field { margin-bottom: 22px; }

.field label {
  display: block;
  margin-bottom: 6px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

.field input {
  display: block;
  width: 100%;
  height: 46px;
  padding: 0 2px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 17px;
  outline: none;
}

.field input::placeholder { color: rgba(255, 255, 255, 0.45); }
.field input:focus { border-bottom-color: #f0be5f; }
.field input[aria-invalid="true"] { border-bottom-color: #ff9b85; }

.field-error {
  min-height: 20px;
  margin: 6px 0 0;
  color: #ffb3a3;
  font-size: 13px;
  line-height: 20px;
}

.step-form .cta { margin-top: auto; }

.hand-name {
  margin: 8px 0 4px;
  color: #f7d286;
  font-size: 15px;
  font-weight: 700;
  word-break: break-all;
}

.hand-sub {
  margin: 8px 0 2px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 15px;
  line-height: 1.5;
  word-break: keep-all;
}

.hand-note {
  margin: 0;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  line-height: 1.5;
}

.hand-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 18px 0 14px;
}

.hand-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: rgba(10, 12, 30, 0.35);
  color: #fff;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.hand-choice span { color: rgba(255, 255, 255, 0.7); font-size: 13px; }

.hand-choice[aria-pressed="true"] {
  border-color: #f0be5f;
  background: rgba(240, 190, 95, 0.16);
  color: #f7d286;
}

.hand-choice[aria-pressed="true"] span { color: #f7d286; }

.hand-next { margin-top: auto; }

/* Camera step: live video with the palm guide on top, then the captured frame. */
.step-camera { padding-bottom: max(20px, calc(env(safe-area-inset-bottom) + 16px)); }

.cam-title { font-size: 18px; }

.cam-frame {
  position: relative;
  flex: 1;
  min-height: 240px;
  margin-top: 12px;
  border-radius: 8px;
  background: #000;
  overflow: hidden;
}

.step-camera:not([data-cam="starting"]):not([data-cam="live"]):not([data-cam="photo"]) .cam-frame { display: none; }

.cam-video,
.cam-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.cam-video { object-fit: cover; }
.cam-photo { display: none; object-fit: contain; }
.step-camera[data-cam="photo"] .cam-video { display: none; }
.step-camera[data-cam="photo"] .cam-photo { display: block; }

/* Open-corner frame around the palm only; fingers and thumb may fall outside. Symmetric, so no mirroring per hand. */
.palm-guide {
  --c: rgba(255, 244, 222, 0.92);
  --len: 38px;
  --w: 3px;
  position: absolute;
  left: 50%;
  top: 55%;
  width: 80%;
  aspect-ratio: 1 / 1.08;
  max-height: 78%;
  transform: translate(-50%, -50%);
  border-radius: 6px;
  background:
    linear-gradient(var(--c), var(--c)) left top / var(--len) var(--w),
    linear-gradient(var(--c), var(--c)) left top / var(--w) var(--len),
    linear-gradient(var(--c), var(--c)) right top / var(--len) var(--w),
    linear-gradient(var(--c), var(--c)) right top / var(--w) var(--len),
    linear-gradient(var(--c), var(--c)) left bottom / var(--len) var(--w),
    linear-gradient(var(--c), var(--c)) left bottom / var(--w) var(--len),
    linear-gradient(var(--c), var(--c)) right bottom / var(--len) var(--w),
    linear-gradient(var(--c), var(--c)) right bottom / var(--w) var(--len);
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.55));
  pointer-events: none;
  display: none;
}

.palm-guide-note {
  position: absolute;
  left: 50%;
  bottom: 10px;
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
  display: none;
}

.step-camera[data-cam="live"] .palm-guide,
.step-camera[data-cam="live"] .palm-guide-note { display: block; }

.cam-status {
  margin: 10px 0 12px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  white-space: pre-line;
  word-break: keep-all;
}

.step-camera:not([data-cam="starting"]):not([data-cam="live"]):not([data-cam="photo"]) .cam-status { margin: auto 0 20px; }

.cam-actions { display: grid; gap: 8px; }

.step .cta:disabled { opacity: 0.45; cursor: default; }

.step .cta-sub {
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: transparent;
  color: #fff;
}

.pick-btn { cursor: pointer; }

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

.pick-btn:focus-within { outline: 2px solid #fff; outline-offset: 2px; }

@media (max-height: 680px) {
  .step { padding-top: 64px; }
  .step-form .step-title { margin: 8px 0 24px; }
  .hand-choices { margin: 14px 0 10px; }
  .cam-frame { min-height: 200px; }
}

/* Wide screens: centered 480-wide column filling the full window height (white sides only).
   Home copy scales from the 393×641 phone layout via --cw; page, home and flow share --ch so the crossfade overlay matches.
   540px floor keeps the home copy clear of the top logo on very short windows. */
@media (min-width: 601px) {
  .page {
    --cw: 480px;
    --ch: max(100svh, 540px);
    width: var(--cw);
    min-height: var(--ch);
  }
  .hero { min-height: 0; height: var(--ch); }
  .flow, .step { min-height: var(--ch); }
  .hero-copy { padding: 0 calc(var(--cw) * 24 / 393) calc(var(--cw) * 28 / 393); }
  .hero-copy::before { top: calc(var(--cw) * -90 / 393); }
  .kicker { font-size: calc(var(--cw) * 19 / 393); }
  .title-hahmlet { width: calc(var(--cw) * 328 / 393); margin-top: calc(var(--cw) * 10 / 393); }
  h1 { margin-bottom: calc(var(--cw) * 44 / 393); }
  .sub { margin-bottom: calc(var(--cw) * 6 / 393); font-size: calc(var(--cw) * 15 / 393); letter-spacing: calc(var(--cw) * -0.4 / 393); }
  .hero .cta {
    gap: calc(var(--cw) * 8 / 393);
    height: calc(var(--cw) * 48 / 393);
    margin: 0 calc(var(--cw) * -4 / 393);
    border-radius: calc(var(--cw) * 8 / 393);
    font-size: calc(var(--cw) * 18 / 393);
  }
  .hero .cta svg { width: calc(var(--cw) * 18 / 393); height: calc(var(--cw) * 18 / 393); }
}
