:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --visual-height: 100dvh;
  --visual-top: 0px;
}
.touch-nav {
  display: none;
}
.room-index nav {
  max-height: calc(var(--visual-height) - 105px - var(--safe-top));
  overflow-y: auto;
  overscroll-behavior: contain;
  max-width: calc(100vw - 32px - var(--safe-left) - var(--safe-right));
}
.room-index nav button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  text-align: left;
  padding: 12px 13px;
  min-height: 44px;
  cursor: pointer;
}
.room-index nav button:hover {
  background: #314134;
  color: #f4ecd2;
}
button,
a,
input,
summary {
  touch-action: manipulation;
}
#close-payment {
  min-width: 44px;
  min-height: 44px;
}
.page-content {
  overflow-wrap: break-word;
  -webkit-overflow-scrolling: touch;
}
.page-content .credits > div {
  min-width: 0;
}
.page-content .donation-form {
  min-width: 0;
}
.page-content input {
  scroll-margin: 32px;
}
dialog {
  max-height: calc(
    var(--visual-height) - 24px - var(--safe-top) - var(--safe-bottom)
  );
  overscroll-behavior: contain;
}

@media (max-width: 1050px), (max-height: 600px) {
  .room-header {
    height: calc(64px + var(--safe-top));
    top: var(--visual-top);
    padding: var(--safe-top) max(16px, var(--safe-right)) 0
      max(16px, var(--safe-left));
    gap: 12px;
  }
  .room-brand {
    font-size: 9px;
    gap: 10px;
    min-height: 44px;
    letter-spacing: 0.05em;
  }
  .room-brand-mark {
    font-size: 25px;
    padding-right: 10px;
  }
  .room-brand-sub {
    display: none;
  }
  .room-location,
  .room-number {
    display: none;
  }
  .room-index summary {
    font-size: 11px;
    gap: 12px;
    min-height: 44px;
    padding: 10px 0 10px 12px;
  }
  .room-index nav {
    top: 100%;
    font-size: 13px;
    min-width: min(270px, calc(100vw - 32px));
    max-height: calc(
      var(--visual-height) - 84px - var(--safe-top) - var(--safe-bottom)
    );
    padding: 8px;
  }
  .room-index nav a,
  .room-index nav button {
    font-size: 13px;
    min-height: 44px;
    padding: 12px;
  }
  .room-title {
    top: calc(89px + var(--safe-top));
    left: max(16px, var(--safe-left));
    right: max(16px, var(--safe-right));
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
  }
  .room-title .eyebrow {
    position: absolute;
    top: -17px;
    font-size: 7px;
    letter-spacing: 0.1em;
    margin: 0;
  }
  .room-title h1 {
    font-size: 26px;
    line-height: 1;
    max-width: 240px;
    margin: 0;
  }
  .room-title h1 br {
    display: none;
  }
  .room-title > p:last-child {
    font-size: 13px;
    max-width: 100px;
    text-align: right;
    margin: 0;
    line-height: 1.4;
  }
  .touch-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    position: fixed;
    z-index: 5;
    bottom: calc(37px + var(--safe-bottom));
    left: max(12px, var(--safe-left));
    right: max(12px, var(--safe-right));
    gap: 4px;
    padding: 5px;
    border: 1px solid #7e9270;
    border-radius: 5px;
    background: linear-gradient(120deg, #72856c, #3b513d);
    box-shadow:
      0 5px 0 #1d301f,
      0 12px 25px #0006;
    pointer-events: auto;
  }
  .touch-nav button {
    min-width: 0;
    min-height: 48px;
    border: 1px solid #849477;
    border-radius: 2px;
    background: linear-gradient(#263e2a, #1c2e20);
    box-shadow: 0 2px 0 #142718;
    color: #e4e8cf;
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: 0.015em;
    padding: 7px 2px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
  }
  .touch-nav button small {
    font-size: 8px;
    color: #9dbb92;
    letter-spacing: 0.08em;
  }
  .touch-nav button:active {
    transform: translateY(2px);
    box-shadow: none;
    background: #3b5639;
  }
  .touch-nav button:last-child {
    background: linear-gradient(#a3412e, #8f3425);
    border-color: #bd6b4b;
    color: #fff1d4;
  }
  .touch-nav button:last-child small {
    color: #e5bc8c;
  }
  .room-instruction {
    bottom: calc(111px + var(--safe-bottom));
    font-size: 8px;
    gap: 8px;
    max-width: calc(100% - 24px);
    white-space: normal;
    width: max-content;
  }
  .room-instruction b {
    font-size: 8px;
    letter-spacing: 0.05em;
  }
  .instruction-line {
    width: 12px;
    flex-shrink: 0;
  }
  .room-bottom {
    left: max(16px, var(--safe-left));
    right: max(16px, var(--safe-right));
    bottom: calc(9px + var(--safe-bottom));
    gap: 10px;
    font-size: 8px;
    flex-wrap: nowrap;
  }
  .room-bottom > span:nth-child(2) {
    font-size: 7px;
    text-align: right;
  }
  .room-bottom > button {
    display: none;
  }
  .room-tooltip {
    display: none;
  }
  .page-open .touch-nav,
  .page-open .room-bottom {
    display: none;
  }
  .page-open .room-hotspot {
    pointer-events: none;
  }
  .page-shell {
    top: calc(var(--visual-top) + 66px + var(--safe-top));
    bottom: auto;
    height: calc(
      var(--visual-height) - 78px - var(--safe-top) - var(--safe-bottom)
    );
    left: max(12px, var(--safe-left));
    right: max(12px, var(--safe-right));
    width: auto;
    max-width: none;
    background: #152219fc;
    border-radius: 3px;
  }
  .page-top {
    padding: 10px 15px;
    gap: 10px;
    min-height: 66px;
  }
  .page-top .mono {
    font-size: 8px;
    letter-spacing: 0.04em;
    line-height: 1.6;
  }
  .page-top p {
    font-size: 11px;
    letter-spacing: 0.04em;
    margin-top: 4px;
  }
  .page-top > button {
    min-width: 44px;
    min-height: 44px;
    font-size: 0;
    padding: 0;
    gap: 0;
    flex-shrink: 0;
  }
  .page-top > button > span {
    width: 44px;
    height: 44px;
    font-size: 28px;
  }
  .page-content .section {
    padding: 24px 18px 32px;
    min-width: 0;
  }
  .page-content .section-label {
    font-size: 9px;
    letter-spacing: 0.04em;
    line-height: 1.65;
    gap: 18px;
    margin-bottom: 24px;
    flex-wrap: wrap;
  }
  .page-content h2,
  .page-content .story-heading h2,
  .page-content .production-intro h2,
  .page-content .support-layout h2,
  .page-content .faq-layout h2 {
    font-size: clamp(38px, 7vw, 57px);
  }
  .page-content .story-heading {
    display: block;
  }
  .page-content .story-heading .eyebrow,
  .page-content .support-layout .eyebrow {
    font-size: 10px;
    letter-spacing: 0.06em;
    line-height: 1.7;
  }
  .page-content .story-credit {
    font-size: 11px;
    text-align: left;
    margin-top: 20px;
    line-height: 1.7;
  }
  .page-content .story-credit br {
    display: none;
  }
  .page-content .story-paper,
  .page-content .credits-paper {
    padding: 22px 19px;
    transform: none;
    margin: 0;
    min-width: 0;
  }
  .page-content .story-paper h3 {
    font-size: 32px;
  }
  .page-content .paper-top {
    font-size: 9px;
    line-height: 1.7;
    letter-spacing: 0.02em;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 23px;
  }
  .page-content .type-line {
    font-size: 10px;
    gap: 15px;
    flex-wrap: wrap;
    line-height: 1.7;
  }
  .page-content .paper-bottom {
    font-size: 10px;
    gap: 12px;
    flex-wrap: wrap;
  }
  .page-content .stamp {
    font-size: 10px;
    transform: none;
  }
  .page-content .story-paper p,
  .page-content .production-intro p,
  .page-content .people-intro p,
  .page-content .support-layout > div > p,
  .page-content .statement-excerpt,
  .page-content .director-statement div,
  .page-content .faqs p {
    font-size: 16px;
    line-height: 1.8;
  }
  .page-content .story-paper p:first-of-type {
    font-size: 17px;
    line-height: 1.8;
  }
  .page-content .statement-layout h2 {
    font-size: 32px;
    line-height: 1.25;
  }
  .page-content .director-statement summary {
    font-size: 12px;
    line-height: 1.8;
    min-height: 44px;
    align-items: center;
    padding: 8px 0;
    gap: 15px;
  }
  .page-content .director-signature {
    font-size: 11px;
  }
  .page-content .director-signature span {
    font-size: 10px;
  }
  .page-content .budget-panel {
    padding: 25px 18px 20px;
  }
  .page-content .budget-display .mono {
    font-size: 10px;
    line-height: 1.7;
  }
  .page-content .budget-display strong {
    font-size: 42px;
  }
  .page-content .budget-display .budget-target strong {
    font-size: 62px;
  }
  .page-content .budget-key {
    font-size: 10px;
    line-height: 1.8;
    gap: 9px;
  }
  .page-content .budget-note {
    font-size: 12px;
    line-height: 1.8;
  }
  .page-content .support-allocation {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  .page-content .support-allocation > p {
    font-size: 11px;
    line-height: 1.8;
  }
  .page-content .support-allocation ul {
    font-size: 14px;
    line-height: 1.8;
  }
  .page-content .support-allocation li span {
    font-size: 10px;
  }
  .page-content .daily-cost {
    justify-self: start;
    padding-left: 18px;
    margin-top: 5px;
  }
  .page-content .daily-cost span {
    font-size: 10px;
    line-height: 1.8;
  }
  .page-content .people-intro h2 {
    font-size: 60px;
  }
  .page-content .credits-layout h3 {
    font-size: 27px;
  }
  .page-content .credits dt {
    font-size: 14px;
    line-height: 1.6;
  }
  .page-content .credits dd {
    font-size: 12px;
    line-height: 1.7;
  }
  .page-content .credits.crew {
    column-gap: 20px;
  }
  .page-content .benefits .mono {
    font-size: 11px;
  }
  .page-content .benefits h3 {
    font-size: 17px;
    line-height: 1.5;
  }
  .page-content .benefits p {
    font-size: 15px;
    line-height: 1.8;
  }
  .page-content .donation-form {
    padding: 23px 18px;
    transform: none;
    max-width: 500px;
  }
  .page-content .donation-label {
    font-size: 29px;
  }
  .page-content .donation-form > p {
    font-size: 14px;
    line-height: 1.7;
  }
  .page-content .amount-presets {
    gap: 5px;
  }
  .page-content .amount-presets button {
    font-size: 12px;
    min-height: 44px;
    padding: 10px 1px;
  }
  .page-content .custom-label {
    font-size: 11px;
    letter-spacing: 0.015em;
    line-height: 1.8;
  }
  .page-content .amount-input input {
    font-size: 48px;
    min-height: 60px;
    border-radius: 0;
  }
  .page-content .donation-form > .amount-help {
    font-size: 12px;
    line-height: 1.7;
  }
  .page-content .dark-button {
    font-size: 11px;
    min-height: 60px;
    letter-spacing: 0;
  }
  .page-content .donation-form > .payment-caption {
    font-size: 10px;
  }
  .page-content .donation-form > .availability,
  .page-content .donation-form > .small-print {
    font-size: 12px;
    line-height: 1.8;
  }
  .page-content .small-print a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
  .page-content .faqs summary {
    font-size: 16px;
    line-height: 1.65;
    min-height: 56px;
    padding: 16px 0;
    gap: 14px;
  }
  .page-content .faqs p {
    padding-right: 0;
  }
  .page-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 6px 12px;
    gap: 0 8px;
    font-size: 10px;
    letter-spacing: 0;
    line-height: 1.4;
  }
  .page-bottom a,
  .page-bottom button {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 8px 4px;
    white-space: normal;
  }
  .page-bottom #share-status {
    font-size: 12px;
    line-height: 1.7;
    overflow-wrap: anywhere;
  }
  dialog[open] {
    position: fixed;
    left: 0;
    right: 0;
    top: calc(var(--visual-top) + var(--visual-height) / 2);
    bottom: auto;
    margin: 0 auto;
    transform: translateY(-50%);
    width: calc(100% - 24px - var(--safe-left) - var(--safe-right));
    max-height: calc(
      var(--visual-height) - 24px - var(--safe-top) - var(--safe-bottom)
    );
    overflow: auto;
  }
  .dialog-heading {
    padding: 12px 15px;
    gap: 12px;
  }
  .dialog-heading .mono {
    font-size: 9px;
    line-height: 1.7;
    letter-spacing: 0.03em;
  }
  .dialog-body {
    padding: 25px 20px;
  }
  .dialog-body h2 {
    font-size: 38px;
  }
  .dialog-body p,
  .dialog-body #checkout-message {
    font-size: 16px;
    line-height: 1.8;
  }
  .dialog-contact {
    font-size: 13px;
    line-height: 1.7;
    min-height: 44px;
    display: flex;
    align-items: center;
    width: fit-content;
  }
  body:not(.room-ready) .machine-controls {
    width: min(300px, calc(100% - 32px));
    max-height: calc(var(--visual-height) - 160px);
    overflow: hidden;
    pointer-events: none;
  }
  .boot-header {
    top: calc(20px + var(--safe-top));
    left: max(16px, var(--safe-left));
    right: max(16px, var(--safe-right));
  }
  .boot-header strong {
    font-size: 10px;
  }
  .boot-header > div {
    font-size: 8px;
  }
  .boot-header > span {
    font-size: 7px;
  }
  #skip-boot {
    font-size: 11px;
    min-height: 44px;
    bottom: calc(16px + var(--safe-bottom));
    right: max(16px, var(--safe-right));
  }
  .boot-screen small {
    font-size: 9px;
    line-height: 1.6;
    letter-spacing: 0;
  }
  .boot-caption {
    font-size: 9px;
  }
  .boot-caption > span {
    font-size: 8px;
  }
}
@media (max-width: 359px) {
  .room-brand {
    font-size: 8px;
  }
  .room-title > p:last-child {
    display: none;
  }
  .room-title h1 {
    font-size: 24px;
    max-width: 280px;
  }
  .room-index summary {
    font-size: 10px;
  }
  .page-content .credits.crew,
  .page-content .credits-layout > div:first-child .credits {
    grid-template-columns: 1fr;
  }
  .page-content .amount-presets {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .page-content .donation-label {
    font-size: 26px;
  }
  .page-top .mono {
    font-size: 7px;
  }
  .page-top p {
    font-size: 10px;
  }
}
@media (max-height: 600px) and (min-width: 600px) {
  .room-title {
    top: 90px;
    right: auto;
    display: block;
    max-width: 220px;
  }
  .room-title h1 {
    font-size: 28px;
    max-width: 220px;
  }
  .room-title > p:last-child {
    font-size: 13px;
    text-align: left;
    max-width: 200px;
    margin-top: 14px;
  }
  .room-title .eyebrow {
    font-size: 7px;
  }
  .room-instruction {
    display: none;
  }
  .touch-nav {
    left: 29%;
    right: 29%;
    bottom: calc(36px + var(--safe-bottom));
  }
  .room-bottom {
    font-size: 8px;
  }
  .page-shell {
    top: calc(var(--visual-top) + 62px + var(--safe-top));
    height: calc(
      var(--visual-height) - 70px - var(--safe-top) - var(--safe-bottom)
    );
  }
  .page-top {
    min-height: 56px;
    padding: 5px 15px;
  }
  .page-bottom {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 4px 12px;
    gap: 10px;
  }
  .boot-overlay {
    padding: 12px;
    gap: 0;
    overflow-y: auto;
  }
  .boot-instrument {
    width: 390px;
    max-width: calc(100% - 32px);
    padding: 10px 18px;
    transform: none;
  }
  .boot-plate-label {
    padding-bottom: 8px;
  }
  .boot-face {
    padding: 13px 17px;
  }
  .boot-circuits {
    margin-bottom: 12px;
    gap: 21px;
  }
  .boot-circuits i {
    width: 9px;
    height: 9px;
  }
  .boot-screen {
    min-height: 136px;
    padding: 14px 17px;
  }
  .boot-screen small {
    font-size: 8px;
    margin-bottom: 10px;
  }
  .boot-screen strong {
    font-size: 34px;
    min-height: 65px;
  }
  .boot-sweep {
    bottom: 12px;
  }
  .boot-progress {
    margin-top: 10px;
  }
  .boot-progress b {
    font-size: 21px;
  }
  .boot-bottom-label {
    margin-top: 8px;
  }
  .boot-caption,
  .boot-header > span {
    display: none;
  }
  .boot-header > div {
    font-size: 7px;
    max-width: 120px;
  }
  #skip-boot {
    font-size: 10px;
    max-width: 135px;
    bottom: 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .touch-nav button {
    transition: none;
  }
}

.dialog-heading {
  position: sticky;
  top: 0;
  z-index: 2;
}
