:root {
  --bg: #110b08;
  --bg-deep: #050403;
  --bg-wine: #221116;
  --bg-navy: #0d1119;
  --canvas-noise: rgba(255, 245, 222, 0.03);

  --card-bg: linear-gradient(160deg, rgba(49, 33, 23, 0.94) 0%, rgba(30, 21, 16, 0.95) 50%, rgba(19, 14, 12, 0.96) 100%);
  --border: rgba(200, 160, 93, 0.45);
  --border-soft: rgba(200, 160, 93, 0.26);
  --gold: #c8a05d;
  --ivory: #efe1c4;
  --ivory-dim: rgba(239, 225, 196, 0.76);
  --ivory-muted: rgba(239, 225, 196, 0.53);

  --accent: #c09a59;
  --glow: rgba(224, 180, 98, 0.25);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 30px;

  --shadow-frame: 0 14px 44px rgba(0, 0, 0, 0.56);
  --shadow-gold: 0 0 22px rgba(213, 176, 107, 0.2);
  --transition: 0.26s cubic-bezier(0.4, 0, 0.2, 1);

  --font-title: "Garamond", "Times New Roman", serif;
  --font-body: "Noto Serif KR", "Apple SD Gothic Neo", "Malgun Gothic", serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }

body {
  font-family: var(--font-body);
  color: var(--ivory);
  min-height: 100dvh;
  overflow-x: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(140% 95% at 82% 14%, rgba(112, 58, 30, 0.2) 0%, rgba(112, 58, 30, 0) 60%),
    radial-gradient(130% 90% at 20% 88%, rgba(46, 39, 70, 0.21) 0%, rgba(46, 39, 70, 0) 62%),
    linear-gradient(145deg, var(--bg-deep) 0%, var(--bg) 36%, var(--bg-wine) 68%, var(--bg-navy) 100%);
  position: relative;
  -webkit-font-smoothing: antialiased;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    repeating-linear-gradient(0deg, transparent 0 3px, var(--canvas-noise) 3px 4px),
    repeating-linear-gradient(90deg, rgba(255, 242, 214, 0.016) 0 2px, transparent 2px 6px);
  opacity: 0.52;
  mix-blend-mode: soft-light;
}

body::after { background: radial-gradient(circle at center, transparent 42%, rgba(0, 0, 0, 0.62) 100%); }

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

.star {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff4d8 0%, #f0c672 34%, rgba(255, 216, 145, 0) 100%);
  opacity: 0;
  animation: candleDust var(--dur, 5s) var(--delay, 0s) infinite ease-in-out;
}

@keyframes candleDust {
  0%, 100% { opacity: 0; transform: translateY(0) scale(0.75); }
  45% { opacity: var(--op, 0.55); transform: translateY(-5px) scale(1); }
}

.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 700px;
  padding: 28px 18px 54px;
}

.container::before {
  content: "";
  position: absolute;
  inset: 8px 8px 18px;
  border: 1px solid rgba(195, 148, 67, 0.26);
  border-radius: var(--radius-xl);
  pointer-events: none;
}

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  animation: fadeUp 0.42s ease-out both;
}

.screen.hidden { display: none; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

.intro-video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  background: #0a0706;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-frame), inset 0 0 0 1px rgba(255, 236, 195, 0.08), 0 0 0 5px rgba(87, 56, 29, 0.28), inset 0 0 28px rgba(0, 0, 0, 0.26);
}

.intro-video-wrap::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(212, 170, 92, 0.45);
  border-radius: calc(var(--radius-lg) - 5px);
  pointer-events: none;
  z-index: 3;
}

.intro-video-wrap:focus-visible {
  outline: none;
  box-shadow: var(--shadow-frame), 0 0 0 3px rgba(255, 214, 132, 0.4), 0 0 32px rgba(255, 199, 107, 0.24);
}

.intro-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.86) contrast(1.06) brightness(0.88);
}

.intro-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 72% 30%, rgba(255, 216, 145, 0.25) 0%, rgba(255, 216, 145, 0) 36%),
    linear-gradient(140deg, #17100d 0%, #261812 48%, #16131a 100%);
}

.intro-placeholder.hidden { display: none; }
.intro-placeholder::before {
  content: "* HOURGLASS LETTER KEY *";
  letter-spacing: 0.22em;
  font-size: clamp(0.85rem, 2.3vw, 1.2rem);
  color: rgba(239, 210, 148, 0.9);
  text-shadow: 0 0 18px rgba(255, 202, 122, 0.25);
  animation: softFlame 3.2s ease-in-out infinite;
}

.intro-placeholder-icon { display: none; }

.video-skip-note {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--ivory-dim);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(255, 219, 160, 0.34);
  text-align: center;
}

.video-skip-note:hover { color: var(--ivory); }


