:root {
  color-scheme: light;
  --plaster: #8d8574;
  --plaster-light: #a39a87;
  --plaster-dark: #70695b;
  --ink: #27241f;
  --ink-soft: rgba(39, 36, 31, 0.72);
  --edge: rgba(48, 43, 35, 0.42);
  --chalk: #eee2bf;
  --oxide: #a74424;
  --blue: #243f80;
  --vermilion: #c53321;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 0;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--plaster);
}

body,
button {
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Roboto Mono", "Segoe UI Mono", monospace;
}

button,
canvas,
a {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.wall {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  min-height: 100%;
  overflow: hidden;
  isolation: isolate;
  background: var(--plaster);
}

#mural {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 44px;
  min-height: 44px;
  touch-action: none;
  cursor: crosshair;
  outline: 0;
}

#mural:focus-visible {
  box-shadow:
    inset 0 0 0 3px rgba(239, 224, 188, 0.92),
    inset 0 0 0 6px rgba(38, 35, 29, 0.76);
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 8px;
  left: 8px;
  min-height: 44px;
  padding: 13px 16px;
  transform: translateY(-140%);
  border: 2px solid var(--ink);
  background: #e6d9b8;
  color: var(--ink);
  font-size: 12px;
}

.skip-link:focus {
  transform: translateY(0);
}

.inscription,
.action-cue,
.keyboard-cue,
.stroke-clue p,
.ending p,
.ending span,
.static-inscription,
.static-copy p,
.static-copy h2 {
  margin: 0;
}

.inscription,
.action-cue,
.keyboard-cue {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  text-transform: uppercase;
  text-shadow: 0 1px rgba(225, 211, 177, 0.24);
}

