* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #172325;
  color: #fff2db;
  font-family: "Avenir Next", Arial, sans-serif;
}
button,
summary {
  cursor: pointer;
  font: inherit;
}
button {
  color: inherit;
  border: 1px solid #e2cdab63;
  background: #223331e8;
  border-radius: 8px;
  padding: 0.55em 0.85em;
}
button:focus-visible,
summary:focus-visible {
  outline: 3px solid #e9be78;
  outline-offset: 3px;
}
button:hover {
  filter: brightness(1.18);
}
button:disabled {
  opacity: 0.58;
}
canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}
[hidden] {
  display: none !important;
}
#menu {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    #142524f5,
    #172926d4 31%,
    #14221e47 65%,
    #14221e0d
  );
  display: flex;
  align-items: center;
  padding: clamp(24px, 7vw, 120px);
  overflow: auto;
}
.intro {
  max-width: 485px;
}
.moon {
  font: 3.2rem Georgia;
  color: #edc795;
  line-height: 1;
  margin-bottom: 1rem;
}
h1 {
  font:
    normal clamp(3.6rem, 6.5vw, 6.8rem)/0.96 Georgia,
    serif;
  letter-spacing: -0.055em;
  margin: 0;
}
h1 em {
  font-weight: normal;
  color: #eccb9c;
}
#introText {
  font-size: clamp(1rem, 1.4vw, 1.24rem);
  line-height: 1.6;
  max-width: 33ch;
  margin: 1.5rem 0;
  color: #f2e4cc;
}
.primary {
  background: #f3dcaf;
  color: #233a34;
  padding: 0.9rem 1.8rem;
  font-weight: 650;
  border: 0;
}
summary {
  width: max-content;
  color: #e3d2b5;
  margin-top: 1.2rem;
  font-size: 0.94rem;
}
.guide {
  background: #20312fef;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  max-height: 32vh;
  overflow: auto;
  font-size: 0.92rem;
  line-height: 1.46;
  margin: 0.6rem 0;
}
.guide p {
  margin: 0.5rem 0;
}
.guide span {
  opacity: 0.5;
  margin: 0 0.35em;
}
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  user-select: none;
}
#hud button,
#touch > div {
  pointer-events: auto;
}
header,
#location,
.actions {
  position: absolute;
  top: clamp(15px, 3vh, 32px);
}
header {
  left: 3vw;
  font: italic clamp(17px, 2.2vw, 30px) Georgia;
  text-shadow: 0 2px 9px #161c19;
}
.mark {
  color: #f4cd90;
  padding-right: 8px;
}
#location,
.eyebrow {
  font-size: 0.76rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #ebcfa8;
}
#location {
  left: 50%;
  transform: translateX(-50%);
  padding: 0.65em 1.25em;
  background: #1d302cce;
  border-radius: 99px;
}
.actions {
  right: 3vw;
  display: flex;
  gap: 7px;
}
.actions button {
  height: 35px;
  min-width: 36px;
  padding: 0;
  font-size: 18px;
}
#clock {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0 0.75em;
  background: #1d302ce8;
  border-radius: 8px;
  color: #ebcfa8;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
#clock b {
  color: #fff2db;
}
#result {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(25rem, 90vw);
  padding: clamp(1.2rem, 4vh, 2rem) 1.4rem;
  text-align: center;
  border: 1px solid #c6a7758a;
  border-radius: 14px;
  color: #fff2db;
  background: linear-gradient(150deg, #293c37fa, #162925fa);
  box-shadow: 0 12px 54px #0a141a55;
}
#result h2 {
  margin: 0;
  font: normal clamp(1.85rem, 4vw, 2.7rem)/1.1 Georgia, serif;
}
#resultTitle:focus {
  outline: none;
}
.timeLabel {
  margin: 1.1rem 0 0;
  color: #ebcfa8;
  font-size: 0.78rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}
