/* Language 5: device policy and camera controls. Existing desktop geometry stays intact. */
html .portrait-notice { display: none; z-index: 10000; }
html[data-orientation-blocked="true"] .portrait-notice { display: grid; }
html .portrait-notice[hidden] { display: none !important; }
.camera-choice { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.camera-choice[hidden] { display: none !important; }
.camera-choice select { min-width: 0; max-width: 100%; flex: 1; min-height: 40px; padding: 6px; border-radius: 10px; color: #123c59; background: #eefaff; font: inherit; }
.camera-choice-status { margin: 3px 0; font-size: 14px; line-height: 1.4; }
.starbag-app #cameraPreview[data-facing="environment"] { transform: none; }
.starbag-app #cameraPreview[data-facing="user"] { transform: scaleX(-1); }
/* The document scrolls; the calibration panel and copy never become nested scrollers. */
html[data-device="tablet"][data-screen="CALIBRATION"],
html[data-device="tablet"][data-screen="CALIBRATION"] body { height: auto; min-height: 100%; overflow: auto; }
html[data-device="tablet"][data-screen="CALIBRATION"] .starbag-app { height: auto; min-height: 100dvh; overflow: visible; }
html[data-device="tablet"] #calibrationScreen { position: relative; min-height: 100dvh; padding: 88px 28px 110px; }
html[data-device="tablet"] .calibration-panel { width: 100%; height: auto; min-height: 0; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 24px; padding: 24px; }
html[data-device="tablet"] .calibration-visual { min-height: 0; height: auto; aspect-ratio: 4 / 3; }
html[data-device="tablet"] .calibration-copy { min-width: 0; overflow: visible; }
html[data-device="tablet"] .calibration-copy h2 { font-size: clamp(28px, 3.5vw, 40px); }
html[data-device="tablet"] .calibration-copy ol { font-size: 18px; margin: 12px 0; line-height: 1.5; }
html[data-device="tablet"] .calibration-actions { flex-wrap: wrap; }
@media (orientation: portrait) {
  html[data-device="phone"], html[data-device="phone"] body { height: auto; min-height: 100%; overflow: auto; }
  html[data-device="phone"] .starbag-app { min-height: 100dvh; height: auto; overflow: visible; }
  html[data-device="phone"] .starbag-screen:not(.activity-screen) { position: relative; min-height: 100dvh; padding: 100px 16px 110px; }
  html[data-device="phone"] .starbag-header { left: 16px; right: 16px; }
  html[data-device="phone"] .starbag-header h1 { font-size: 26px; }
  html[data-device="phone"] .phase-chip { min-width: 0; font-size: 14px; padding: 8px; }
  html[data-device="phone"] .starbag-eyebrow { font-size: 11px; }
  html[data-device="phone"] .group-activity-grid { width: 100%; grid-template-columns: 1fr; gap: 18px; }
  html[data-device="phone"] .group-activity-card { min-height: 270px; padding: 135px 18px 22px; }
  html[data-device="phone"] .group-home-copy h2 { font-size: 38px; }
  html[data-device="phone"] .setup-panel,
  html[data-device="phone"] .calibration-panel { width: 100%; height: auto; padding: 20px; gap: 20px; grid-template-columns: minmax(0, 1fr); }
  html[data-device="phone"] .setup-intro { padding: 0; }
  html[data-device="phone"] .setup-intro h2,
  html[data-device="phone"] .calibration-copy h2 { font-size: 32px; }
  html[data-device="phone"] .calibration-visual { min-height: 0; aspect-ratio: 4 / 3; }
  html[data-device="phone"] .calibration-copy { min-width: 0; }
  html[data-device="phone"] .calibration-actions { flex-wrap: wrap; }
  html[data-device="phone"] .camera-consent-gate { position: fixed; padding: 16px; overflow-y: auto; }
  html[data-device="phone"] .camera-consent-card { width: 100%; padding: 22px; }
  html[data-device="phone"] .camera-consent-actions { flex-wrap: wrap; }
  html[data-device="phone"] .activity-screen { position: relative; height: 100dvh; min-height: 560px; overflow: hidden; padding: 0; }
  html[data-device="phone"] .activity-prompt { width: calc(100% - 32px); min-width: 0; gap: 8px; padding: 10px; }
  html[data-device="phone"] .activity-prompt strong { font-size: 24px; }
  html[data-device="phone"] .activity-prompt span { font-size: 16px; }
  html[data-device="phone"] .prompt-star { width: 36px; }
  html[data-device="phone"] .facilitator-rail:not(.is-collapsed) { width: min(310px, 88vw); }
  html[data-device="phone"] .result-overlay { inset: 16% 5%; padding: 20px; }
}

/* Language 5.3 — Phone Portrait Team geometry only.
   Shared inset = half of the normal bag width + 6px.
   Logical star/bag X and collision thresholds remain unchanged. */
@media (orientation: portrait) {
  html[data-device="phone"] .starbag-app #teamBoard {
    left: 12px !important;
    right: 12px !important;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    transition: none;
  }
  html[data-device="phone"] #teamBoard .team-lane {
    min-width: 0;
    container-type: inline-size;
    border-radius: 18px;
  }
  html[data-device="phone"] #teamBoard .team-lane header { left: 8px; right: 8px; gap: 4px; }
  html[data-device="phone"] #teamBoard .team-lane h3 { font-size: 20px; }
  html[data-device="phone"] #teamBoard .team-score { width: 34px; height: 34px; font-size: 20px; }
  html[data-device="phone"] #teamBoard .team-bag {
    width: min(92px, 54%);
    height: min(58px, 34cqw);
    bottom: max(3%, 10px);
  }
  html[data-device="phone"] #teamBoard .falling-star {
    width: min(46px, 33cqw);
    height: min(46px, 33cqw);
    --phone-star-half: min(23px, 16.5cqw);
  }
  html[data-device="phone"] #teamBoard .falling-star.is-big {
    width: min(94px, 60cqw);
    height: min(94px, 60cqw);
    --phone-star-half: min(49.585px, 31.65cqw); /* includes existing 1.055 ready pulse */
  }
  html[data-device="phone"] #teamBoard :is(.team-bag, .falling-star) {
    --phone-team-inset: calc(min(46px, 27cqw) + 6px);
    left: calc(var(--phone-team-inset) + (100% - 2 * var(--phone-team-inset)) * clamp(0, var(--phone-team-x, .5), 1)) !important;
  }
  html[data-device="phone"] #teamBoard .falling-star {
    top: clamp(calc(var(--phone-star-half) + 6px), var(--phone-team-y, 6%), calc(100% - var(--phone-star-half) - 6px)) !important;
  }
  html[data-device="phone"] #teamBoard .falling-star.is-big {
    left: clamp(calc(var(--phone-star-half) + 6px), calc(var(--phone-team-inset) + (100% - 2 * var(--phone-team-inset)) * clamp(0, var(--phone-team-x, .5), 1)), calc(100% - var(--phone-star-half) - 6px)) !important;
  }
  html[data-device="phone"] #teamBoard .team-bag.is-expanded {
    transform: translateX(-50%) scale(1.08);
  }
  /* Preserve the fade duration; avoid the old 1.8× mist expanding across safe edges. */
  html[data-device="phone"] #teamBoard .falling-star.is-fading { animation-name: phoneTeamMist; }
}
@keyframes phoneTeamMist {
  to { opacity: 0; transform: translate(-50%, -50%); }
}

/* StarBag-only presentation lock: keep legacy DOM/state for compatibility. */
#starBagApp #phaseChip,
#starBagApp .setup-form fieldset[hidden] { display: none !important; }

/* Language 5.3.1 — Phone gameplay branding cleanup.
   Runtime already marks the global header hidden on activityScreen.
   Only phone honors that hidden state here; iPad/Desktop presentation stays unchanged. */
html[data-device="phone"] #starBagApp > .starbag-header[hidden] {
  display: none !important;
}