.inscription {
  top: max(20px, env(safe-area-inset-top));
  left: max(22px, env(safe-area-inset-left));
  color: rgba(40, 36, 30, 0.82);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.inscription span,
.action-cue span,
.keyboard-cue span {
  color: var(--oxide);
}

.action-cue {
  top: max(20px, env(safe-area-inset-top));
  right: max(22px, env(safe-area-inset-right));
  width: min(48vw, 520px);
  color: rgba(42, 38, 31, 0.68);
  font-size: 9px;
  line-height: 1.45;
  letter-spacing: 0.12em;
  text-align: right;
}

.keyboard-cue {
  right: max(22px, env(safe-area-inset-right));
  bottom: max(80px, calc(env(safe-area-inset-bottom) + 80px));
  color: rgba(41, 37, 30, 0.56);
  font-size: 8px;
  line-height: 1.5;
  letter-spacing: 0.09em;
  text-align: right;
}

.stroke-clue {
  position: absolute;
  z-index: 4;
  left: var(--clue-x, 24px);
  top: var(--clue-y, 210px);
  width: min(260px, calc(100vw - 40px));
  min-height: 46px;
  padding: 7px 0 7px 22px;
  color: rgba(31, 28, 23, 0.86);
  pointer-events: none;
  transform: translateY(-50%);
}

.stroke-clue[data-side="left"] {
  transform: translate(-100%, -50%);
  padding: 7px 22px 7px 0;
  text-align: right;
}

.stroke-clue__pin {
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 1px;
  background: currentColor;
}

.stroke-clue[data-side="left"] .stroke-clue__pin {
  right: 0;
  left: auto;
}

.stroke-clue__pin::after {
  position: absolute;
  top: -3px;
  right: -1px;
  width: 7px;
  height: 7px;
  border: 1px solid currentColor;
  border-radius: 50%;
  content: "";
}

.stroke-clue[data-side="left"] .stroke-clue__pin::after {
  right: auto;
  left: -1px;
}

.stroke-clue__number {
  display: block;
  margin-bottom: 3px;
  color: rgba(36, 32, 27, 0.52);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.stroke-clue p {
  font-size: 10px;
  font-weight: 650;
  line-height: 1.5;
  letter-spacing: 0.035em;
}

.stroke-clue[data-feedback="shape"] p::before {
  content: "↤ ";
  color: #711f18;
  font-weight: 900;
}

.stroke-clue[data-feedback="tempo"] p::before {
  content: "≈ ";
  color: #5c381c;
  font-weight: 900;
}

.stroke-clue[data-feedback="accepted"] p::before {
  content: "✓ ";
  color: #283e28;
  font-weight: 900;
}

.wall-edge {
  position: absolute;
  z-index: 5;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  left: max(20px, env(safe-area-inset-left));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.awakening-key {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
}

.awakening-key span {
  display: block;
  width: 27px;
  height: 3px;
  border: 1px solid rgba(38, 34, 28, 0.36);
  background: transparent;
  transform: skewX(-18deg);
  transition: height 180ms ease, opacity 180ms ease;
}

.awakening-key span.is-awake {
  height: 7px;
  border-color: rgba(33, 29, 24, 0.54);
}

.awakening-key [data-pigment="oxide"].is-awake { background: var(--oxide); }
.awakening-key [data-pigment="ultramarine"].is-awake { background: var(--blue); }
.awakening-key [data-pigment="chalk"].is-awake { background: var(--chalk); }
.awakening-key [data-pigment="vermilion"].is-awake { background: var(--vermilion); }

.edge-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  pointer-events: auto;
}

.edge-action {
  min-width: 120px;
  min-height: 48px;
  padding: 11px 15px;
  border: 1px solid rgba(39, 35, 29, 0.72);
  border-radius: 0;
  background: rgba(142, 133, 114, 0.86);
  box-shadow: 3px 3px 0 rgba(45, 40, 33, 0.22);
  color: rgba(35, 31, 26, 0.94);
  font: inherit;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

.edge-action:hover:not(:disabled) {
  background: rgba(176, 163, 136, 0.94);
}

.edge-action:focus-visible {
  outline: 3px solid #f2dfad;
  outline-offset: 3px;
}

.edge-action:disabled {
  border-color: rgba(47, 42, 34, 0.25);
  box-shadow: none;
  color: rgba(42, 38, 31, 0.36);
  cursor: not-allowed;
}

.ending {
  position: absolute;
  z-index: 4;
  top: 44%;
  right: auto;
  left: clamp(110px, 25vw, 380px);
  width: min(300px, calc(100% - 52px));
  padding: 15px 0 13px 24px;
  border-left: 2px solid rgba(51, 44, 34, 0.68);
  color: rgba(32, 28, 23, 0.9);
  pointer-events: none;
}

.ending::before {
  position: absolute;
  top: 0;
  left: -2px;
  width: 2px;
  height: 42%;
  background: var(--vermilion);
  content: "";
}

.ending p {
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 2.6vw, 38px);
  line-height: 1.08;
  text-wrap: balance;
}

.ending span {
  display: block;
  margin-top: 9px;
  color: rgba(39, 34, 27, 0.52);
  font-size: 8px;
  letter-spacing: 0.22em;
}

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

.static-mural {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    repeating-linear-gradient(167deg, transparent 0 31px, rgba(56, 49, 39, 0.05) 32px, transparent 34px),
    radial-gradient(circle at 28% 19%, rgba(224, 209, 173, 0.26), transparent 46%),
    #8d8574;
}

.static-ground {
  position: absolute;
  inset: 0;
}

.fallback-mark {
  position: absolute;
  display: block;
  transform-origin: left center;
  box-shadow:
    -7px 9px 0 rgba(41, 34, 27, 0.32),
    3px -3px 0 rgba(235, 213, 171, 0.22);
}

.fallback-mark::after {
  position: absolute;
  inset: 12% 0;
  border-top: 2px solid rgba(246, 223, 180, 0.36);
  border-bottom: 4px solid rgba(39, 31, 25, 0.3);
  content: "";
}

.fallback-mark--oxide {
  top: 22%;
  left: -7%;
  width: 116%;
  height: 12%;
  background: #9e3f23;
  transform: rotate(3deg) skewX(-12deg);
}

.fallback-mark--blue {
  top: 78%;
  left: 3%;
  width: 78%;
  height: 8%;
  background: #233e7d;
  transform: rotate(-57deg) skewX(15deg);
}

.fallback-mark--graphite {
  top: 94%;
  left: 66%;
  width: 93%;
  height: 7%;
  background: #3e3c39;
  transform: rotate(-76deg);
}

.fallback-mark--chalk {
  top: 92%;
  left: 68%;
  width: 91%;
  height: 4%;
  background: repeating-linear-gradient(90deg, #dccfa7 0 14px, transparent 14px 19px);
  transform: rotate(-76deg);
}

.fallback-mark--vermilion {
  top: 73%;
  left: 101%;
  width: 112%;
  height: 7%;
  background: #bd3221;
  transform: rotate(173deg) skewX(-17deg);
}

.static-inscription {
  position: absolute;
  top: 22px;
  left: 24px;
  color: rgba(35, 31, 25, 0.8);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.static-copy {
  position: absolute;
  right: 28px;
  bottom: 26px;
  width: min(410px, calc(100% - 56px));
  padding-left: 18px;
  border-left: 2px solid #a74424;
  color: #29251f;
}

.static-copy h2 {
  margin-bottom: 7px;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 23px;
  font-weight: 500;
}

.static-copy p {
  font-size: 10px;
  line-height: 1.55;
}

.js .static-mural,
.no-js .interactive-only {
  display: none !important;
}

@media (max-width: 620px) {
  .inscription {
    top: max(16px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left));
    font-size: 9px;
  }

  .action-cue {
    top: max(43px, calc(env(safe-area-inset-top) + 43px));
    right: auto;
    left: max(16px, env(safe-area-inset-left));
    width: calc(100% - 32px);
    font-size: 8px;
    text-align: left;
  }

  .keyboard-cue {
    display: none;
  }

  .stroke-clue {
    width: min(210px, calc(100vw - 28px));
  }

  .stroke-clue p {
    font-size: 9px;
  }

  .wall-edge {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(14px, env(safe-area-inset-left));
    align-items: flex-end;
  }

  .awakening-key {
    max-width: 114px;
    flex-wrap: wrap;
    align-content: flex-end;
    gap: 5px;
  }

  .awakening-key span {
    width: 22px;
  }

  .edge-action {
    min-width: 132px;
    min-height: 48px;
  }

  .ending {
    top: 44%;
    right: auto;
    bottom: auto;
    left: 16px;
    width: 134px;
    padding: 12px 0 10px 17px;
  }

  .ending p {
    font-size: 26px;
    line-height: 1.06;
  }

  .static-copy {
    right: 18px;
    bottom: 22px;
    width: calc(100% - 36px);
  }

  .fallback-mark--oxide { top: 25%; width: 142%; height: 10%; }
  .fallback-mark--blue { top: 78%; left: -14%; width: 120%; }
  .fallback-mark--graphite { left: 50%; width: 130%; }
  .fallback-mark--chalk { left: 53%; width: 126%; }
  .fallback-mark--vermilion { top: 72%; width: 145%; }
}

@media (prefers-reduced-motion: reduce) {
  .awakening-key span {
    transition: none;
  }
}
