/* Phone dialogs share one reading scale and keep the game controls reachable. */
html[data-phone-device='true'] body#top[data-page='play'] :is(.modal, dialog),
html[data-phone-device='true'] body#top[data-page='play'] :is(.modal, dialog) * { scrollbar-width: none !important; }
html[data-phone-device='true'] body#top[data-page='play'] :is(.modal, dialog)::-webkit-scrollbar,
html[data-phone-device='true'] body#top[data-page='play'] :is(.modal, dialog) *::-webkit-scrollbar { display: none !important; width: 0; height: 0; }
@media (orientation: landscape) and (max-width: 1100px) and (max-height: 599px) {
  body#top[data-page='play'].phone-match-active {
    --phone-dialog-left: max(12px, env(safe-area-inset-left, 0px));
    --phone-dialog-right: max(12px, env(safe-area-inset-right, 0px));
    --phone-dialog-top: max(12px, env(safe-area-inset-top, 0px));
    --phone-dialog-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    --phone-combat-top: 80px;
    --phone-combat-bottom: calc(56px + var(--phone-footer-inset, 6px));
    --phone-combat-gap: 24px;
    --phone-battle-size: clamp(48px, calc(100dvh - 282px), 96px);
    --phone-core-accent: #ffd780;
  }
  html[data-theme='light'] body#top[data-page='play'].phone-match-active { --phone-core-accent: #79510b; }

  body#top[data-page='play'].phone-match-active .modal:not(#setup-screen) {
    padding: var(--phone-dialog-top) var(--phone-dialog-right) var(--phone-dialog-bottom) var(--phone-dialog-left);
  }
  body#top[data-page='play'].phone-match-active .modal:not(#setup-screen) > :not([aria-hidden='true']) {
    max-width: 100%;
    max-height: calc(100dvh - var(--phone-dialog-top) - var(--phone-dialog-bottom)) !important;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--text-low) transparent;
  }
  body#top[data-page='play'].phone-match-active .modal-card {
    width: min(680px, 100%);
    padding: 16px;
  }
  body#top[data-page='play'].phone-match-active :is(.modal, .row-popup) .btn,
  body#top[data-page='play'].phone-match-active :is(#btn-combat-done, #btn-tut-continue-step) {
    min-height: 44px;
    min-width: 44px;
    font-size: 12px;
    letter-spacing: .5px;
  }
  body#top[data-page='play'].phone-match-active .modal :is(p, .tut-modal-subtitle, .csb-description, .codex-card-body, .codex-banner-desc, .codex-action-desc, .codex-special-desc, .codex-core-body) {
    font-size: 13px !important;
    line-height: 1.45;
  }

  /* Confirm a reserve roll in its own side rail, without covering the board. */
  body#top[data-page='play'].phone-match-active .row-popup {
    position: fixed !important;
    top: 160px !important;
    bottom: auto;
    width: var(--phone-side-width, 140px);
    min-width: 0;
    max-width: var(--phone-side-width, 140px);
    max-height: calc(100dvh - 216px - var(--phone-footer-inset, 6px));
    padding: 8px;
    gap: 6px;
    transform: none !important;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }
  body#top[data-page='play'].phone-match-active .row-popup.popup-p1 {
    left: var(--phone-board-start, 8px) !important;
    right: auto;
  }
  body#top[data-page='play'].phone-match-active .row-popup.popup-p2 {
    right: var(--phone-controls-end, 8px);
    left: auto !important;
  }
  body#top[data-page='play'].phone-match-active .row-popup-lbl {
    font-size: 11px;
    line-height: 1.3;
    letter-spacing: .5px;
  }
  body#top[data-page='play'].phone-match-active .popup-big-val {
    width: 100%;
    height: 48px;
    min-height: 48px;
    font-size: 30px;
  }
  body#top[data-page='play'].phone-match-active .popup-actions { display: flex; gap: 4px; }
  body#top[data-page='play'].phone-match-active .popup-actions .btn {
    flex: 1;
    justify-content: center;
    border-radius: 8px;
    padding: 6px 2px;
    font: 800 12px/1.3 Inter, sans-serif;
    text-transform: none;
    letter-spacing: 0;
  }
  body#top[data-page='play'].phone-match-active .popup-p1 .btn-primary { background: #17628d; color: #f4f7fc; }
  body#top[data-page='play'].phone-match-active .popup-p2 .btn-primary { background: #743b82; color: #f4f7fc; }
  body#top[data-page='play'].phone-match-active .popup-actions .btn:disabled {
    opacity: 1 !important;
    color: var(--phone-muted, #b6c0d0) !important;
    background: var(--phone-field, #09101a) !important;
    border: 1px solid var(--phone-line, #758398) !important;
    filter: none !important;
    pointer-events: none !important;
    box-shadow: none !important;
  }

  /* Combat replaces each reserve with a focused, readable battle panel. */
  body#top[data-page='play'].phone-match-active.combat-active .side-stash {
    display: flex !important;
    position: fixed;
    top: var(--phone-combat-top);
    bottom: var(--phone-combat-bottom);
    width: calc((100vw - var(--phone-board-start, 8px) - var(--phone-controls-end, 8px) - var(--phone-combat-gap)) / 2) !important;
    max-width: none;
    height: calc(100dvh - var(--phone-combat-top) - var(--phone-combat-bottom)) !important;
    max-height: calc(100dvh - var(--phone-combat-top) - var(--phone-combat-bottom)) !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    transform: none !important;
    overflow: hidden;
    z-index: 70 !important;
  }
  body#top[data-page='play'].phone-match-active.combat-active .stash-p1 { left: var(--phone-board-start, 8px); right: auto; }
  body#top[data-page='play'].phone-match-active.combat-active .stash-p2 { right: var(--phone-controls-end, 8px); left: auto; }
  body#top[data-page='play'].phone-match-active.combat-active .stash-grid-wrapper { display: none !important; }
  body#top[data-page='play'].phone-match-active.combat-active #board-col { opacity: .16; pointer-events: none; }
  body#top[data-page='play'].phone-match-active.combat-active .combat-stash-content {
    display: block !important;
    position: absolute;
    inset: 8px;
    width: calc(100% - 16px) !important;
    height: calc(100% - 16px) !important;
    min-height: 0;
    padding: 0 !important;
  }
  body#top[data-page='play'].phone-match-active.combat-active :is(.cb-role-badge, .csp-unit) {
    position: absolute;
    top: 0;
    width: calc(50% - 2px);
    height: 24px;
    padding: 4px 2px !important;
    margin: 0 !important;
    font-size: 11px !important;
    line-height: 16px;
    letter-spacing: .4px !important;
    text-align: center;
  }
  body#top[data-page='play'].phone-match-active.combat-active .cb-role-badge { left: 0; }
  body#top[data-page='play'].phone-match-active.combat-active .csp-unit { right: 0; }
  body#top[data-page='play'].phone-match-active.combat-active .cb-section-title { display: none; }
  body#top[data-page='play'].phone-match-active.combat-active .combat-matrix-cell {
    position: absolute;
    inset: 28px 0 0;
    width: 100%;
    max-width: none;
    height: calc(100% - 28px) !important;
    min-height: 0;
    margin: 0 !important;
    padding: 18px 6px 32px;
    transform: none !important;
    justify-content: center !important;
  }
  body#top[data-page='play'].phone-match-active.combat-active .cb-battle-die-pill {
    top: 0 !important;
    padding: 3px 10px !important;
    font-size: 11px !important;
    line-height: 14px;
    letter-spacing: .7px !important;
  }
  body#top[data-page='play'].phone-match-active.combat-active .bg3-battle-die-widget {
    width: 100%;
    height: calc(var(--phone-battle-size) + 32px);
    min-height: calc(var(--phone-battle-size) + 32px);
    margin: 0 !important;
  }
  body#top[data-page='play'].phone-match-active.combat-active :is(.bg3-die-container, .bg3-3d-canvas, .bg3-die-body) {
    width: var(--phone-battle-size);
    height: var(--phone-battle-size);
  }
  body#top[data-page='play'].phone-match-active.combat-active .bg3-prompt-badge {
    min-width: min(112px, 100%);
    min-height: 24px;
    padding: 4px 8px !important;
    margin: 4px auto 0 !important;
    font-size: 11px !important;
    line-height: 14px;
    letter-spacing: .4px !important;
  }
  body#top[data-page='play'].phone-match-active.combat-active .bg3-die-face-content { width: 100%; height: 100%; }
  body#top[data-page='play'].phone-match-active.combat-active :is(.bg3-face-text, .bg3-boost-num, .bg3-final-boost) { font-size: clamp(28px, 6dvh, 36px) !important; }
  body#top[data-page='play'].phone-match-active.combat-active .bg3-die-face-content svg { width: 44px; height: 44px; }
  body#top[data-page='play'].phone-match-active.combat-active .bg3-effect-desc {
    position: absolute;
    bottom: 4px;
    left: 4px;
    right: 4px;
    width: calc(100% - 8px);
    min-height: 0;
    max-height: 30px;
    margin: 0 !important;
    padding: 0 !important;
    overflow-y: auto;
    scrollbar-width: thin;
  }
  body#top[data-page='play'].phone-match-active.combat-active .bg3-effect-text {
    font-size: 11px !important;
    line-height: 1.3 !important;
    letter-spacing: 0 !important;
  }
  body#top[data-page='play'].phone-match-active #combat-result-container { min-width: 0; width: 100%; }
  body#top[data-page='play'].phone-match-active #cb-outcome {
    font-size: 12px !important;
    line-height: 1.3;
    letter-spacing: .3px !important;
    white-space: normal !important;
  }
  body#top[data-page='play'].phone-match-active #btn-combat-done {
    position: static !important;
    margin-left: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    text-transform: none;
    transform: none !important;
    flex-shrink: 0;
  }
  body#top[data-page='play'].phone-match-active #evade-decision-container {
    inset: auto 0 0 !important;
    width: 100%;
    gap: 6px !important;
    transform: none !important;
  }
  body#top[data-page='play'].phone-match-active #evade-decision-container .btn {
    flex: 1;
    min-width: 0 !important;
    min-height: 48px;
    padding: 4px 6px !important;
    font-size: 11px !important;
    white-space: normal !important;
  }

  /* Core art and explanations have separate columns; neither shrinks the text. */
  body#top[data-page='play'].phone-match-active:has(#core-modal.active) #tutorial-overlay { visibility: hidden; pointer-events: none; }
  body#top[data-page='play'].phone-match-active #core-modal .core-chamber-card {
    display: grid !important;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    align-items: stretch !important;
    gap: 8px 16px !important;
    width: min(680px, 100%) !important;
    max-width: 680px !important;
    height: min(316px, calc(100dvh - 12px - var(--phone-dialog-bottom))) !important;
    padding: 16px !important;
    background: var(--phone-surface, #151d2a) !important;
    color: var(--phone-ink, #f3f6fb);
  }
  body#top[data-page='play'].phone-match-active #core-modal .core-hud-header { grid-area: 1 / 2; margin: 0; }
  body#top[data-page='play'].phone-match-active #core-modal :is(.core-eyebrow-row, .core-sys-label, .core-status-line) {
    font-size: 11px;
    line-height: 1.35;
    letter-spacing: .5px;
  }
  body#top[data-page='play'].phone-match-active #core-modal .core-eyebrow-row { flex-wrap: wrap; gap: 4px; }
  body#top[data-page='play'].phone-match-active #core-modal .core-scorer-tag { letter-spacing: .5px; }
  body#top[data-page='play'].phone-match-active #core-modal .core-sys-label { color: var(--phone-core-accent) !important; text-shadow: none; }
  body#top[data-page='play'].phone-match-active #core-modal .core-status-line { color: var(--phone-muted, #b6c0d0) !important; }
  body#top[data-page='play'].phone-match-active #core-modal .core-d4-widget {
    grid-area: 1 / 1 / 6 / 2;
    height: min(210px, calc(100dvh - 80px)) !important;
    min-height: 120px;
    align-self: center;
    overflow: hidden;
  }
  body#top[data-page='play'].phone-match-active #core-modal .core-3d-canvas {
    width: min(190px, calc(100dvh - 116px)) !important;
    height: min(190px, calc(100dvh - 116px)) !important;
    max-width: 100%;
  }
  body#top[data-page='play'].phone-match-active #core-modal .core-face-symbol { width: 120px; height: 120px; }
  body#top[data-page='play'].phone-match-active #core-modal .core-face-symbol svg { width: 110px; height: 110px; }
  body#top[data-page='play'].phone-match-active #core-modal .core-prompt-badge { bottom: 0; padding: 8px 10px; background: var(--phone-field, #09101a) !important; border-color: var(--phone-core-accent) !important; }
  body#top[data-page='play'].phone-match-active #core-modal .core-prompt-text { font-size: 11px; letter-spacing: .3px; color: var(--phone-ink, #f3f6fb) !important; }
  body#top[data-page='play'].phone-match-active #core-modal .core-outcome-section { grid-area: 2 / 2; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
  body#top[data-page='play'].phone-match-active #core-modal-title { font-size: 22px !important; letter-spacing: .5px !important; color: var(--phone-ink, #f3f6fb) !important; text-shadow: none !important; }
  body#top[data-page='play'].phone-match-active #core-modal-desc { font-size: 13px !important; line-height: 1.4; margin-bottom: 0 !important; color: var(--phone-muted, #b6c0d0) !important; }
  body#top[data-page='play'].phone-match-active #core-ready-container { grid-area: 3 / 2; flex-wrap: wrap; gap: 6px !important; margin: 0 !important; }
  body#top[data-page='play'].phone-match-active #core-ready-status { grid-area: 4 / 2; font-size: 12px !important; margin: 0 !important; color: var(--phone-muted, #b6c0d0) !important; }
  body#top[data-page='play'].phone-match-active #core-action-container { grid-area: 5 / 2; margin: 0 !important; }
  body#top[data-page='play'].phone-match-active #btn-core-ok { min-height: 48px; padding: 8px 10px !important; font-size: 12px !important; letter-spacing: .5px !important; background: #916008 !important; color: #fff !important; }
  body#top[data-page='play'].phone-match-active #btn-core-ok:is(:disabled, [data-core-confirmed='true']) { background: var(--phone-field, #09101a) !important; color: var(--phone-muted, #b6c0d0) !important; border-color: var(--phone-line, #758398) !important; box-shadow: none !important; }

  /* The normal tutorial prompt comes from the persistent phone status panel. */
  body#top[data-page='play'].phone-match-active #tutorial-banner {
    position: fixed;
    inset: auto auto calc(58px + var(--phone-footer-inset, 6px)) 50%;
    width: max-content;
    max-width: calc(100vw - 32px);
    min-height: 0;
    padding: 0;
    gap: 0;
    transform: translateX(-50%);
    border: 0;
    background: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    pointer-events: none;
  }
  body#top[data-page='play'].phone-match-active #tutorial-banner::before { display: none; }
  body#top[data-page='play'].phone-match-active #tutorial-banner .tut-banner-left { display: none; }
  body#top[data-page='play'].phone-match-active #tutorial-banner .tut-banner-actions { pointer-events: auto; }
  body#top[data-page='play'].phone-match-active #btn-tut-continue-step { min-height: 48px; padding: 8px 12px; white-space: normal; }
  body#top[data-page='play'].phone-match-active.tutorial-active.combat-active { --phone-combat-gap: 168px; }
  body#top[data-page='play'].phone-match-active.tutorial-active.combat-active #tutorial-banner {
    top: var(--phone-combat-top);
    bottom: var(--phone-combat-bottom);
    width: 144px;
    padding: 8px;
    flex-direction: column;
    align-items: stretch;
    justify-content: space-between;
    gap: 8px;
    background: var(--phone-surface, #151d2a) !important;
    color: var(--phone-ink, #f3f6fb) !important;
    border: 1px solid var(--text-low);
    border-radius: 8px;
    pointer-events: auto;
  }
  body#top[data-page='play'].phone-match-active.tutorial-active.combat-active #tutorial-banner .tut-banner-left {
    display: flex;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }
  body#top[data-page='play'].phone-match-active #tut-stage-badge { font-size: 11px; line-height: 1.35; letter-spacing: .2px; }
  body#top[data-page='play'].phone-match-active #tut-instruction-text { font-size: 12px; line-height: 1.4; letter-spacing: 0; }
  body#top[data-page='play'].phone-match-active.tutorial-active.combat-active .tut-banner-actions { flex-shrink: 0; }
  body#top[data-page='play'].phone-match-active.tutorial-active.combat-active #btn-tut-continue-step { width: 100%; }
  body#top[data-page='play'].phone-match-active.tutorial-active.combat-active #tut-stage-badge { color: var(--phone-ink, #f3f6fb) !important; text-shadow: none; }
  body#top[data-page='play'].phone-match-active.tutorial-active.combat-active #tut-instruction-text { color: var(--phone-muted, #b6c0d0) !important; }
  body#top[data-page='play'].phone-match-active.tutorial-active.combat-active #tut-instruction-text :is(strong, .tut-highlight) { color: var(--phone-ink, #f3f6fb) !important; }

  /* Read history in a drawer; references open within safe screen edges. */
  body#top[data-page='play'].phone-match-active #log-panel {
    position: fixed;
    inset: auto auto calc(58px + var(--phone-footer-inset, 6px)) 50% !important;
    width: min(480px, calc(100vw - var(--phone-dialog-left) - var(--phone-dialog-right))) !important;
    height: min(260px, calc(100dvh - 80px)) !important;
    max-height: calc(100dvh - 80px);
    transform: translateX(-50%) !important;
    z-index: 300;
  }
  body#top[data-page='play'].phone-match-active #log-panel.collapsed { display: none !important; }
  body#top[data-page='play'].phone-match-active #log-panel .log-toggle-btn { min-height: 44px; height: 44px !important; flex-basis: 44px; font-size: 12px !important; }
  body#top[data-page='play'].phone-match-active #game-log { min-height: 0; padding: 10px 12px; gap: 8px; }
  body#top[data-page='play'].phone-match-active #log-panel .chat-msg { font-size: 12px; line-height: 1.45; padding: 8px 10px; }
  body#top[data-page='play'].phone-match-active #tactical-codex-modal .codex-card { width: min(920px, 100%) !important; height: calc(100dvh - 12px - var(--phone-dialog-bottom)) !important; padding: 0 !important; overflow: hidden; }
  body#top[data-page='play'].phone-match-active .codex-header-bar { padding: 8px 12px !important; min-height: 60px; margin-bottom: 8px; }
  body#top[data-page='play'].phone-match-active .codex-header-actions { position: static !important; gap: 4px !important; }
  body#top[data-page='play'].phone-match-active .codex-modal-title { font-size: 16px !important; letter-spacing: .7px !important; }
  body#top[data-page='play'].phone-match-active .codex-header-actions :is(button, .audio-toggle-btn) { min-width: 44px; min-height: 44px; }
  body#top[data-page='play'].phone-match-active .codex-tab-btn { min-height: 44px; font-size: 11px; padding: 8px 12px; }
  body#top[data-page='play'].phone-match-active .codex-content-container { min-height: 0; padding: 12px; }
}


