.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  width: 100%;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  overflow: hidden;
  background: var(--paper-deep);
}

.topbar {
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 6px max(var(--edge), env(safe-area-inset-right)) 5px max(var(--edge), env(safe-area-inset-left));
}

.brand {
  min-width: 0;
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-weight: 900;
  font-size: clamp(.9rem, 2vw, 1.08rem);
  transform: rotate(-1deg);
}

.status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font: 800 clamp(.62rem, 1.5vw, .74rem) "Courier New", monospace;
  white-space: nowrap;
}

.chaos-meter {
  width: clamp(52px, 8vw, 96px);
  height: 11px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 52% 45% 48% 54%;
  transform: rotate(.7deg);
}

.chaos-meter i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--red);
  transition: width .25s ease;
}

.viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
}

.scene-track {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform .45s cubic-bezier(.2, .8, .2, 1);
  will-change: transform;
}

.scene {
  position: relative;
  flex: 0 0 100%;
  min-width: 0;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  background:
    radial-gradient(circle at 12% 8%, rgba(255,255,255,.9), transparent 25%),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(80,70,60,.035) 31px 32px),
    var(--paper);
}

.scene--night {
  color: #fbf5eb;
  background:
    radial-gradient(circle at 18% 10%, rgba(255,255,255,.06), transparent 25%),
    linear-gradient(180deg, var(--night-light), var(--night));
}

.scene__content {
  position: relative;
  z-index: 2;
  width: min(1180px, 100%);
  min-height: 100%;
  margin-inline: auto;
  padding: clamp(22px, 4vh, 52px) var(--edge) clamp(30px, 6vh, 70px);
}

.intro-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, .75fr);
  align-items: center;
  gap: clamp(32px, 7vw, 100px);
}

.intro-copy { max-width: 680px; }

.intro-copy h1 span { color: var(--red); }

.intro-text {
  max-width: 590px;
  font-size: clamp(1rem, 1.8vw, 1.16rem);
}

.intro-text p { margin-bottom: .7em; }

.intro-doodle {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  min-width: 0;
  transform: rotate(2.5deg);
}

.intro-doodle__face {
  display: grid;
  place-items: center;
  width: min(24vw, 280px);
  min-width: 190px;
  aspect-ratio: 1;
  border: 4px solid var(--ink);
  border-radius: 46% 54% 50% 49% / 53% 45% 55% 47%;
  background: rgba(255,255,255,.75);
  box-shadow: 8px 9px 0 rgba(48,43,40,.18);
  font-size: clamp(6rem, 12vw, 10rem);
}

.intro-doodle p {
  max-width: 21ch;
  margin: 14px 0 0;
  color: var(--blue);
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-weight: 900;
  text-align: center;
}

.sheet-layout {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(20px, 4vh, 42px);
}

.sheet-heading {
  max-width: 680px;
  padding-right: 20px;
}

.sheet-heading p:last-child {
  max-width: 54ch;
  margin-bottom: 0;
  color: var(--muted);
}

.scene--night .sheet-heading p:last-child { color: rgba(255,255,255,.68); }

.tool-grid {
  display: grid;
  align-items: center;
  gap: clamp(14px, 2.5vw, 28px);
  width: min(1020px, 100%);
  margin: auto;
}

.tool-grid--day { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tool-grid--night { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.cat-board {
  display: grid;
  grid-template-columns: minmax(150px, .8fr) minmax(270px, 1.45fr) minmax(150px, .8fr);
  align-items: center;
  gap: clamp(16px, 4vw, 54px);
  width: min(1020px, 100%);
  margin: auto;
}

.cat-board__actions {
  display: grid;
  gap: clamp(18px, 3vh, 32px);
}

.cat-board__actions--left { transform: translateY(12px); }
.cat-board__actions--right { transform: translateY(-4px); }

.cat-focus {
  position: relative;
  display: grid;
  place-items: center;
  align-self: stretch;
  min-height: 330px;
  padding: 40px 12px 22px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.cat-focus__cat {
  z-index: 2;
  font-size: clamp(7rem, 14vw, 11rem);
  filter: drop-shadow(4px 5px 0 rgba(48,43,40,.14));
  transition: transform .18s ease;
}

.cat-focus:hover .cat-focus__cat { transform: translateY(-5px) rotate(-2deg); }

.cat-focus__cushion {
  position: absolute;
  z-index: 1;
  left: 14%;
  right: 14%;
  bottom: 62px;
  height: 58px;
  border: 3px solid currentColor;
  border-radius: 50%;
  background: #d8b9a0;
}

.cat-focus__bubble {
  position: absolute;
  z-index: 4;
  top: 2px;
  left: 50%;
  min-width: 170px;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 9% 12% 8% 14%;
  background: white;
  box-shadow: 3px 3px 0 var(--ink);
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-size: .78rem;
  transform: translateX(-50%) rotate(-1deg);
}

.cat-focus > b {
  z-index: 3;
  align-self: end;
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-size: 1.15rem;
}

.scene-nav {
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 50px;
  padding: 3px max(var(--edge), env(safe-area-inset-right)) 7px max(var(--edge), env(safe-area-inset-left));
}

.scene-nav > button {
  border: 0;
  background: transparent;
  font: 900 1.65rem "Segoe Print", "Comic Sans MS", cursive;
  cursor: pointer;
}

.scene-nav > button:disabled { opacity: .22; cursor: default; }

.scene-dots { display: flex; gap: 9px; }

.scene-dot {
  width: 14px;
  min-width: 14px;
  height: 14px;
  min-height: 14px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transform: rotate(var(--dot-rotate, 0deg));
}

.scene-dot.is-active { background: var(--red); }
