:root {
  color-scheme: dark;
  --ink: #281f35;
  --cream: #fff0c9;
  --gold: #ffc16d;
  --red: #bb4438;
  font-family:
    -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic",
    sans-serif;
  color: var(--cream);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--ink);
}
[hidden] {
  display: none !important;
}
button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible {
  outline: 3px solid #ffe09d;
  outline-offset: 3px;
}
#theatre {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 280px;
  overflow: hidden;
}
#title,
#arena,
#dialog,
.scenery,
.veil {
  position: absolute;
  inset: 0;
}
#title {
  isolation: isolate;
  background: #32273e;
  overflow: hidden;
}
.scenery {
  z-index: -3;
  background: url(./courtyard.webp) center 49% / cover no-repeat;
}
.veil {
  z-index: -2;
  background:
    linear-gradient(
      90deg,
      rgba(27, 21, 44, 0.87) 0%,
      rgba(36, 24, 44, 0.72) 30%,
      rgba(40, 26, 45, 0.12) 63%
    ),
    linear-gradient(0deg, rgba(29, 22, 40, 0.57), transparent 38%);
}
.star {
  position: absolute;
  width: min(53vw, 780px);
  height: 83%;
  object-fit: contain;
  right: 4%;
  bottom: 6%;
  filter: drop-shadow(10px 19px 6px rgba(29, 17, 31, 0.46));
  z-index: -1;
}
.poster {
  position: absolute;
  left: max(7vw, env(safe-area-inset-left));
  top: 50%;
  transform: translateY(-50%);
}
.venue,
.folio {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: #ffda98;
  font-size: clamp(14px, 1.4vw, 19px);
  font-weight: 750;
}
.venue i {
  width: 24px;
  height: 3px;
  background: var(--gold);
  transform: rotate(-8deg);
}
h1,
h2,
.nameplate {
  font-family: "AppleMyungjo", "Batang", "Nanum Myeongjo", serif;
}
h1 {
  font-size: clamp(72px, min(9.5vw, 16vh), 154px);
  letter-spacing: -0.095em;
  line-height: 0.98;
  margin: 0.24em 0 0.19em -0.04em;
  transform: rotate(-4deg);
  text-shadow: 3px 5px #552e39;
}
h1 span {
  color: #ffd27d;
}
.premise {
  line-height: 1.6;
  font-weight: 600;
  font-size: clamp(15px, 1.4vw, 20px);
  margin: 1.1em 0 1.35em;
}
.paint {
  font-weight: 850;
  color: #392937;
  border: 0;
  background: #ffcb72;
  padding: 13px 35px;
  min-height: 48px;
  box-shadow: inset 0 -3px 0 #cc8c4e;
  border-radius: 52% 47% 46% 49% / 15% 14% 18% 15%;
  font-size: 17px;
  letter-spacing: -0.025em;
}
.paint:disabled {
  opacity: 0.65;
}
.paint:active {
  transform: translateY(2px);
}
.method {
  font-size: 13px;
  color: #f1dfc5;
  margin-top: 12px;
}
.method span {
  margin: 0 4px;
  color: #efb86b;
}
#arena {
  background: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