@media (orientation: landscape) and (max-width: 700px) and (max-height: 599px) {
  body#top[data-page='play'].phone-match-active .row-popup {
    top: 112px !important;
    max-height: calc(100dvh - 168px - var(--phone-footer-inset, 6px));
  }
}

@media (orientation: landscape) and (max-width: 1000px) and (max-height: 340px) {
  body#top[data-page='play'].phone-match-active { --phone-battle-size: 48px; }
  body#top[data-page='play'].phone-match-active .row-popup { top: 112px !important; max-height: calc(100dvh - 168px - var(--phone-footer-inset, 6px)); }
  body#top[data-page='play'].phone-match-active #core-modal .core-chamber-card { padding: 12px !important; gap: 6px 12px !important; }
  body#top[data-page='play'].phone-match-active #core-modal .core-d4-widget { height: 190px !important; }
  body#top[data-page='play'].phone-match-active #core-modal .core-3d-canvas { width: 164px !important; height: 164px !important; }
  body#top[data-page='play'].phone-match-active #core-modal-title { font-size: 20px !important; }
  body#top[data-page='play'].phone-match-active #core-modal-desc { font-size: 12px !important; }
}

@media (prefers-reduced-motion: reduce) {
  body#top[data-page='play'].phone-match-active :is(.bg3-die-container, .bg3-prompt-badge, .core-prompt-pulse, .core-shockwave-ring, .bg3-shockwave-ring) { animation: none !important; }
}

