:root {
  --page: #1f232a; --sign: #fbf3e4; --cream: #f7eedf; --input: #fffaf3; --ink: #3b2f33; --muted: #76666a;
  --stitch: #d9c39c; --berry: #d64f5e; --berry-deep: #b23a4c; --butter: #f6dc8f; --blush: #f2b8b5;
  --meadow: #b8dc9c; --sky: #a9d3f0;
  --font-display: "Yeon Sung", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --font-body: "Pretendard Variable", "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  --r-card: 28px; --r-pill: 999px;
  --shadow: 0 6px 0 rgba(0, 0, 0, .18), 0 14px 30px rgba(0, 0, 0, .22);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in: cubic-bezier(.55, 0, 1, .45);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: var(--page); overflow: hidden; overflow-x: clip;
  font-family: var(--font-body); color: var(--ink); font-size: 16px;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

.world {
  position: fixed; inset: 0; width: 100vw; height: 100dvh; display: block;
  touch-action: none; outline: none; cursor: grab;
}
.world:active { cursor: grabbing; }

/* ---------- character select ---------- */
.select {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(31, 35, 42, .92); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; flex-direction: column; align-items: center;
  padding: 12vh 16px calc(24px + env(safe-area-inset-bottom));
  transition: opacity 400ms var(--ease-out);
}
.select.is-leaving { opacity: 0; pointer-events: none; }
.select-title {
  margin: 0 0 clamp(24px, 6vh, 56px);
  font-family: var(--font-display); font-weight: 400; font-size: 32px; line-height: 1.25;
  color: var(--sign); text-align: center; text-wrap: balance;
}
.cards { display: flex; gap: 24px; justify-content: center; }
.card {
  position: relative; width: 260px; height: 340px; padding: 0; border: 0;
  display: flex; flex-direction: column; align-items: stretch;
  background: var(--cream); border-radius: var(--r-card); box-shadow: var(--shadow);
  outline: 2px dashed var(--stitch); outline-offset: -10px;
  font: inherit; color: var(--ink); cursor: pointer;
  transition-property: transform, box-shadow; transition-duration: 160ms; transition-timing-function: ease-out;
}
.card:hover, .card:focus-visible { transform: translateY(-4px); }
.card:active { transform: scale(.97); transition-duration: 90ms; }
.card:focus-visible { box-shadow: 0 0 0 3px var(--page), 0 0 0 6px var(--berry-deep), var(--shadow); }
.card.is-remembered { box-shadow: 0 0 0 3px var(--berry-deep), var(--shadow); }
.card-stage { flex: 0 0 75%; }
.card-name {
  flex: 1; display: flex; align-items: center; justify-content: center; padding-bottom: 6px;
  font-family: var(--font-display); font-size: 28px; line-height: 1; color: var(--ink);
}

.preview {
  position: fixed; inset: 0; width: 100vw; height: 100dvh; z-index: 11; pointer-events: none;
  transition: opacity 400ms var(--ease-out);
}
.preview.is-leaving { opacity: 0; }
/* saved character: never show the picker; cover the world until the player is placed */
.no-pick .select, .no-pick .preview { display: none; }
.no-pick .fade { opacity: 1; transition: none; }

/* ---------- character button (top-left): opens the picker again ---------- */
.who {
  position: fixed; z-index: 6; top: calc(16px + env(safe-area-inset-top)); left: calc(16px + env(safe-area-inset-left));
  height: 44px; padding: 0 16px; border: 0; border-radius: var(--r-pill); cursor: pointer;
  background: var(--cream); color: var(--ink); font: 400 20px/1 var(--font-display);
  outline: 2px dashed var(--stitch); outline-offset: -6px;
  box-shadow: 0 2px 0 rgba(59, 47, 51, .12), 0 8px 20px rgba(59, 47, 51, .14);
  transition: transform 160ms ease-out;
}
.who:hover { transform: translateY(-2px); }
.who:active { transform: scale(.96); transition-duration: 90ms; }
.who:focus-visible { outline: 3px solid var(--berry-deep); outline-offset: 2px; }

/* sound on/off (shared with the hall: one switch for music + effects) */
.sound {
  position: fixed; z-index: 6; top: calc(16px + env(safe-area-inset-top)); right: calc(16px + env(safe-area-inset-right));
  width: 44px; height: 44px; border: 0; padding: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center;
  background: var(--cream); color: var(--ink);
  outline: 2px dashed var(--stitch); outline-offset: -6px;
  box-shadow: 0 2px 0 rgba(59, 47, 51, .12), 0 8px 20px rgba(59, 47, 51, .14);
  transition-property: transform; transition-duration: 160ms; transition-timing-function: ease-out;
}
.sound:hover { transform: translateY(-2px); }
.sound:active { transform: scale(.96); transition-duration: 90ms; }
.sound:focus-visible { outline: 3px solid var(--berry-deep); outline-offset: 2px; }
.sound[aria-pressed="false"] { color: var(--muted); }
.select:not(.is-leaving) ~ .sound { z-index: 11; }

@media (max-width: 480px) { .select { justify-content: center; padding-top: 0; } } /* phones: the cards sit in the middle, not over an empty lower half */
@media (max-width: 560px) {
  .select-title { font-size: 24px; }
  .cards { gap: 14px; }
  .card { width: min(44vw, 200px); height: calc(min(44vw, 200px) * 1.3); border-radius: 24px; }
  .card-name { font-size: 24px; }
}

/* ---------- fade to the wedding hall ---------- */
.fade {
  position: fixed; inset: 0; z-index: 20; background: var(--sign);
  opacity: 0; pointer-events: none;
  transition: opacity 600ms var(--ease-in);
}
.fade.is-on { opacity: 1; pointer-events: auto; }

/* ---------- touch joystick (created by kit controls) ---------- */
.mp-joy {
  position: fixed; z-index: 5; width: 156px; height: 156px;
  left: calc(14px + env(safe-area-inset-left)); bottom: calc(18px + env(safe-area-inset-bottom));
  touch-action: none; display: grid; place-items: center;
}
.mp-joy-base {
  width: 112px; height: 112px; border-radius: 50%;
  background: rgba(251, 243, 228, .5); box-shadow: 0 4px 14px rgba(59, 47, 51, .18);
  outline: 2px dashed rgba(178, 58, 76, .45); outline-offset: -8px;
  display: grid; place-items: center;
}
.mp-joy-knob {
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--sign); box-shadow: 0 3px 0 rgba(59, 47, 51, .2), 0 6px 14px rgba(59, 47, 51, .22);
  outline: 2px dashed var(--stitch); outline-offset: -6px;
  will-change: transform;
}
.mp-joy.is-active .mp-joy-base { background: rgba(251, 243, 228, .68); }

