/* A quiet frame around the player, on desktop and mobile. */
.brand { font-size: 16px; font-weight: 400; letter-spacing: 3px; }
main { width: min(510px, calc(100% - 44px)); grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 0; padding-block: 32px 64px; }
.cassette-label .label-rule { margin: 0; }
.listening:empty { display: none; }

/* Fit the available phone viewport; shrink the cassette before the controls. */
@media (max-width: 820px), (max-height: 500px) and (pointer: coarse) {
  body {
    height: 100svh;
    height: 100dvh;
    min-height: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
      env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .masthead, footer { width: calc(100% - 40px); flex-shrink: 0; }
  .masthead { height: clamp(44px, 7dvh, 62px); }
  main {
    width: min(460px, calc(100% - 32px));
    flex: 1;
    min-height: 0;
    margin: 0 auto;
    padding: 10px 0 32px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
  }
  .intro { padding: 0; text-align: center; }
  .eyebrow { justify-content: center; font-size: 8px; }
  h1 { font-size: clamp(24px, 3.7dvh, 32px); line-height: 1.3; margin: 8px 0; letter-spacing: 0; }
  h1 br, .intro-copy br, .intro-bottom { display: none; }
  .intro-copy { font-size: 10px; line-height: 1.6; letter-spacing: .4px; }
  .device {
    height: 100%;
    max-height: 610px;
    min-height: 0;
    align-self: center;
    display: flex;
    flex-direction: column;
    padding: clamp(14px, 2dvh, 22px) 20px 14px;
    border-radius: 19px;
  }
  .device-heading { flex-shrink: 0; margin-bottom: 10px; }
  .device-heading strong { font-size: 16px; }
  .device-heading div:first-child > span { font-size: 6px; margin-top: 5px; }
  .cassette-bay { flex: 1; min-height: 0; height: auto; padding: 10px; }
  .cassette { width: 100%; height: 100%; padding: 8px 10px 0; }
  .cassette-label { height: 30%; max-height: 51px; padding: 4px 8px; gap: 8px; }
  .handwriting { font-size: clamp(12px, 2dvh, 17px); letter-spacing: 0; }
  .side { font-size: 18px; }
  .tape-length { font-size: 9px; }
  .tape-window { height: 40%; border-width: 4px; }
  .reel { height: 75%; width: auto; aspect-ratio: 1; max-height: 48px; border-width: 4px; }
  .reel i { width: 40%; height: 40%; }
  .tape-bridge { top: 25%; height: 50%; }
  .cassette-stripes { height: 8%; max-height: 12px; }
  .cassette-bottom { height: 16%; max-height: 27px; }
  .display { flex-shrink: 0; margin-top: 12px; padding: 9px 12px 4px; }
  .display-top { font-size: 8px; letter-spacing: .3px; }
  .display-center { height: 36px; }
  .clock { font-size: 27px; }
  #duration { font-size: 12px; }
  .duration-divider { margin-inline: 5px; }
  .transport { flex-shrink: 0; margin-top: 12px; }
  .transport-key { height: 58px; gap: 5px; }
  .settings { flex-shrink: 0; margin-top: 8px; gap: 4px; }
  .icon-button { width: 38px; height: 40px; }
  .repeat-one { left: 16px; top: 15px; }
  .mode-controls { gap: 0; }
  #mode-label { font-size: 8px; margin-left: 1px; }
  .volume-control { gap: 3px; }
  .volume-control input { width: 56px; }
  .device-foot { display: none; }
  .listening { margin-top: 10px; font-size: 9px; letter-spacing: .5px; }
  footer { min-height: 0; height: 28px; font-size: 7px; letter-spacing: .3px; gap: 8px; }
  footer > span:last-child { font-size: 8px; gap: 6px; }
}
@media (max-width: 820px) and (max-height: 660px), (max-height: 500px) and (pointer: coarse) {
  .eyebrow, .intro-copy { display: none; }
  main { padding-top: 6px; gap: 8px; }
  h1 { margin: 0; font-size: 25px; }
  .device { padding-top: 13px; padding-bottom: 8px; }
  .device-heading { margin-bottom: 8px; }
  .device-heading div:first-child > span { display: none; }
  .cassette-bay { padding: 6px; }
  .cassette { padding-top: 4px; }
  .cassette-label { padding-block: 1px; }
  .handwriting { font-size: 12px; }
  .tape-length small, .label-rule { display: none; }
}
@media (max-width: 820px) and (max-height: 520px), (max-height: 500px) and (pointer: coarse) {
  main { grid-template-rows: minmax(0, 1fr); }
  .intro, .cassette-bay, footer { display: none; }
  .device { max-height: 340px; justify-content: center; }
  .display { margin-top: 0; }
}
@media (max-width: 820px) and (max-height: 400px), (max-height: 400px) and (pointer: coarse) {
  .masthead, .device-heading { display: none; }
  main { padding-top: 8px; }
}