/* Online confirmation keeps the settled Core explanation visible on short phones. */
@media (orientation: landscape) and (max-width: 1100px) and (max-height: 300px) {
  body#top[data-page='play'].phone-match-active #core-modal .core-chamber-card { gap: 4px 12px !important; }
  body#top[data-page='play'].phone-match-active #core-modal .core-hud-header { gap: 3px; }
  body#top[data-page='play'].phone-match-active #core-ready-container { padding: 4px 8px !important; }
  body#top[data-page='play'].phone-match-active #core-ready-status { font-size: 11px !important; line-height: 1.3; }
  body#top[data-page='play'].phone-match-active #core-modal-title { margin: 0 0 4px !important; }
  body#top[data-page='play'].phone-match-active #core-modal-desc { line-height: 1.35 !important; }
}

/* Match confirmations share safe spacing and keep both choices visible without scrolling. */
@media (orientation: landscape) and (max-width: 1100px) and (max-height: 599px) {
  body#top[data-page='play'].phone-match-active #game-confirm-modal {
    box-sizing: border-box;
    padding: var(--phone-dialog-top) var(--phone-dialog-right) var(--phone-dialog-bottom) var(--phone-dialog-left);
    overflow: hidden;
  }
  body#top[data-page='play'].phone-match-active #game-confirm-modal .confirm-card {
    width: min(440px, 100%) !important;
    max-width: 440px !important;
    max-height: calc(100dvh - var(--phone-dialog-top) - var(--phone-dialog-bottom));
    padding: 16px !important;
    box-sizing: border-box;
    overflow: hidden;
  }
  body#top[data-page='play'].phone-match-active #game-confirm-modal .confirm-card > div:first-child {
    width: 36px !important;
    height: 36px !important;
    margin: 0 auto 12px !important;
  }
  body#top[data-page='play'].phone-match-active #gcm-title {
    font-size: 15px !important;
    line-height: 1.25 !important;
    letter-spacing: .7px !important;
    margin: 0 0 10px !important;
  }
  body#top[data-page='play'].phone-match-active #gcm-desc {
    font-size: 13px !important;
    line-height: 1.4 !important;
    margin: 0 0 16px !important;
  }
  body#top[data-page='play'].phone-match-active #game-confirm-modal .confirm-card > div:last-child {
    gap: 8px !important;
  }
  body#top[data-page='play'].phone-match-active :is(#gcm-btn-cancel, #gcm-btn-confirm) {
    min-width: 44px;
    min-height: 44px;
    height: 44px;
    padding: 6px 10px !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
    letter-spacing: .5px !important;
    white-space: normal;
    box-sizing: border-box;
  }
}