canvas {
  width: 100%;
  height: 100%;
  display: block;
}
header {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}
.eyebrow {
  font-size: 13px;
  font-weight: 700;
  text-shadow: 0 1px 3px #241a30;
}
.ward {
  display: grid;
  gap: 7px;
}
#lamps {
  display: flex;
  gap: 7px;
}
.lamp {
  width: 13px;
  height: 15px;
  border-radius: 35% 35% 42% 42%;
  background: #fabb59;
  border: 1px solid #ffddb1;
  box-shadow:
    inset 2px 0 #b55d40,
    inset -2px 0 #b55d40;
  position: relative;
}
.lamp:before,
.lamp:after {
  content: "";
  position: absolute;
  background: #dcc69c;
  left: 3px;
  width: 5px;
  height: 2px;
}
.lamp:before {
  top: -3px;
}
.lamp:after {
  bottom: -4px;
}
.lamp.out {
  filter: saturate(0.1);
  opacity: 0.26;
}
.tools {
  display: flex;
  gap: 5px;
  pointer-events: auto;
}
.tools button,
#home {
  border: 0;
  color: var(--cream);
  background: #352538e0;
  min-height: 44px;
  min-width: 44px;
  border-radius: 5px;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 650;
}
#pause {
  font-size: 17px;
}
.nameplate {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 3px #24162c;
  font-weight: 800;
  font-size: clamp(17px, 2.2vw, 28px);
}
#life {
  width: 100%;
  min-width: 104px;
  height: 6px;
  margin: 5px auto 0;
  background: #362537;
  border: 1px solid #e6be8c;
}
#lifeBar {
  display: block;
  height: 100%;
  background: #ff9663;
  transition: width 0.12s;
}
.score {
  position: absolute;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  display: grid;
  text-align: center;
  color: #ffdd98;
  text-shadow: 0 2px 3px #281c2c;
}
.score strong {
  font:
    800 clamp(23px, 3vw, 36px)/1 ui-monospace,
    Menlo,
    monospace;
}
.score span {
  margin-top: 3px;
  font-size: 12px;
}
#drum {
  position: absolute;
  border: 0;
  border-radius: 50%;
  background: transparent;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#drum:focus:not(:focus-visible) {
  outline: none;
}
#tip {
  position: absolute;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: #fff0d2;
  text-shadow: 0 2px 3px #23182e;
  text-align: center;
  width: min(72%, 550px);
  font-size: clamp(13px, 1.5vw, 17px);
  font-weight: 650;
  pointer-events: none;
  word-break: keep-all;
}
#dialog {
  z-index: 5;
  display: grid;
  place-items: center;
  background: #21182caa;
  padding: 12px;
}
.paper {
  background: #f5e5bb;
  color: #382939;
  width: min(348px, 100%);
  padding: 28px 27px 16px;
  box-shadow:
    inset 0 0 0 5px #f5e5bb,
    inset 0 0 0 7px #a5503f,
    4px 8px 0 #211a2e66;
  max-height: 97%;
  overflow: auto;
  text-align: center;
}
.folio {
  font-size: 13px;
  color: #924439;
  justify-content: center;
}
.paper h2 {
  font-size: 36px;
  line-height: 1.18;
  letter-spacing: -0.07em;
  margin: 14px 0;
}
.paper p#story {
  font-size: 15px;
  line-height: 1.55;
  word-break: keep-all;
}
.paper .paint {
  background: #a34237;
  color: #fff2ca;
  box-shadow: inset 0 -3px #82372e;
  width: 100%;
  min-height: 46px;
}
#home {
  color: #5f433c;
  background: transparent;
}
.paper #tally {
  display: flex;
  gap: 21px;
  justify-content: center;
  margin: 20px 0;
}
.paper #tally div {
  display: grid;
  gap: 4px;
  font-size: 12px;
}
.paper #tally strong {
  font:
    bold 25px/1 ui-monospace,
    Menlo,
    monospace;
}
@media (orientation: portrait) {
  .star {
    width: 78%;
    height: 54%;
    right: -4%;
    bottom: 43%;
  }
  .veil {
    background: linear-gradient(
      0deg,
      #261d30 2%,
      #30223bea 24%,
      #30223b8a 47%,
      transparent 72%
    );
  }
  .poster {
    left: max(8%, env(safe-area-inset-left));
    top: auto;
    bottom: max(6%, env(safe-area-inset-bottom));
    transform: none;
  }
  h1 {
    font-size: clamp(74px, min(19vw, 12.5vh), 136px);
  }
  .premise {
    margin: 12px 0 15px;
  }
  .nameplate {
    top: max(72px, calc(env(safe-area-inset-top) + 52px));
  }
  .score {
    right: 14px;
    bottom: 16px;
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  .poster {
    left: 6%;
  }
  .venue {
    font-size: 12px;
  }
  h1 {
    margin: 0.1em 0;
    font-size: clamp(39px, 14vh, 77px);
  }
  .premise {
    font-size: 13px;
    line-height: 1.35;
    margin: 9px 0;
  }
  .method {
    font-size: 11px;
    margin-top: 6px;
  }
  .paint {
    min-height: 42px;
    padding-block: 8px;
  }
  .star {
    height: 95%;
    bottom: 1%;
  }
  header {
    top: 7px;
  }
  .nameplate {
    top: 9px;
  }
  .paper {
    padding-block: 14px;
  }
  .paper h2 {
    margin: 7px 0;
  }
  .paper #tally {
    margin: 10px 0;
  }
  #tip {
    bottom: 5px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #lifeBar {
    transition: none;
  }
}
.pulses {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  height: 14px;
}
.pulses i {
  display: block;
  width: 6px;
  height: 6px;
  background: #766474;
  transform: rotate(45deg);
  box-shadow: 0 0 0 1px #3e3043;
}
.pulses .lit {
  background: #ffe3a2;
  box-shadow: 0 0 5px #e8ab67;
}