.crest {
  font-size: 2.65rem;
  color: var(--gold);
  filter: drop-shadow(0 0 14px rgba(255, 205, 117, 0.26));
  animation: softFlame 3.8s ease-in-out infinite;
}

@keyframes softFlame {
  0%, 100% { opacity: 0.82; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

.title {
  font-family: var(--font-title);
  font-size: clamp(1.8rem, 5vw, 2.65rem);
  font-weight: 700;
  text-align: center;
  line-height: 1.25;
  color: var(--ivory);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 0 0 22px rgba(255, 218, 137, 0.16);
}

.lead {
  font-size: 1rem;
  color: var(--ivory-dim);
  text-align: center;
  line-height: 1.82;
  max-width: 560px;
}

.start-image-wrap {
  width: 100%;
  max-width: 560px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-frame), inset 0 0 0 1px rgba(255, 236, 195, 0.08);
}

.start-image-wrap.hidden { display: none; }

.start-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.9) contrast(1.04) brightness(0.9);
}

.question-count { font-size: 0.8rem; color: var(--ivory-muted); letter-spacing: 0.11em; }
.start-gap { height: 12px; width: 100%; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-family: var(--font-body);
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.btn::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: inherit;
  border: 1px solid rgba(255, 234, 194, 0.25);
  pointer-events: none;
}

.btn-primary {
  color: #24170f;
  background: linear-gradient(165deg, #ebcf99 0%, #c59653 42%, #9f7037 100%);
  box-shadow: var(--shadow-gold), 0 6px 20px rgba(0, 0, 0, 0.45);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: 0 0 24px rgba(234, 188, 99, 0.3), 0 10px 22px rgba(0, 0, 0, 0.5);
}

.btn-primary:active { transform: translateY(0) scale(0.985); }

.btn-ghost {
  color: var(--ivory-dim);
  background: linear-gradient(160deg, rgba(70, 47, 31, 0.6) 0%, rgba(47, 30, 22, 0.65) 100%);
}

.btn-ghost:hover {
  color: var(--ivory);
  border-color: rgba(240, 196, 114, 0.6);
  box-shadow: 0 0 16px rgba(217, 170, 84, 0.22);
}

.btn-ghost:disabled { opacity: 0.34; cursor: not-allowed; }

.progress-wrap {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  background:
    repeating-linear-gradient(90deg, rgba(241, 215, 162, 0.08) 0 8px, rgba(241, 215, 162, 0.02) 8px 16px),
    rgba(19, 12, 10, 0.78);
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #b17e3f 0%, #ddbc7f 55%, #ffe2a8 100%);
  box-shadow: 0 0 12px rgba(232, 189, 108, 0.42);
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-label { font-size: 0.78rem; color: var(--ivory-muted); letter-spacing: 0.1em; align-self: flex-end; }

.quiz-card {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 24px 24px;
  box-shadow: var(--shadow-frame), inset 0 0 0 1px rgba(255, 233, 190, 0.08), inset 0 0 42px rgba(255, 214, 140, 0.04);
  position: relative;
  animation: cardIn 0.35s ease-out both;
}

.quiz-card::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(213, 176, 107, 0.28);
  border-radius: calc(var(--radius-lg) - 6px);
  pointer-events: none;
}

.quiz-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(circle at 10% 12%, rgba(255, 218, 150, 0.05) 0%, transparent 28%),
    radial-gradient(circle at 85% 88%, rgba(255, 218, 150, 0.04) 0%, transparent 30%);
}

@keyframes cardIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
.quiz-card.reverse { animation: cardInReverse 0.35s ease-out both; }
@keyframes cardInReverse { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: translateX(0); } }

.q-image-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--border-soft);
  background: rgba(15, 10, 8, 0.8);
}

.q-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.88) contrast(1.05);
  transition: opacity 0.26s ease;
}

.q-image-wrap.hidden { display: none; }

.question-text {
  font-size: clamp(1.03rem, 2.9vw, 1.2rem);
  line-height: 1.82;
  color: var(--ivory);
  margin-bottom: 20px;
  word-break: keep-all;
  position: relative;
  padding-left: 0;
  border-left: none;
}

.choices { list-style: none; display: flex; flex-direction: column; gap: 10px; }

.choice-btn {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: linear-gradient(160deg, rgba(76, 50, 33, 0.52) 0%, rgba(41, 28, 22, 0.66) 100%);
  color: var(--ivory-dim);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.62;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
  word-break: keep-all;
  box-shadow: inset 0 0 0 1px rgba(255, 233, 190, 0.05);
}

.choice-btn:hover {
  border-color: rgba(228, 187, 108, 0.62);
  color: var(--ivory);
  transform: translateX(3px);
  box-shadow: 0 0 16px rgba(255, 199, 104, 0.2), inset 0 0 22px rgba(255, 202, 109, 0.07);
}