/* Before the outcome, the Core has one centered focal point in the same outer card. */
@media (orientation: landscape) and (max-width: 1100px) and (max-height: 599px) {
  body#top[data-page='play'].phone-match-active #core-modal:has(#core-modal-title[style*='none']) .core-chamber-card {
    grid-template-rows: auto minmax(0, 1fr);
  }
  body#top[data-page='play'].phone-match-active #core-modal:has(#core-modal-title[style*='none']) .core-hud-header {
    grid-area: 1 / 1 / 2 / 3; flex-direction: row; justify-content: space-between;
    align-items: center; gap: 8px; text-align: center;
  }
  body#top[data-page='play'].phone-match-active #core-modal:has(#core-modal-title[style*='none']) .core-eyebrow-row {
    justify-content: center; flex-wrap: nowrap;
  }
  body#top[data-page='play'].phone-match-active #core-modal:has(#core-modal-title[style*='none']) .core-status-line {
    white-space: nowrap;
  }
  body#top[data-page='play'].phone-match-active #core-modal:has(#core-modal-title[style*='none']) .core-d4-widget {
    grid-area: 2 / 1 / 3 / 3; justify-self: center; align-self: stretch;
    width: 100%; height: 100% !important; min-height: 0; max-height: 100%;
  }
  body#top[data-page='play'].phone-match-active #core-modal:has(#core-modal-title[style*='none']) .core-die-container {
    position: absolute; inset: 0 0 38px; width: 100%; height: auto;
  }
  body#top[data-page='play'].phone-match-active #core-modal:has(#core-modal-title[style*='none']) .core-3d-canvas {
    width: min(190px, calc(100dvh - 108px)) !important;
    height: min(190px, calc(100dvh - 108px)) !important;
  }
  body#top[data-page='play'].phone-match-active #core-modal:has(#core-modal-title[style*='none']) :is(.core-outcome-section, #core-action-container) {
    display: none !important;
  }
}

