:root {
  color-scheme: light;
  --shell-width: 460px;
  --navy: #0b1d3a;
  --navy-deep: #07152c;
  --navy-soft: #17345c;
  --gold: #f1cc6a;
  --gold-dark: #9a7546;
  --pink: #f2a7c6;
  --pink-dark: #8b3f69;
  --paper: #faf8f3;
  --ink: #363d3b;
  --green: #486454;
  --green-dark: #344f40;
  --muted: #626c60;
  --border: #a5af9c;
  --speech-blue: #174d8b;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--navy-deep); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 12%, #1b3a64 0, var(--navy-deep) 52%, #050f21 100%);
  color: var(--ink);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid #5db4d8;
  outline-offset: 4px;
}

#site-shell {
  width: min(100%, var(--shell-width));
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(241, 204, 106, .32), 0 0 48px rgba(0, 0, 0, .48);
}

#app, .screen { min-height: 100vh; min-height: 100svh; }
.screen { animation: enter .25s ease-out; }
@keyframes enter { from { opacity: .35; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Opening invitation */
.opening-screen {
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: var(--navy-deep);
  color: #f8f2df;
}

.opening-card {
  position: relative;
  width: 100%;
  min-height: calc(100svh - 28px);
  padding: clamp(28px, 7svh, 58px) clamp(18px, 6vw, 30px) 26px;
  border: 3px solid var(--gold);
  box-shadow: inset 0 0 0 5px var(--navy-deep), inset 0 0 0 7px #365078;
  background:
    radial-gradient(circle at 20% 14%, rgba(72, 102, 151, .25) 0 2px, transparent 3px),
    radial-gradient(circle at 83% 22%, rgba(72, 102, 151, .28) 0 2px, transparent 3px),
    radial-gradient(circle at 16% 70%, rgba(72, 102, 151, .22) 0 2px, transparent 3px),
    radial-gradient(circle at 86% 77%, rgba(72, 102, 151, .25) 0 2px, transparent 3px),
    linear-gradient(145deg, #0e2446, #091a35 64%, #0d2344);
  text-align: center;
}

.save-date {
  display: grid;
  gap: 4px;
  margin-bottom: clamp(24px, 5svh, 42px);
  color: var(--gold);
  font-family: ui-monospace, "Courier New", monospace;
  text-transform: uppercase;
  letter-spacing: .18em;
  line-height: 1.4;
}
.save-date::before, .save-date::after {
  content: "◆";
  position: absolute;
  top: clamp(35px, 8svh, 64px);
  color: var(--gold);
  font-size: .6rem;
}
.save-date::before { left: 17%; }
.save-date::after { right: 17%; }
.save-date span { font-size: .875rem; font-weight: 800; }
.save-date strong { font-size: .75rem; font-weight: 700; color: #d9e0f2; }

.portrait-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2.5vw, 13px);
  margin: 0 auto 22px;
}

.character-box {
  position: relative;
  width: 40%;
  aspect-ratio: .68;
  margin: 0;
  overflow: hidden;
  border: 3px solid var(--gold);
  background: linear-gradient(#e9bd91, #d9a56f);
  box-shadow: inset 0 0 0 4px #182a45, 5px 6px 0 rgba(0, 0, 0, .45);
}
.character-box:last-child { background: linear-gradient(#efb99d, #dca586); }
.character-box canvas {
  position: absolute;
  left: 50%;
  bottom: -1px;
  display: block;
  width: auto;
  height: 100%;
  max-width: none;
  transform: translateX(-50%) scale(var(--portrait-scale, 1));
  transform-origin: 50% 100%;
}
#wei-character { --portrait-scale: 1.03; }
#claris-character { --portrait-scale: .96; }

.portrait-heart {
  flex: 0 0 auto;
  color: #f185b6;
  font-family: ui-monospace, monospace;
  font-size: clamp(1.4rem, 7vw, 2rem);
  filter: drop-shadow(2px 3px 0 #351a35);
}

.couple-title {
  margin: 0;
  color: #fff9e9;
  font-family: Georgia, serif;
  font-size: clamp(2.35rem, 12vw, 3.7rem);
  font-weight: 400;
  line-height: 1.08;
  white-space: nowrap;
}
.couple-title span { color: var(--pink); font-size: .76em; font-style: italic; }

.opening-copy h2 {
  margin: 20px 0 4px;
  color: #e3e8f4;
  font-family: Georgia, serif;
  font-size: clamp(1.25rem, 5.5vw, 1.55rem);
  font-weight: 400;
}
.opening-copy p { margin: 4px 0 22px; color: #bfc9df; }

.name-form { width: min(100%, 340px); margin: 0 auto; text-align: left; }
.name-form label {
  display: block;
  margin-bottom: 7px;
  color: #f4da8c;
  font-size: .875rem;
  font-weight: 700;
  letter-spacing: .04em;
}
.name-form input {
  width: 100%;
  height: 50px;
  padding: 11px 13px;
  border: 2px solid #d6bd74;
  border-radius: 0;
  background: #fffaf0;
  color: #15233a;
  box-shadow: 3px 3px 0 #21375a;
  font-size: 1rem;
}
.name-form input::placeholder { color: #6f7783; }
.form-error { margin: 7px 0 0; color: #ffbdcf; font-size: .875rem; }

.pixel-button {
  display: flex;
  width: 100%;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border: 2px solid #411f42;
  border-radius: 0;
  background: var(--pink);
  color: #111c32;
  box-shadow: inset 3px 3px 0 #ffd2e5, 5px 6px 0 #552a50;
  font-family: ui-monospace, "Courier New", monospace;
  font-size: 1rem;
  font-weight: 800;
  transition: transform .12s, filter .12s;
}
.pixel-button:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); }
.pixel-button:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: inset 2px 2px 0 #ffd2e5, 3px 4px 0 #552a50; }
.pixel-button:disabled { opacity: .48; }
.open-button { margin-top: 15px; }
.opening-note { margin: 23px 0 0; color: #aebbd3; font-family: Georgia, serif; font-size: .875rem; font-style: italic; }

/* Quiz */
.question-screen { background: var(--paper); }
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 20px 14px;
  color: #687363;
  font-size: .875rem;
}
.small-monogram { color: #3c5647; font-family: Georgia, serif; font-size: 1.25rem; letter-spacing: .05em; }
.small-monogram i { color: var(--gold-dark); font-size: .85em; font-weight: 400; }

.scene-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 3;
  overflow: hidden;
  background: #f0eee5;
}
.scene-frame canvas { display: block; width: 100%; height: auto; }
.celebration { position: absolute; inset: 0; width: 100%; height: auto; pointer-events: none; }

.question-content { width: 100%; padding: 0 20px max(28px, env(safe-area-inset-bottom)); }
.reaction-slot {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: center;
  padding: 13px 0 11px;
}
.speech {
  position: relative;
  width: 100%;
  margin: 0;
  padding: 12px 14px;
  border: 2px solid #234f82;
  border-radius: 0;
  background: #fff;
  color: var(--speech-blue);
  box-shadow: 4px 4px 0 #aabed2;
  font-family: ui-monospace, "Courier New", monospace;
  font-size: .9375rem;
  font-weight: 800;
  letter-spacing: .015em;
  line-height: 1.45;
  text-align: center;
}
.speech::before {
  content: "";
  position: absolute;
  top: -7px;
  left: calc(50% - 6px);
  width: 11px;
  height: 11px;
  border-left: 2px solid #234f82;
  border-top: 2px solid #234f82;
  background: #fff;
  transform: rotate(45deg);
}

.question-progress { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
.question-progress p { flex: none; margin: 0; color: #5a665a; font-size: .875rem; }
.progress-track { width: 104px; height: 6px; overflow: hidden; border: 1px solid #9da997; background: #e0e5d9; }
.progress-track span { display: block; height: 100%; background: var(--green); transition: width .2s ease; }
.question-title {
  margin: 0 0 20px;
  color: #354d3e;
  font-family: Georgia, serif;
  font-size: clamp(1.45rem, 7vw, 1.9rem);
  font-weight: 400;
  line-height: 1.25;
}
.question-title:focus, .result h1:focus { outline: none; }
.activities { display: grid; gap: 3px; margin: -5px 0 18px; padding: 0; color: #525f50; list-style: none; }
.answer-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.answer-button {
  display: flex;
  width: 100%;
  min-height: 55px;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: #fffefb;
  color: #354337;
  box-shadow: 2px 2px 0 #e1e4d8;
  font-size: 1rem;
  line-height: 1.35;
  text-align: left;
}
.answer-button:hover:not(:disabled) { border-color: var(--green); background: #eff3e8; }
.answer-button:disabled { opacity: 1; pointer-events: none; }
.answer-button.selected { border: 2px solid var(--green); background: #e9efdf; padding: 10px 12px; }
.choice-letter {
  display: flex;
  width: 27px;
  height: 27px;
  flex: none;
  align-items: center;
  justify-content: center;
  border: 1px solid #bfc7b6;
  color: #4d624d;
  font-family: ui-monospace, monospace;
  font-size: .875rem;
  font-weight: 800;
}
.selected-marker { margin-left: auto; color: var(--green); font-weight: 800; }
.next-slot { min-height: 88px; padding-top: 20px; text-align: center; }
.next-button { border-color: #344b3e; background: var(--green); color: #fff; box-shadow: inset 2px 2px 0 #698274, 4px 5px 0 #b7bdaa; }
.next-button { touch-action: manipulation; }
.next-button:active:not(:disabled) { box-shadow: inset 2px 2px 0 #698274, 2px 3px 0 #b7bdaa; }
.answer-hint { margin: 4px 0; color: #6b7266; font-size: .875rem; }

/* Result and invitation */
.final-screen { padding: max(25px, env(safe-area-inset-top)) 12px max(26px, env(safe-area-inset-bottom)); background: var(--paper); }
.result { max-width: 410px; margin: 0 auto 23px; text-align: center; }
.eyebrow { margin: 0 0 9px; color: #5b675b; font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; }
.result h1 { margin: 7px 0 6px; overflow-wrap: anywhere; font-size: 1.2rem; line-height: 1.4; }
.result > p:last-child { margin: 0; color: var(--muted); font-size: .875rem; }
.invitation { margin: 0 auto; border: 1px solid #c6cbbd; background: #fffef9; box-shadow: 4px 4px 0 #e2e5d8; }
.final-art { aspect-ratio: 1536 / 921; }
.invitation-body { padding: 28px 17px; text-align: center; }
.invitation-intro { margin: 0 0 14px; color: #65715d; }
.invitation .couple-title { color: #3c5647; font-size: clamp(2.3rem, 12vw, 3.25rem); }
.invitation .couple-title span { color: #a7607e; }
.invitation-wording { margin: 17px 0 21px; }
.invitation-wording span, address span { display: block; }
.invitation-rule { width: 64px; height: 1px; margin: 24px auto; background: #b9c1ac; }
.wedding-date { margin: 0 0 4px; color: #405641; font-family: Georgia, serif; font-size: 1.3rem; }
.wedding-time { margin: 0; }
.venue { margin: 24px 0 6px; color: #405641; font-family: Georgia, serif; font-size: 1.18rem; }
address { color: #626b5e; font-style: normal; }
.closing { max-width: 350px; margin: 27px auto 29px; color: #58674e; font-family: Georgia, serif; font-style: italic; }
.blessing { max-width: 410px; margin: 0 auto; padding: 22px 6px 0; border-top: 1px solid #dce0d2; }
blockquote { margin: 0; }
blockquote p { margin: 9px 0 11px; color: #41583f; font-family: Georgia, serif; font-size: 1.08rem; line-height: 1.65; }
blockquote cite { color: #68745f; font-size: .875rem; font-style: normal; }
.replay-button {
  display: block;
  min-height: 46px;
  margin: 24px auto;
  padding: 10px 25px;
  border: 1px solid #8f9d85;
  border-radius: 2px;
  background: #fffefb;
  color: #354337;
  box-shadow: 2px 2px 0 #d8ddd0;
  font-size: 1rem;
}
.copyright { max-width: 420px; margin: 0 auto; color: #68715f; font-size: .75rem; line-height: 1.6; text-align: center; }
.copyright p { margin: 0 0 8px; }
.copyright a { text-decoration: underline; text-underline-offset: 3px; }

noscript { display: block; padding: 24px; background: var(--paper); color: var(--ink); text-align: center; }

@media (max-width: 359px) {
  .opening-screen { padding-inline: 8px; }
  .opening-card { padding-inline: 14px; }
  .save-date::before { left: 10%; }
  .save-date::after { right: 10%; }
  .question-content { padding-inline: 16px; }
  .couple-title { font-size: 2.25rem; }
  .portrait-row { gap: 6px; }
  .speech { font-size: .875rem; }
}

@media (hover: none), (pointer: coarse) {
  .next-slot {
    padding-bottom: max(84px, calc(env(safe-area-inset-bottom) + 64px));
  }
}

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