:root {
  color-scheme: light;
  --navy: #111d32;
  --ink: #152339;
  --muted: #4b5664;
  --gold: #ad8044;
  --gold-dark: #725025;
  --champagne: #dfbd81;
  --paper: #f9f3e7;
  --rule: #d2ba92;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", STSong, "Noto Serif CJK SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

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

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 0%, #273b54 0, transparent 54%),
    repeating-linear-gradient(129deg, #e3c38507 0 1px, transparent 1px 36px),
    #101a2c;
  font: 1rem/1.65 var(--sans);
  -webkit-text-size-adjust: 100%;
}

button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
img { display: block; max-width: 100%; height: auto; }
[hidden] { display: none !important; }
::selection { background: #ead3a5; color: var(--ink); }

:focus-visible { outline: 2px solid #9e6924; outline-offset: 4px; }
[tabindex="-1"]:focus { outline: none; }
h1, h2, p { margin: 0; }

.app-shell {
  width: 100%;
  max-width: 30rem;
  margin-inline: auto;
  padding: 1.25rem 1rem;
  padding-top: max(1.25rem, env(safe-area-inset-top));
  padding-right: max(1rem, env(safe-area-inset-right));
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  padding-left: max(1rem, env(safe-area-inset-left));
}

.masthead {
  min-height: 2.45rem;
  margin: 0 .125rem 1rem;
  display: flex;
  align-items: center;
  color: #f3e2bc;
}

.masthead-brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  font: 600 .86rem/1.3 var(--serif);
  letter-spacing: .055em;
}

.masthead-mark { flex: 0 0 auto; width: 2rem; height: 2rem; color: var(--champagne); }
#screen { min-width: 0; }

.paper {
  position: relative;
  min-width: 0;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #e2ca9f;
  border-radius: .625rem;
  box-shadow: 0 24px 60px #060b156b, 0 2px 7px #060b1566;
}

.invitation, .result {
  padding: 2.2rem clamp(1.15rem, 6.6vw, 2.35rem) 1.85rem;
  text-align: center;
  background:
    radial-gradient(ellipse at top, #fffaf0, transparent 74%),
    repeating-linear-gradient(120deg, #95622d09 0 1px, transparent 1px 5px),
    var(--paper);
}

.invitation::before, .result::before {
  content: "";
  position: absolute;
  inset: .46rem;
  border: 1px solid #ae80596b;
  border-radius: .35rem;
  pointer-events: none;
}

.invitation::after, .result::after {
  content: "";
  position: absolute;
  inset: .64rem;
  border: 1px solid #c5a67848;
  border-radius: .25rem;
  pointer-events: none;
}

.eyebrow {
  color: var(--gold-dark);
  font: 700 .875rem/1.35 var(--serif);
  letter-spacing: .21em;
}

.cover-flourish {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  margin-bottom: .78rem;
  color: #a2763f;
}

.cover-flourish::before, .cover-flourish::after {
  content: "";
  width: 2.3rem;
  height: 1px;
  background: linear-gradient(to right, transparent, #b99361);
}

.cover-flourish::after { transform: scaleX(-1); }
.cover-flourish svg { display: block; width: .9rem; height: .9rem; }

.cover-title {
  margin: .78rem 0 .85rem;
  font: 700 clamp(1.8rem, 8.6vw, 2.6rem)/1.14 var(--serif);
  letter-spacing: -.035em;
}

.cover-title span { display: block; }
.cover-title .cover-edition {
  margin-top: .48rem;
  font-size: .58em;
  letter-spacing: .08em;
  color: var(--gold-dark);
}

.invitation-copy, .result-copy {
  max-width: 21rem;
  margin: 0 auto;
  color: var(--muted);
  font-size: .9375rem;
  line-height: 1.75;
  text-wrap: pretty;
}

.invitation-copy + .invitation-copy { margin-top: .36rem; }

.seal {
  width: 5.6rem;
  height: 5.6rem;
  display: block;
  margin: .88rem auto .86rem;
  color: #94662f;
  transform: rotate(-9deg);
}

.cover-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0 0 1.1rem;
  padding: .68rem 0;
  border-block: 1px solid var(--rule);
}

.cover-meta div { padding: 0 .35rem; }
.cover-meta div + div { border-inline-start: 1px solid var(--rule); }
.cover-meta dt { font-size: .8125rem; line-height: 1.3; color: var(--muted); }
.cover-meta dd { margin: .12rem 0 0; font-weight: 700; font-size: 1rem; }

.button-primary, .outline-button {
  border-radius: .35rem;
  min-height: 2.875rem;
  padding: .57rem 1rem;
  text-align: center;
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.button-primary {
  width: 100%;
  border: 1px solid #172641;
  color: #fff4d9;
  background: linear-gradient(135deg, #243955, #121f35 80%);
  box-shadow: inset 0 0 0 2px #e8cd921d, 0 3px 7px #17223924;
}

.button-primary:active { background: #102037; }
.button-primary:disabled { opacity: .6; }

.outline-button {
  border: 1px solid #ad8d61;
  background: #fffaf0;
  color: var(--ink);
  font-size: .875rem;
}

.button-quiet {
  background: transparent;
  border: 0;
  border-radius: .25rem;
  min-height: 2.75rem;
  padding: .4rem .75rem;
  color: inherit;
  font-size: .875rem;
  text-decoration: underline;
  text-underline-offset: .22em;
}

.utilities { color: #e1c893; text-align: center; margin-top: .35rem; }
.noscript { color: #fff4d9; padding: 1rem 0; }

.question-card { padding: clamp(1.05rem, 5vw, 1.7rem); }

.progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  margin-bottom: .48rem;
  font-weight: 700;
  color: var(--gold-dark);
  font-size: .875rem;
}

.progress-copy span:last-child {
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.progress-track, .timer-track {
  height: .42rem;
  border-radius: 1rem;
  overflow: hidden;
  background-color: #e4d7bf;
}

.progress-fill, .timer-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #9b6c34;
  transform: scaleX(0);
  transform-origin: left;
}

.question-title {
  margin: 1.08rem 0 .96rem;
  font: 700 clamp(1.24rem, 5vw, 1.63rem)/1.48 var(--serif);
  overflow-wrap: anywhere;
}

.question-note {
  margin: -.35rem 0 .76rem;
  font-size: .875rem;
  color: var(--muted);
}

.choices { display: grid; gap: .49rem; }

.choice {
  display: grid;
  grid-template-columns: 1.82rem minmax(0, 1fr);
  align-items: center;
  gap: .58rem;
  width: 100%;
  min-height: 3.15rem;
  border: 1px solid #c7b18f;
  border-radius: .4rem;
  padding: .43rem .63rem;
  color: var(--ink);
  background: #fffbf3;
  text-align: start;
  font-size: .965rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.choice:disabled { opacity: 1; color: var(--ink); }
.choices[data-locked="true"] .choice { background: #eee7d8; border-color: #d9ccb6; }
.choice[data-state="incorrect"] { background: #f8e7e2; border-color: #9c5b52; }
.choice[data-state="correct"] { background: #eaf1e8; border-color: #5c7c68; }

.choice-letter {
  display: grid;
  place-items: center;
  align-self: start;
  margin-block: .045rem;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid #d5be98;
  border-radius: .22rem;
  color: var(--gold-dark);
  background: #f7edd9;
  font: 700 .92rem/1 var(--serif);
}

.choice[data-state="incorrect"] .choice-letter { background: #ffece6; border-color: #a76d62; color: #743733; }
.choice[data-state="correct"] .choice-letter { background: #dceadf; border-color: #7c9b88; color: #304c3d; }

.choice-text { white-space: pre-wrap; }

.timer-panel {
  margin: 0 0 .78rem;
  padding: .73rem;
  background: #f1e5ce;
  border: 1px solid #cab093;
  border-radius: .4rem;
}

.timer-label { display: block; margin: 0 0 .43rem; font-weight: 700; font-size: .875rem; }
.timer-track { background: #e0ccab; height: .55rem; }
.timer-fill { background: linear-gradient(90deg, #8c632d, #a97022); }
.timer-panel button { margin-top: .56rem; width: 100%; }

.answer-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: .5rem;
}

.input-label {
  grid-column: 1 / -1;
  font-size: .875rem;
  font-weight: 700;
  color: var(--muted);
}

.answer-form input {
  width: 100%;
  min-width: 0;
  min-height: 2.875rem;
  padding: .42rem .54rem;
  border: 1px solid #a98f69;
  border-radius: .35rem;
  color: var(--ink);
  background: #fffaf1;
  font-size: 1rem;
}

.answer-form .button-primary { width: auto; padding-inline: .85rem; }

.feedback {
  display: grid;
  gap: .25rem;
  margin-top: .77rem;
  padding: .62rem .76rem;
  border: 1px solid #b88b71;
  border-radius: .35rem;
  background: #f8e9e0;
  color: #66372f;
  overflow-wrap: anywhere;
}

.feedback[data-state="correct"] {
  color: #254537;
  border-color: #9bad9b;
  background: #ebf1e8;
}

.feedback strong { display: block; font-size: .9rem; }
.feedback p { white-space: pre-wrap; line-height: 1.52; }
.question-asset { margin: .57rem 0 0; }
.question-asset img { margin-inline: auto; object-fit: contain; border-radius: .2rem; }
.meme-image { width: auto; max-height: 8.125rem; }
.photo-open { width: 100%; }
.photo-open img { max-height: 10rem; margin-bottom: .34rem; }
.photo-open span { font-size: .875rem; text-decoration: underline; text-underline-offset: .18em; }
.next-button { margin-top: .72rem; }
.result .seal { width: 6.55rem; height: 6.55rem; margin-top: 1.23rem; margin-bottom: 1.23rem; }
.result .cover-title { margin-bottom: .72rem; }
.result .button-primary { margin-top: .28rem; }

.photo-dialog {
  max-width: min(calc(100% - 1.5rem), 32rem);
  width: 100%;
  max-height: calc(100% - 1.5rem);
  padding: 1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: .6rem;
  box-shadow: 0 1rem 3rem #0208147d;
}

.photo-dialog::backdrop { background: #070e1bd1; }
.photo-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.photo-toolbar h2 { font: 700 1.25rem/1.35 var(--serif); }
.photo-scroll {
  max-height: 60vh;
  max-height: max(9rem, calc(100dvh - 10rem));
  overflow: auto;
  margin-block: .75rem;
  background: white;
}
.photo-scroll img { width: 100%; height: auto; }
.photo-scroll[data-zoomed="true"] img { width: max(53rem, 200%); max-width: none; }

@media (min-width: 36rem) {
  .app-shell { padding-top: max(2.8rem, env(safe-area-inset-top)); }
}

@media (hover: hover) {
  .button-primary:hover:not(:disabled) { background: #293e5e; }
  .outline-button:hover:not(:disabled) { background: #f3e8d3; }
  .choice:hover:not(:disabled):not([data-state]) { border-color: #8e6837; background: #f8eedb; }
}

@media (prefers-reduced-motion: no-preference) {
  .paper { animation: paper-enter .26s ease-out both; }
  @keyframes paper-enter {
    from { opacity: 0; transform: translateY(.35rem); }
    to { opacity: 1; transform: translateY(0); }
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
