:root {
  color-scheme: light;
  font-family: Georgia, serif;
  color: #222a24;
  background: #eeeae0;
  --paper: #fbf8ef;
  --accent: #795331;
  --ink: #192f28;
  --line: #d9cdb8;
  --sans: system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; }
.reader {
  width: min(100% - 32px, 790px);
  margin: clamp(20px, 5vw, 58px) auto 32px;
}
.masthead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  border-bottom: 1px solid #c6b79f;
  padding-bottom: 14px;
  color: #535449;
  font: 600 .75rem/1.35 var(--sans);
}
#progress { white-space: nowrap; color: var(--accent); }
h1 {
  margin: 22px 0 24px;
  color: var(--ink);
  font-size: clamp(1.95rem, 6.35vw, 4.15rem);
  font-weight: normal;
  letter-spacing: -.055em;
  line-height: 1.12;
}
h1 em { font-weight: normal; }

#story {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 16px 42px #34280d13;
}
.stage {
  --portrait-size: clamp(63px, 11vw, 98px);
  --left-position: 20%;
  position: relative;
  isolation: isolate;
  min-height: clamp(174px, 27vw, 284px);
  overflow: hidden;
  background: #152722;
  background-image: linear-gradient(180deg, #101e1b27, #0e1d18bd), url("./great-hall.webp");
  background-size: cover;
  background-position: center;
}
.stage::before {
  content: '';
  position: absolute;
  top: calc(50% + var(--portrait-size) / 2 - 2px);
  left: 8%;
  right: 5%;
  height: 8px;
  border-top: 2px solid #ddbe82;
  border-bottom: 1px solid #b9975d;
  background: linear-gradient(90deg, #a4804870, #e1be8166, #a4804870);
  border-radius: 6px;
  box-shadow: 0 4px 10px #080f0bbb;
}
.actor {
  position: absolute;
  top: calc(50% - var(--portrait-size) / 2);
  left: var(--left-position);
  width: var(--portrait-size);
  margin: 0;
  text-align: center;
}
.actor.moving { left: calc(var(--left-position) + var(--portrait-size)); }

figcaption {
  width: 100%;
  margin: 9px auto 0;
  color: #fff1d6;
  font: 600 .78rem/1.25 var(--sans);
  text-shadow: 0 1px 4px #071411;
}
.portrait {
  position: relative;
  width: var(--portrait-size);
  aspect-ratio: 1;
  margin: auto;
  border: 1px solid #d3b681;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 20%, #f9e9c5, #dfbb81);
  box-shadow: inset 0 0 0 4px #563d281e, 0 6px 22px #08141191;
}
.hat i {
  position: absolute;
  inset: 15% 19% 24%;
  background: linear-gradient(130deg, #92704a, #4d3728 77%);
  clip-path: polygon(0 100%, 24% 60%, 36% 31%, 69% 2%, 91% 15%, 65% 23%, 62% 41%, 78% 65%, 100% 100%);
}
.hat b {
  position: absolute;
  inset: auto 12% 20%;
  height: 16%;
  border-radius: 50%;
  background: #504030;
  border-top: 2px solid #a38050;
}
.harry i {
  position: absolute;
  inset: 15% 21% 17%;
  border-radius: 45% 45% 44% 44%;
  background: #dba777;
  border-top: clamp(11px, 2.2vw, 19px) solid #3c2d25;
}
.harry i::after {
  content: '';
  position: absolute;
  bottom: 16%;
  left: 39%;
  width: 22%;
  height: 8%;
  background: #875840;
  border-radius: 0 0 50% 50%;
}
.harry b {
  position: absolute;
  inset: 43% 26% auto;
  height: 16%;
  background: linear-gradient(#443026, #443026) center 42% / 20% 2px no-repeat;
}
.harry b::before, .harry b::after {
  content: '';
  position: absolute;
  top: 0;
  width: 43%;
  aspect-ratio: 1;
  border: 2px solid #443026;
  border-radius: 50%;
}
.harry b::before { left: 0; }
.harry b::after { right: 0; }

.copy, .choices, .feedback { margin-inline: clamp(16px, 5vw, 44px); }
.copy { margin-top: clamp(18px, 3.5vw, 34px); margin-bottom: 19px; }
.copy p, .ending p {
  max-width: 58ch;
  margin: 0 0 14px;
  color: #41443a;
  font-size: clamp(1.06rem, 2.15vw, 1.25rem);
  line-height: 1.53;
}
h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.25rem, 3.3vw, 1.65rem);
  line-height: 1.2;
}
h2:focus { outline: none; }
.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 13px);
}
button {
  padding: 12px clamp(8px, 2vw, 17px);
  min-height: 56px;
  border: 1px solid #9c805f;
  border-radius: 7px;
  color: var(--ink);
  background: #f3eddf;
  cursor: pointer;
  font: 650 .87rem/1.28 var(--sans);
  overflow-wrap: anywhere;
}
button:hover { border-color: var(--accent); background: #ede2ca; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button.incorrect { border-color: var(--accent); background: #f0ddc6; }
.feedback {
  min-height: 1.25em;
  margin-top: 8px;
  margin-bottom: 10px;
  color: var(--accent);
  font: 600 .81rem/1.3 var(--sans);
}
.ending { padding: clamp(24px, 6vw, 54px) clamp(16px, 5vw, 44px); }
.ending h2 { font-size: clamp(2.3rem, 7vw, 4rem); font-weight: normal; margin-bottom: 10px; }

@media (max-width: 420px) {
  h1 { margin: 16px 0 17px; }
  .masthead { padding-bottom: 10px; }
  #story { border-radius: 10px; }
}

.wearing-hat i { inset: 29% 21% 10%; border-top-width: 0; }
.wearing-hat b { top: 51%; }
.wearing-hat span {
  position: absolute;
  inset: 5% 13% 59%;
  z-index: 1;
  background: linear-gradient(125deg, #9b754d, #4d3728 82%);
  clip-path: polygon(0 85%, 23% 72%, 33% 48%, 44% 20%, 74% 0, 63% 32%, 76% 72%, 100% 85%, 94% 100%, 6% 100%);
}
.thinking i::after { left: 43%; width: 14%; height: 10%; border-radius: 50%; }
.thinking b { transform: translateY(-2px); }
.sorted span {
  position: absolute;
  inset: auto 20% 10%;
  height: 13%;
  border-radius: 5px;
  background: repeating-linear-gradient(105deg, #773829 0 8px, #bd9657 8px 13px);
}
.voice i {
  position: absolute;
  inset: 26% 18% 28%;
  border: 2px solid #5e422a;
  border-radius: 42%;
}
.voice i::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 22%;
  width: 10px;
  height: 10px;
  border-left: 2px solid #5e422a;
  transform: skewY(-38deg);
}
.voice b {
  position: absolute;
  top: 47%;
  left: calc(50% - 2px);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #5e422a;
  box-shadow: -8px 0 #5e422a, 8px 0 #5e422a;
}