@media (prefers-reduced-motion: reduce) {
  .select, .preview, .card, .fade { transition-duration: 1ms !important; }
  .card:hover, .card:focus-visible, .card:active { transform: none; }
}

/* ---------- touch jump button (kit controls) ---------- */
.mp-jump {
  position: fixed; z-index: 5; width: 76px; height: 76px; border-radius: 50%; border: 0; padding: 0;
  right: calc(22px + env(safe-area-inset-right)); bottom: calc(52px + env(safe-area-inset-bottom));
  background: var(--sign); box-shadow: 0 3px 0 rgba(59, 47, 51, .2), 0 6px 14px rgba(59, 47, 51, .22);
  outline: 2px dashed var(--stitch); outline-offset: -7px; touch-action: none; cursor: pointer;
  transition: transform .12s ease-out;
}
.mp-jump::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 22px; height: 22px;
  border-left: 4px solid #3b2f33; border-top: 4px solid #3b2f33; border-radius: 3px;
  transform: translateY(4px) rotate(45deg);
}
.mp-jump:active { transform: scale(.92); }

/* music volume slider under the speaker button (audio/sfx.js) */
.vol {
  position: fixed; z-index: 6; top: calc(66px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right));
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px 8px; border-radius: 14px;
  background: var(--cream); color: var(--ink); font-size: 12px;
  outline: 2px dashed var(--stitch); outline-offset: -5px;
  box-shadow: 0 2px 0 rgba(59, 47, 51, .12), 0 8px 20px rgba(59, 47, 51, .14);
}
.vol[hidden] { display: none; }
/* shown only while the speaker or the card is hovered / focused; gone 300 ms after the pointer leaves both.
   Never on touch screens (phones have hardware volume). */
.vol { opacity: 0; visibility: hidden; transition: opacity 120ms ease-out 180ms, visibility 0s linear 300ms; }
.sound:hover + .vol, .sound:focus-visible + .vol, .vol:hover, .vol:focus-within { opacity: 1; visibility: visible; transition-delay: 0s; }
@media (pointer: coarse) { .vol { display: none; } }
.vol input { width: 96px; accent-color: var(--berry-deep, #c0567a); cursor: pointer; }

/* ---------- 화질 toggle (자동/높음/보통/낮음), left of the sound button; js/world/quality.js ---------- */
.quality {
  position: fixed; z-index: 6; top: calc(22px + env(safe-area-inset-top)); right: calc(68px + env(safe-area-inset-right));
  height: 32px; padding: 0 12px; border: 0; border-radius: 16px; cursor: pointer;
  font: 600 13px/1 inherit; font-family: inherit; letter-spacing: -0.01em;
  background: var(--cream); color: var(--ink);
  outline: 2px dashed var(--stitch); outline-offset: -5px;
  box-shadow: 0 2px 0 rgba(59, 47, 51, .12), 0 8px 20px rgba(59, 47, 51, .14);
  transition-property: transform; transition-duration: 160ms; transition-timing-function: ease-out;
}
.quality[hidden] { display: none; }
.quality:hover { transform: translateY(-2px); }
.quality:active { transform: scale(.96); transition-duration: 90ms; }
.quality:focus-visible { outline: 3px solid var(--berry-deep); outline-offset: 2px; }
@media (pointer: coarse) { .quality { height: 44px; top: calc(16px + env(safe-area-inset-top)); font-size: 14px; } }

/* r7: "웨딩홀 들어가기" chip over the hall door (same butter chip as 나가기 inside the hall) */
.door-hint {
  position: fixed; left: 0; top: 0; z-index: 3; min-height: 34px; padding: 5px 14px; border: 0; border-radius: var(--r-pill);
  background: var(--butter); color: var(--ink); font: inherit; font-weight: 700; font-size: 16px; line-height: 1.3; white-space: nowrap;
  box-shadow: 0 2px 0 rgba(59, 47, 51, .16), 0 4px 10px rgba(59, 47, 51, .14);
  outline: 2px dashed var(--stitch); outline-offset: -5px; cursor: pointer; touch-action: none; will-change: transform;
}
.door-hint.is-hidden { visibility: hidden; }
@media (pointer: coarse) { .door-hint { min-height: 42px; padding: 8px 16px; } }