#finishTime {
  margin: 0.15rem 0 1.2rem;
  color: #ffdfa6;
  font: normal clamp(3.15rem, 8vw, 4.7rem)/1.05 Georgia, serif;
  font-variant-numeric: lining-nums tabular-nums;
}
.resultActions {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
}
.resultActions button {
  padding: 0.65rem 1rem;
}
body.withdrawing #prompt:after {
  display: none;
}
@media (max-width: 410px) {
  #clock span {
    display: none;
  }
}
#aim,
#guideStar,
#prompt,
#feedback,
#awake,
#reader {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
#aim {
  top: 50%;
  height: 4px;
  width: 4px;
  background: #fff2db;
  border-radius: 50%;
  box-shadow: 0 0 2px #000;
}
#guideStar {
  font: 28px Georgia;
  color: #ffdfaa;
  text-shadow: 0 1px 3px #000;
}
#prompt,
#reader,
#awake {
  background: #192c2dec;
  border: 1px solid #b7aa876b;
  border-radius: 10px;
  padding: 0.6rem 1rem;
  max-width: 95vw;
}
#prompt {
  top: 61%;
  font-size: 0.97rem;
  white-space: nowrap;
  overflow: hidden;
}
#prompt:after {
  content: "";
  position: absolute;
  bottom: 1px;
  left: 4%;
  width: calc(92% * var(--p, 0));
  height: 2px;
  background: #eed2a3;
}
#feedback {
  top: 69%;
  text-shadow: 0 1px 4px black;
}
#awake {
  top: 19%;
  font-size: 1rem;
}
#awake button {
  margin-left: 8px;
}
#objective,
#sleep {
  position: absolute;
  bottom: 9%;
  padding: 0.9rem 1.15rem;
  border: 1px solid #d9c7a34a;
  background: #1a2d2bea;
  border-radius: 12px;
  box-shadow: 0 5px 20px #15242015;
}
#objective {
  left: 3vw;
  max-width: 45%;
}
#sleep {
  right: 3vw;
  width: clamp(145px, 19vw, 250px);
}
.eyebrow {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
#chapter {
  opacity: 0.7;
  letter-spacing: 0.04em;
}
aside strong,
#reader strong {
  display: block;
  font: normal clamp(1.16rem, 1.65vw, 1.5rem) Georgia;
  margin: 0.35rem 0;
}
aside small {
  color: #d6d8c7;
  font-size: 0.85rem;
}
.meter {
  display: grid;
  grid-template-columns: repeat(18, minmax(0, 1fr));
  gap: 3px;
  height: 6px;
  margin: 0.48rem 0 0.16rem;
  --lit: #d9bd89;
}
.meter.warning {
  --lit: #e29a72;
}
.meter i {
  height: 100%;
  background: #546664b3;
  border-radius: 2px;
}
.meter i.lit {
  background: var(--lit);
}
#radioNoise {
  color: #e7c593;
  font-size: 0.76rem;
  margin-top: 0.32rem;
  display: block;
}
#keys {
  position: absolute;
  bottom: 2.6%;
  left: 3vw;
  font-size: 0.83rem;
  text-shadow: 0 1px 4px #000;
}
kbd {
  font: 600 0.85em Arial;
  border: 1px solid #dbcdac83;
  padding: 0.16em 0.42em;
  border-radius: 4px;
  background: #263a37;
  color: #fff1d7;
}
#keys kbd:not(:first-child) {
  margin-left: 12px;
}
#reader {
  bottom: 3%;
  top: auto;
  transform: translateX(-50%);
  min-width: min(380px, 97vw);
}
#reader div {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
#reader strong {
  margin-bottom: 8px;
}
#reader button {
  font-size: 0.87rem;
}
#touch {
  display: none;
}
body.reading #aim,
body.reading #objective,
body.reading #sleep,
body.reading #keys,
body.reading #touch,
body.reading #prompt {
  display: none;
}
@media (pointer: coarse) {
  #touch {
    display: block;
  }
  #keys {
    display: none;
  }
  #stick,
  #touchKeys {
    position: absolute;
    bottom: 15px;
    touch-action: none;
  }
  #stick {
    left: 4vw;
    width: 85px;
    height: 85px;
    border-radius: 50%;
    background: #233530b5;
    border: 1px solid #d5c4a287;
    display: grid;
    place-items: center;
  }
  #stick i {
    border-radius: 50%;
    background: #d6c1a0ba;
    width: 32px;
    height: 32px;
  }
  #touchKeys {
    right: 4vw;
    display: grid;
    gap: 5px;
  }
  #objective,
  #sleep {
    bottom: 148px;
  }
  #touch button {
    touch-action: none;
  }
}
@media (max-width: 650px) {
  header {
    font-size: 17px;
  }
  #location {
    top: 60px;
  }
  #objective {
    max-width: 56%;
  }
  #sleep {
    max-width: 37%;
  }
  #awake {
    top: 26%;
    width: max-content;
  }
  #keys {
    font-size: 0.72rem;
  }
  #menu {
    background: linear-gradient(90deg, #152827ec, #17292665);
  }
}
@media (max-height: 560px) {
  #menu {
    align-items: flex-start;
    padding-top: 24px;
  }
  .moon {
    display: none;
  }
  h1 {
    font-size: 3.2rem;
  }
  #introText {
    margin: 0.7rem 0;
  }
  .guide {
    max-height: 24vh;
  }
  #objective,
  #sleep {
    bottom: 8%;
    padding: 0.5rem 0.8rem;
  }
  body.touch #objective,
  body.touch #sleep {
    top: 14%;
    bottom: auto;
  }
  body.touch #location {
    display: none;
  }
}
@media (max-width: 650px) {
  #prompt {
    font-size: 0.85rem;
    white-space: normal;
    width: max-content;
    max-width: 90vw;
  }
  #reader {
    padding: 0.45rem 0.55rem;
  }
}

body.withdrawing #keys,
body.withdrawing #stick {
  display: none;
}
body.withdrawing #touchKeys {
  left: 4vw;
  display: flex;
  justify-content: space-between;
}
body.withdrawing #touchKeys button {
  min-height: 48px;
}
.achievements summary { cursor: pointer; }
.achievementList {
  list-style: none;
  padding: 0.3rem 0;
  margin: 0.5rem 0 0;
  text-align: left;
}
.achievementList li { border-top: 1px solid #bbaa8c45; padding: 0.55rem 0; }
.achievementList strong, .achievementList small { display: block; }
.achievementList small { color: #ded7c9; margin-top: 0.15rem; line-height: 1.4; }
.achievementList .earned strong, #earnedTonight { color: #f1d39d; }
#menu .achievements[open] { background: #1d302ff2; padding: 0.1rem 0.85rem 0.4rem; border-radius: 8px; }
#menu .achievementList { max-height: 34vh; overflow-y: auto; }
#result { max-height: 88dvh; overflow-y: auto; pointer-events: auto; }
#result .achievements summary { margin: 0.9rem auto 0; }
#earnedTonight { font-size: 0.88rem; margin: -0.3rem 0 0.9rem; }
#achievementNotice {
  position: absolute; top: 17%; left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 88vw; padding: 0.6rem 0.9rem;
  border-radius: 8px; color: #ffdfa6; background: #1d302cf2; text-align: center;
}
