.phone-layout .phone-rotate[open] {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  box-sizing: border-box;
  margin: 0;
  padding: 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  border: 0;
  background: #1d4965;
  color: #fff;
  text-align: center;
  font-family: system-ui, sans-serif;
  overflow: auto;
}
.phone-layout .phone-rotate::backdrop { background: #1d4965; }
.phone-rotate-open { overflow: hidden; }
.phone-layout .phone-rotate-icon {
  display: block;
  color: #ffbf46;
  font-size: clamp(44px, 18vh, 76px);
  line-height: 1;
}
.phone-layout .phone-rotate h2 {
  margin: 12px 0 6px;
  font-size: clamp(22px, 5vh, 32px);
}
.phone-layout .phone-rotate p { margin: 0; font-size: 16px; }

@media (max-width: 600px) {
  .phone-layout header .site-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }
  .phone-layout header .site-tabs > a {
    min-height: 44px;
    padding-inline: 6px;
    text-align: center;
  }
  .phone-layout .home-hero { min-height: auto; }
  .phone-layout .hero-copy { padding: 28px 16px; }
  .phone-layout .home-links { display: grid; }
  .phone-layout .home-links a { text-align: center; }
  .phone-layout .home-content { padding-inline: 16px; }
  .phone-layout .explore-card { padding: 18px; }
  .phone-layout .story-layout { padding: 12px; gap: 12px; }
  .phone-layout .story-layout > article { padding: 18px 14px; }
  .phone-layout .layout,
  .phone-layout body.viewer .layout { min-height: 0; }
  .phone-layout .map-stage,
  .phone-layout body.viewer .map-stage {
    height: clamp(300px, 55dvh, 560px);
    min-height: 0;
  }
  .phone-layout #detailPanel { height: 72%; max-height: 72%; }
  .phone-layout #entries { grid-template-columns: minmax(0, 1fr); }
}

/* Compact header for phones held upright. */
@media (orientation: portrait) {
  .phone-layout header .header-identity p {
    display: none;
  }
  .phone-layout header {
    padding-top: 6px;
    padding-bottom: 6px;
    row-gap: 6px;
  }
}
/* Phone portrait map reading layout. */
.phone-map-letters,
.phone-map-entry { display: none; }

@media (orientation: portrait) {
  .phone-layout body:has(.layout) { height: auto; min-height: 100dvh; }
  .phone-layout .layout,
  .phone-layout body.viewer .layout {
    display: flex;
    flex-direction: column;
    flex: none;
    height: auto;
    min-height: 0;
    gap: 0;
  }
  .phone-layout .layout > aside { display: none; }
  .phone-layout .map-stage,
  .phone-layout body.viewer .map-stage {
    order: 0;
    flex: none;
    width: 100%;
    height: auto;
    min-height: 0;
    aspect-ratio: 1;
  }
  .phone-layout #map,
  .phone-layout body.viewer #map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
  }
  .phone-layout #detailPanel { display: none; }
  .phone-layout .phone-map-letters {
    order: 1;
    display: flex;
    flex: none;
    gap: 8px;
    padding: 12px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    background: white;
    border-bottom: 1px solid #d4e0e5;
  }
  .phone-layout .phone-map-letters button {
    flex: 0 0 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    text-align: center;
    color: #004F71;
    font-weight: 600;
  }
  .phone-layout .phone-map-letters button[aria-current="true"] {
    background: #F2A900;
    border-color: #004F71;
    color: #000;
  }
  .phone-layout .phone-map-entry {
    order: 2;
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 20px 16px 24px;
    background: white;
    color: #000;
    overflow-wrap: anywhere;
    line-height: 1.7;
  }
  .phone-layout .phone-map-entry h2 {
    margin: 0 0 16px;
    font: 600 24px/1.3 system-ui, sans-serif;
    color: #004F71;
  }
  .phone-layout .phone-map-entry .popup { width: auto; max-width: none; }
  .phone-layout .phone-map-entry .image-enlarge { width: 100%; }
  .phone-layout .phone-map-entry img {
    display: block;
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
  }
  .phone-layout .phone-map-entry p { white-space: pre-wrap; margin: 18px 0; }
  .phone-layout .phone-map-pagination {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 24px;
  }
  .phone-layout .phone-map-pagination button { min-height: 44px; }
}

@media (orientation: portrait) {
  .phone-layout .site-footer {
    justify-content: center;
  }
}

@media (orientation: portrait) {
  .phone-layout .story-layout > .contents {
    display: none;
  }
}

/* Full-width stories only on phones held upright. */
@media (orientation: portrait) {
  .phone-layout .story-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none;
    padding-inline: 0;
    padding-bottom: 0;
    margin-bottom: 0;
  }
  .phone-layout .story-layout > .story-nav {
    width: 100%;
    padding-inline: 12px;
  }
  .phone-layout .story-layout > article {
    width: 100%;
    max-width: none;
    margin-inline: 0;
    padding: 20px 16px 24px;
    border-radius: 0;
    box-shadow: none;
  }
}

/* Shared footer and accessibility settings. */
.site-footer {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  align-items: center;
}
.site-footer .anniversary-logo { grid-column: 2; justify-self: center; }
.access-footer-button { grid-column: 3; justify-self: end; }
.access-phone-button { display: none; }
.access-panel {
  position: fixed;
  inset: auto 22px 100px auto;
  margin: 0;
  width: min(360px, calc(100vw - 32px));
  max-height: 80dvh;
  overflow: auto;
  padding: 22px;
  border: 1px solid #004F71;
  border-radius: 12px;
  background: #fff;
  color: #000;
  box-shadow: 0 8px 40px #0003;
  font: 16px/1.5 system-ui,sans-serif;
}
.access-panel::backdrop { background: #0003; }
.access-panel-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:20px; }
.access-panel h2 { font:600 22px/1.3 system-ui,sans-serif; margin:0; color:#004F71; }
.access-panel label { display:block; margin:16px 0 8px; }
.access-panel select { width:100%; min-height:44px; padding:8px; }
.access-panel .access-check { display:flex; align-items:center; gap:10px; min-height:44px; }
.access-panel input { width:20px; height:20px; }
.access-panel button, .access-footer-button { min-height:44px; padding:9px 14px; border:1px solid #004F71; border-radius:6px; background:#fff; color:#004F71; font:inherit; cursor:pointer; }
.access-panel :focus-visible, .access-footer-button:focus-visible, .access-phone-button:focus-visible { outline:3px solid #004F71; outline-offset:3px; }
body .home-main p, body .phone-map-entry p { font-size:calc(17px * var(--reading-scale,1)); }
body.high-contrast .home-main, body.high-contrast .home-main p, body.high-contrast .story-layout article, body.high-contrast .phone-map-entry { color:#000; }
body.reduce-motion .home-links a:hover { transform:none; }
@media (orientation: portrait) {
  .phone-layout .site-footer { display:flex; justify-content:center; }
  .phone-layout .access-footer-button { display:none; }
  .phone-layout header .site-tabs { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)) 44px; width:100%; gap:2px; }
  .phone-layout header .access-phone-button { display:grid; place-items:center; min-width:44px; min-height:44px; padding:8px; border:0; border-radius:6px; color:white; background:transparent; cursor:pointer; }
  .phone-layout .access-phone-button:focus-visible { outline-color:#F2A900; }
  .phone-layout .access-panel { inset:auto 0 0; width:100%; max-width:100%; max-height:85dvh; border-radius:16px 16px 0 0; padding-bottom:max(22px,env(safe-area-inset-bottom)); }
}
