:root {
  --bone: #e4ddcc;
  --bone-2: rgba(228, 221, 204, 0.62);
  --bone-3: rgba(228, 221, 204, 0.34);
  --ink: #16130f;
  --rust: #5e170f;
  --ember: #c9a46c;
  --f-title: 'Ruslan Display', 'Cormorant Garamond', serif;
  --f-dirt: 'Rubik Dirt', 'Old Standard TT', serif;
  --f-ui: 'Cormorant Garamond', 'Old Standard TT', serif;
  --f-text: 'Old Standard TT', 'Cormorant Garamond', serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  overflow: hidden;
  cursor: default;
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(100vw, 177.78vh);
  height: min(100vh, 56.25vw);
  container-type: size;
  overflow: hidden;
  background: #000;
  user-select: none;
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#stage.playing { cursor: none; }
#stage.playing .screen { cursor: default; }

#layer { position: absolute; inset: 0; pointer-events: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* ---------------------------------------------------------- екрани */

.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.9s ease;
  pointer-events: auto;
}
.screen.in { opacity: 1; }
.screen.out { opacity: 0; transition-duration: 0.6s; }

.w-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 7cqh;
  margin: 0;
  text-align: center;
  font: 300 0.74cqw/1 var(--f-mono);
  letter-spacing: 0.32em;
  text-transform: lowercase;
  color: var(--bone-3);
  animation: breathe 3.2s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.loading { display: grid; place-items: center; pointer-events: none; }
.loading .bar { width: 14cqw; height: 1px; background: rgba(228, 221, 204, 0.12); }
.loading i { display: block; height: 100%; width: 0; background: var(--bone-2); transition: width 0.3s; }

.warning { display: grid; place-items: center; }
.warning .w-text { text-align: center; font: 400 1.55cqw/1.7 var(--f-text); color: var(--bone-2); }
.warning p { margin: 0; }
.warning .gap { height: 1.6cqw; }
.warning p:last-child { color: var(--bone); font-style: italic; }

/* ---------------------------------------------------------- меню */

.title .logo {
  position: absolute;
  left: 0;
  right: 0;
  top: 22cqh;
  margin: 0;
  text-align: center;
  font: 400 17.5cqw/1 var(--f-title);
  letter-spacing: 0.04em;
  color: var(--bone);
  text-shadow: 0 0 2.4cqw rgba(0, 0, 0, 0.95), 0 0 0.5cqw rgba(94, 23, 15, 0.45);
  filter: url(#wobble);
}
.title .logo span { display: inline-block; transition: transform 0.05s; }

.title .tagline {
  position: absolute;
  left: 0;
  right: 0;
  top: 55cqh;
  margin: 0;
  text-align: center;
  font: italic 300 1.7cqw/1 var(--f-ui);
  letter-spacing: 0.14em;
  color: var(--bone-2);
}

.menu {
  position: absolute;
  left: 7cqw;
  bottom: 11cqh;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.5cqh;
}
.menu.center {
  position: static;
  align-items: center;
  flex-direction: row;
  justify-content: center;
  gap: 4cqw;
  margin-top: 6cqh;
}
.menu button {
  position: relative;
  font: 500 1.08cqw/1.4 var(--f-ui);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--bone-3);
  transition: color 0.35s, letter-spacing 0.6s;
  outline: none;
}
.menu button em {
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: none;
  margin-left: 0.8em;
  opacity: 0.7;
}
.menu button::before {
  content: '';
  position: absolute;
  right: calc(100% + 1.2cqw);
  top: 50%;
  width: 0;
  height: 1px;
  background: var(--bone);
  transition: width 0.45s ease;
}
.menu button:hover,
.menu button:focus-visible { color: var(--bone); letter-spacing: 0.48em; }
.menu button:hover::before,
.menu button:focus-visible::before { width: 2.6cqw; }
.menu.center button::before { display: none; }

