* { box-sizing: border-box; }

:root {
  --ink: #3d302a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", "Gill Sans", "Gill Sans MT", "Segoe UI", system-ui, sans-serif;
  --edge: clamp(18px, 3.4vw, 46px);
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #f1cfb5;
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.vignette, .grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
.vignette {
  background: radial-gradient(125% 95% at 50% 46%, transparent 58%, rgba(34, 16, 30, .2) 100%);
}
.grain {
  opacity: .34;
  mix-blend-mode: overlay;
  background-size: 260px 260px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1.1 -.1'/%3E%3C/filter%3E%3Crect width='260' height='260' filter='url(%23n)'/%3E%3C/svg%3E");
}

.cap {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .24em;
  text-transform: uppercase;
}

/* ---------- in-game readout ---------- */

.hud {
  position: fixed;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(var(--edge) * .85) var(--edge);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .5s, transform .7s cubic-bezier(.2, .8, .2, 1);
}
body[data-state="playing"] .hud,
body[data-state="paused"] .hud,
body[data-state="dying"] .hud {
  opacity: 1;
  transform: none;
}

.score { display: flex; flex-direction: column; gap: 10px; }
.score .cap { opacity: .62; padding-left: 4px; }
#score {
  display: inline-block;
  align-self: flex-start;
  font-size: clamp(54px, 8.2vw, 108px);
  font-style: italic;
  line-height: .8;
  transform-origin: 10% 90%;
}
#score.bump { animation: bump .5s cubic-bezier(.2, 1.5, .3, 1); }
@keyframes bump {
  0% { transform: scale(1); }
  28% { transform: scale(1.24) rotate(-4deg); }
  100% { transform: scale(1); }
}

.day { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
#phase {
  font-size: clamp(22px, 2.7vw, 36px);
  font-style: italic;
  line-height: 1;
}
#phase.turn { animation: turn 1.6s cubic-bezier(.2, .8, .2, 1); }
@keyframes turn {
  0% { opacity: 0; transform: translateY(14px); letter-spacing: .12em; }
  100% { opacity: 1; transform: none; letter-spacing: 0; }
}
.pips { display: flex; gap: 7px; }
.pips i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  opacity: .4;
  transition: opacity .3s, transform .4s cubic-bezier(.2, 1.6, .3, 1), background-color .3s;
}
.pips i.on { background: var(--ink); opacity: 1; transform: scale(1.18); }

/* ---------- headline cards ---------- */

.card {
  position: fixed;
  left: 0;
  right: 0;
  top: clamp(26px, 7.5vh, 84px);
  padding: 0 20px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity .35s, transform .5s cubic-bezier(.2, .8, .2, 1);
}
body[data-state="title"] #title,
body[data-state="over"] #over,
body[data-state="paused"] #paused {
  opacity: 1;
  transform: none;
  transition-duration: .7s, .9s;
}

h1, h2 {
  margin: 0;
  font-weight: 400;
  font-style: italic;
  letter-spacing: -.03em;
  line-height: .95;
}
h1 { font-size: clamp(60px, 12vw, 164px); }
h2 { font-size: clamp(46px, 8.6vw, 116px); }

h1 span {
  display: inline-block;
  animation: rise 1s cubic-bezier(.2, .9, .2, 1) both;
  animation-delay: calc(var(--i) * 60ms + .35s);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(.32em) rotate(5deg); }
  to { opacity: 1; transform: none; }
}
h1 .o { width: .5em; margin: 0 .012em 0 .02em; animation-name: drop; animation-duration: 1.2s; }
h1 .o svg { display: block; width: 100%; transform: translateY(.045em); }
@keyframes drop {
  0% { opacity: 0; transform: translateY(-.9em) scale(.8); }
  55% { opacity: 1; transform: translateY(.04em) scale(1.08, .9); }
  75% { transform: translateY(-.05em) scale(.97, 1.04); }
  100% { opacity: 1; transform: none; }
}

.sub, .line { margin: clamp(12px, 2.2vh, 22px) 0 0; opacity: .72; }
.line span + span::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin: 0 1.3em .2em 1.1em;
  border-radius: 50%;
  background: currentColor;
  opacity: .6;
}
.line .new { opacity: 1; }

/* ---------- bottom furniture ---------- */

.prompt {
  position: fixed;
  left: 0;
  right: 0;
  bottom: clamp(44px, 8vh, 84px);
  margin: 0;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s;
}
body[data-state="title"] .prompt,
body[data-state="over"] .prompt,
body[data-state="paused"] .prompt { opacity: 1; transition-delay: .5s; }
.prompt span { display: inline-block; animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { opacity: .5; }
  50% { opacity: 1; }
}

.keys {
  position: fixed;
  left: calc(var(--edge) + 34px);
  bottom: clamp(60px, 11vh, 110px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s;
}
body[data-state="title"] .keys { opacity: 1; transition-delay: 1.2s; }
.keys .cap { opacity: .62; }
.plane {
  display: grid;
  grid-template: "x u y" 34px "l d r" 34px / 34px 34px 34px;
  gap: 5px;
}
kbd {
  display: grid;
  place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  font: 600 15px/1 var(--sans);
  opacity: .8;
}
kbd.u { grid-area: u; }
kbd.l { grid-area: l; }
kbd.d { grid-area: d; }
kbd.r { grid-area: r; }

.foot {
  position: fixed;
  inset: auto 0 0 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: calc(var(--edge) * .8) var(--edge);
  pointer-events: none;
}
.foot .cap { opacity: .62; }
.foot b { font-weight: 600; margin-left: .5em; }
.hints { margin-left: auto; display: flex; gap: 2.4em; }
.playhint { opacity: 0; transition: opacity .4s; }
body[data-state="playing"] .playhint, body[data-state="paused"] .playhint { opacity: 1; }
#mute {
  all: unset;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  pointer-events: auto;
  padding: 10px 0 10px 10px;
  margin: -10px 0;
}
#mute:hover, #mute:focus-visible { text-decoration: underline; text-underline-offset: 5px; }

@media (pointer: coarse), (max-width: 620px) {
  .keys, .playhint { display: none; }
}
@media (max-height: 520px) {
  .keys { display: none; }
}