.choice-btn:active { transform: translateX(1px) scale(0.995); }

.choice-btn.selected {
  border-color: rgba(248, 206, 127, 0.84);
  color: var(--ivory);
  background: linear-gradient(160deg, rgba(110, 73, 41, 0.62) 0%, rgba(58, 37, 25, 0.78) 100%);
  box-shadow: 0 0 18px rgba(241, 195, 110, 0.24), inset 0 0 28px rgba(255, 221, 150, 0.08);
}

.choice-label {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  font-weight: 700;
  color: #21150d;
  background: linear-gradient(165deg, #f4dca8 0%, #cd9b56 100%);
  border: 1px solid rgba(132, 89, 34, 0.75);
  box-shadow: 0 0 10px rgba(219, 173, 93, 0.22);
}

.result-announce { font-size: 0.82rem; color: var(--ivory-muted); letter-spacing: 0.12em; text-transform: uppercase; }

.house-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-frame), 0 0 0 6px rgba(83, 54, 29, 0.35), 0 0 26px rgba(212, 170, 92, 0.18), inset 0 0 40px rgba(0, 0, 0, 0.2);
}

.house-image-wrap::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(243, 211, 146, 0.33);
  border-radius: calc(var(--radius-lg) - 5px);
  pointer-events: none;
  z-index: 2;
}

.house-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.9) contrast(1.04);
  transition: opacity 0.35s ease;
}

.house-image-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.7rem;
  color: rgba(255, 230, 178, 0.92);
  text-shadow: 0 0 22px rgba(255, 208, 122, 0.4);
}

.house-image-fallback.hidden { display: none; }

.house-name {
  font-family: var(--font-title);
  font-size: clamp(1.8rem, 5.5vw, 2.55rem);
  line-height: 1.2;
  text-align: center;
  color: var(--accent);
  text-shadow: 0 0 25px var(--glow);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.house-subtitle { display: none; }

.tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }

.tag {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(235, 196, 118, 0.53);
  background: rgba(66, 43, 27, 0.45);
  font-size: 0.74rem;
  color: rgba(244, 219, 167, 0.95);
  letter-spacing: 0.04em;
}

.nerd-section {
  width: 100%;
  border-radius: var(--radius-md);
  padding: 21px 20px 18px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  box-shadow: var(--shadow-frame), inset 0 0 0 1px rgba(255, 233, 190, 0.07);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
}

.nerd-section::before {
  content: "HOURGLASS";
  position: absolute;
  right: 14px;
  top: 9px;
  color: rgba(239, 202, 130, 0.48);
  font-size: 0.57rem;
  letter-spacing: 0.08em;
}

.nerd-label { font-size: 0.76rem; color: var(--ivory-muted); letter-spacing: 0.12em; text-transform: uppercase; }

.nerd-bar-wrap {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  background: rgba(17, 11, 9, 0.76);
}

.nerd-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8a5e2f 0%, var(--accent) 60%, #ffe2ad 100%);
  box-shadow: 0 0 12px var(--glow);
  transition: width 1.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.nerd-percent {
  min-width: 118px;
  text-align: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(227, 182, 102, 0.68);
  background: radial-gradient(circle at 50% 35%, rgba(255, 206, 124, 0.2) 0%, rgba(38, 25, 19, 0.9) 72%);
  font-family: var(--font-title);
  font-size: 1.95rem;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 16px var(--glow);
}

.nerd-rank {
  font-size: 0.86rem;
  color: var(--ivory);
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(230, 187, 103, 0.5);
  background: rgba(74, 49, 30, 0.58);
  box-shadow: inset 0 0 0 1px rgba(255, 225, 164, 0.12);
}

.house-desc {
  max-width: 560px;
  font-size: 0.95rem;
  line-height: 1.85;
  color: var(--ivory-dim);
  text-align: center;
  word-break: keep-all;
}

.result-actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

#btn-share-image { display: none; }

#btn-retry {
  width: 100%;
  max-width: none;
}

@media (max-width: 560px) {
  .container { padding: 20px 12px 44px; }
  .title { font-size: 1.72rem; }
  .quiz-card { padding: 22px 15px 18px; }
  .question-text { font-size: 1rem; line-height: 1.76; }
  .choice-btn { min-height: 56px; padding: 13px 12px; font-size: 0.92rem; }
  .btn { min-height: 50px; width: 100%; max-width: 320px; }
  .btn-ghost { max-width: 220px; }
  .result-actions { grid-template-columns: 1fr; gap: 8px; }
  #btn-share-image { display: none; }
  .result-actions .btn { width: 100%; max-width: none; padding: 12px 10px; font-size: 0.9rem; }
  .house-name { font-size: 1.62rem; }
  .nerd-percent { font-size: 1.66rem; }
}