.headphones {
  position: absolute;
  right: 4cqw;
  bottom: 5cqh;
  margin: 0;
  font: 300 0.72cqw/1 var(--f-mono);
  letter-spacing: 0.3em;
  color: var(--bone-3);
}

.title.final .tagline { letter-spacing: 0.5em; text-transform: uppercase; font-size: 1.2cqw; }

.credits {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--bone-2);
}
.credits h2 { margin: 0 0 5cqh; font: 400 5cqw/1 var(--f-title); color: var(--bone); }
.credits .cr-author { margin: 0; font: 400 2.4cqw/1 var(--f-dirt); letter-spacing: 0.06em; color: var(--bone); }
.credits .cr-license {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 13cqh;
  margin: 0;
  font: 300 0.62cqw/1.4 var(--f-mono);
  letter-spacing: 0.08em;
  color: var(--bone-3);
}

/* ---------------------------------------------------------- як грати */

.howto { display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--bone); }
.howto h2 { margin: 0 0 5.5cqh; font: 400 3.4cqw/1 var(--f-title); letter-spacing: 0.04em; }
.ht-grid { display: flex; align-items: flex-start; gap: 5.5cqw; }
.ht-left { display: flex; flex-direction: column; align-items: center; gap: 5cqh; width: 26cqw; }
.ht-plan { position: relative; width: 15cqw; height: 15cqw; margin-top: 2cqh; border: 1px solid rgba(228, 221, 204, 0.22); }
.ht-plan span { position: absolute; transform: translate(-50%, -50%); text-align: center; white-space: nowrap; font: 400 1.15cqw/1 var(--f-dirt); }
.ht-plan b { display: block; margin-top: 0.6cqh; font: 400 1.4cqw/1 var(--f-dirt); color: #b0503f; }
.ht-plan .ht-me { left: 50%; top: 50%; font-size: 1cqw; color: var(--bone-2); }
.ht-plan .up { left: 50%; top: 0; }
.ht-plan .down { left: 50%; top: 100%; }
.ht-plan .left { left: 0; top: 50%; }
.ht-plan .right { left: 100%; top: 50%; }
.ht-keys { display: grid; grid-template-columns: auto 1fr; gap: 1.1cqh 1.2cqw; margin: 0; }
.ht-keys dt { font: 300 0.7cqw/1.5 var(--f-mono); letter-spacing: 0.2em; color: var(--bone); text-align: right; white-space: nowrap; }
.ht-keys dd { margin: 0; font: 400 0.95cqw/1.45 var(--f-text); color: var(--bone-2); }
.ht-rules { list-style: none; margin: 0; padding: 0; width: 40cqw; }
.ht-rules li { margin: 0 0 3cqh; }
.ht-rules b { font: 400 1.6cqw/1 var(--f-title); margin-right: 1cqw; }
.ht-rules i { font: 300 0.7cqw/1 var(--f-mono); font-style: normal; letter-spacing: 0.3em; color: var(--bone-3); }
.ht-rules span { display: block; margin-top: 0.9cqh; font: 400 1.02cqw/1.5 var(--f-text); color: var(--bone-2); }
.ht-rules u { display: block; text-decoration: none; font-style: italic; color: var(--ember); }
.ht-rules em { font-style: normal; color: #d26a55; }
.ht-foot { max-width: 60cqw; margin: 3cqh 0 0; text-align: center; font: 300 0.78cqw/1.6 var(--f-mono); letter-spacing: 0.06em; color: var(--bone-2); }

/* ---------------------------------------------------------- оповідь */

.prose { display: grid; place-items: center; }
.prose .col {
  width: 56cqw;
  font: 400 1.95cqw/1.65 var(--f-text);
  color: var(--bone);
  transition: opacity 1.4s ease;
}
.prose .col.center { text-align: center; }
.prose.over .col { text-shadow: 0 0 1cqw #000, 0 0 0.3cqw #000; }
.prose .col.dim { opacity: 0.12; }
.prose .col p { margin: 0 0 1.2cqh; min-height: 1.65em; }
.prose .fade { opacity: 0; transform: translateY(0.4cqh); transition: opacity 1.4s ease, transform 1.8s ease; }
.prose .fade.in { opacity: 1; transform: none; }

.prose .verdict {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  font: 400 9.5cqw/1 var(--f-dirt);
  letter-spacing: 0.06em;
  color: var(--bone);
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.25s, transform 4s ease-out;
}
.prose .verdict.in { opacity: 1; transform: scale(1); }

.skip {
  position: absolute;
  right: 4cqw;
  bottom: 5cqh;
  font: 300 0.72cqw/1 var(--f-mono);
  letter-spacing: 0.3em;
  color: var(--bone-3);
}
.skip:hover { color: var(--bone); }

.morning .clock {
  position: absolute;
  top: 18cqh;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font: 300 1cqw/1 var(--f-mono);
  letter-spacing: 0.5em;
  color: var(--bone-3);
}
.morning .col { font-style: italic; text-align: center; }

/* ---------------------------------------------------------- ніч: заставка і стіна */

.ordinal { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ordinal p { margin: 0; color: var(--bone); }
.ordinal .n-small { font: 300 0.9cqw/1 var(--f-mono); letter-spacing: 0.8em; color: var(--bone-3); margin-bottom: 2.4cqh; }
.ordinal .n-big { font: 400 8cqw/1 var(--f-title); letter-spacing: 0.06em; }

.wallcard { color: var(--ink); }
.wallcard .rule {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%) rotate(-2.2deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  font: 400 4.6cqw/1.12 var(--f-dirt);
  letter-spacing: 0.02em;
  white-space: nowrap;
  filter: url(#charcoal);
  mix-blend-mode: multiply;
}
.wallcard .rule.other { transform: translate(-50%, -50%) rotate(3deg) skewX(-6deg); font-size: 5.6cqw; color: #2a0d08; }
.wallcard .line {
  display: block;
  opacity: 0.9;
  clip-path: inset(-20% 100% -20% 0);
  transition: clip-path 1.2s cubic-bezier(0.55, 0.1, 0.4, 0.95);
}
.wallcard .line.write { clip-path: inset(-20% 0 -20% 0); }
.wallcard .old {
  position: absolute;
  margin: 0;
  font: 400 1.9cqw/1.15 var(--f-dirt);
  opacity: 0.72;
  white-space: nowrap;
  filter: url(#charcoal);
  mix-blend-mode: multiply;
}
.wallcard .memory {
  position: absolute;
  left: 50%;
  top: 70%;
  margin: 0;
  transform: translateX(-38%) rotate(4deg);
  font: 400 2.4cqw/1 var(--f-dirt);
  color: var(--rust);
  white-space: nowrap;
  filter: url(#charcoal);
  mix-blend-mode: multiply;
  clip-path: inset(-20% 100% -20% 0);
  transition: clip-path 1s ease;
}
.wallcard .memory.write { clip-path: inset(-20% 0 -20% 0); }
/* підказка внизу на темній смузі, щоб її було видно на будь-якій стіні */
.wallcard .wall-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 7cqh 0 5cqh;
  text-align: center;
  font: 400 0.9cqw/1 var(--f-mono);
  letter-spacing: 0.35em;
  color: var(--bone);
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.78));
  opacity: 0;
  transition: opacity 1s;
}
.wallcard .wall-hint.in { opacity: 1; }

.wallcard .plan {
  position: absolute;
  right: 7cqw;
  bottom: 12cqh;
  width: 22cqw;
  height: 22cqw;
  opacity: 0;
  transition: opacity 1s;
  mix-blend-mode: multiply;
  filter: url(#charcoal);
}
.wallcard .plan.in { opacity: 1; }
.wallcard .plan svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.wallcard .plan path { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
.wallcard .plan .walls { stroke-width: 2.8; }
.wallcard .plan .arrow { stroke-dasharray: 3 2.4; }
.wallcard .plan .fresh { opacity: 0; transition: opacity 0.9s; }
.wallcard .plan .fresh.write { opacity: 1; }
.wallcard .plan .fresh.write.place { color: var(--rust); }
.wallcard .plan span {
  position: absolute;
  transform: translate(-50%, -50%);
  font: 400 1.5cqw/1 var(--f-dirt);
  color: var(--ink);
  white-space: nowrap;
  text-align: center;
}
.wallcard .plan .me { left: 50%; top: 50%; font-size: 1.3cqw; }
.wallcard .plan .place b {
  display: block;
  margin-top: 0.6cqh;
  font: 400 1.6cqw/1 var(--f-dirt);
}

/* ---------------------------------------------------------- HUD */

#hud { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 1.2s; }
#hud.in { opacity: 1; }

#hud-battery {
  position: absolute;
  left: 3.4cqw;
  bottom: 4.6cqh;
  display: flex;
  align-items: center;
  gap: 0.9cqw;
  font: 300 0.68cqw/1 var(--f-mono);
  letter-spacing: 0.3em;
  color: var(--bone-3);
}
#hud-battery b { display: block; width: 8cqw; height: 2px; background: rgba(228, 221, 204, 0.12); }
#hud-battery i { display: block; height: 100%; background: var(--bone-2); transition: width 0.2s linear; }
#hud-battery.low i { background: #8a2a1d; animation: breathe 0.9s infinite; }

#hud-clock {
  position: absolute;
  right: 3.4cqw;
  bottom: 4.2cqh;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.7cqh;
}
#hud-time { font: 300 1.3cqw/1 var(--f-mono); letter-spacing: 0.12em; color: var(--bone-2); }
#hud-night { font: 300 0.62cqw/1 var(--f-mono); letter-spacing: 0.35em; color: var(--bone-3); }

/* підказка першого разу */
#tip {
  position: absolute;
  left: 50%;
  top: 7cqh;
  width: 46cqw;
  margin: 0;
  transform: translateX(-50%);
  padding: 1.4cqh 2cqw;
  text-align: center;
  font: 400 1.15cqw/1.45 var(--f-text);
  color: var(--bone);
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.72) 18%, rgba(0, 0, 0, 0.72) 82%, transparent);
  border-top: 1px solid rgba(228, 221, 204, 0.18);
  border-bottom: 1px solid rgba(228, 221, 204, 0.18);
  opacity: 0;
  transition: opacity 0.7s;
}
#tip.in { opacity: 1; }

/* ---------------------------------------------------------- пауза, смерть, спалах тексту */

.pause {
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition-duration: 0.3s;
}
.pause .p-title { margin: 0 0 5cqh; font: 400 5cqw/1 var(--f-title); color: var(--bone); }
.pause .vol {
  display: flex;
  align-items: center;
  gap: 1.4cqw;
  font: 300 0.74cqw/1 var(--f-mono);
  letter-spacing: 0.3em;
  color: var(--bone-3);
}
.pause input[type='range'] { width: 12cqw; accent-color: var(--bone); }
.pause .p-keys {
  margin: 3.4cqh 0 0;
  font: 300 0.7cqw/1.6 var(--f-mono);
  letter-spacing: 0.14em;
  color: var(--bone-3);
}
.pause .menu.center { margin-top: 5cqh; }

.death {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.death .d-time { margin: 0 0 4cqh; font: 300 0.9cqw/1 var(--f-mono); letter-spacing: 0.4em; color: var(--bone-3); }
.death .d-hint { margin: 0; font: 400 4cqw/1.1 var(--f-dirt); color: var(--bone); text-align: center; transform: rotate(-1.5deg); }

.flashtext { display: grid; place-items: center; pointer-events: none; }
.flashtext p { margin: 0; font: 400 4.6cqw/1 var(--f-title); letter-spacing: 0.08em; color: #f2ede2; text-shadow: 0 0 2cqw rgba(0, 0, 0, 0.4); }