/* The original 3D Core fills its chamber at twice the former phone scale. */
@media (orientation: landscape) and (max-width: 1100px) and (max-height: 599px) {
  body#top[data-page='play'].phone-match-active #core-modal .core-d4-widget {
    height: min(280px, calc(100dvh - var(--phone-dialog-top) - var(--phone-dialog-bottom) - 26px)) !important;
    max-height: 100%;
  }
  body#top[data-page='play'].phone-match-active #core-modal .core-3d-canvas {
    transform: translate(-50%, -50%) scale(2) !important;
    transform-origin: center;
  }
}

/* Short Core rolls use the full event surface with a separate prompt strip. */
@media (orientation: landscape) and (max-width: 1100px) and (max-height: 300px) {
  body#top[data-page='play'].phone-match-active #core-modal:has(#core-modal-title[style*='none']) {
    --phone-dialog-top: max(4px, env(safe-area-inset-top, 0px));
    --phone-dialog-bottom: max(4px, env(safe-area-inset-bottom, 0px));
  }
  body#top[data-page='play'].phone-match-active #core-modal:has(#core-modal-title[style*='none']) .core-chamber-card {
    height: calc(100dvh - var(--phone-dialog-top) - var(--phone-dialog-bottom)) !important;
    max-height: calc(100dvh - var(--phone-dialog-top) - var(--phone-dialog-bottom)) !important;
    padding: 8px 12px 12px !important;
  }
}
