/* Preserve the desktop duel's faction color and artwork at phone scale. */
@media (orientation: landscape) and (max-width: 1100px) and (max-height: 599px) {
  body#top[data-page='play'].phone-match-active {
    --core-impact-amplitude:.08;
    --phone-field:#100919; --phone-surface:#1d102c; --phone-line:#554563;
    --phone-ink:#f8f3ff; --phone-muted:#c5b7d2; --phone-azure:#00b6ff; --phone-violet:#ff48ba;
    --phone-safe-top:env(safe-area-inset-top,0px);
    --phone-safe-bottom:env(safe-area-inset-bottom,0px);
    --phone-safe-left:env(safe-area-inset-left,0px);
    --phone-safe-right:env(safe-area-inset-right,0px);
    --phone-board-start:max(4px,var(--phone-safe-left));
    --phone-controls-end:max(4px,var(--phone-safe-right));
    --phone-board-gutter:max(var(--phone-board-start),var(--phone-controls-end));
    --phone-board-left:calc(var(--phone-board-gutter) + var(--phone-reserve-width) + 6px);
    --phone-board-right:var(--phone-board-left);
    --phone-reserve-width:clamp(100px,14vw,120px); --phone-side-width:var(--phone-reserve-width);
    --phone-reserve-top:calc(100px + var(--phone-safe-top)); --hud-w:clamp(112px,16.5vw,140px);
    --phone-reserve-die-size:calc((var(--phone-reserve-width) - 14px)/2);
    --phone-portrait:clamp(54px,7.6vw,66px);
  }
  html[data-theme='light'] body#top[data-page='play'].phone-match-active {
    --phone-field:#eee6f5; --phone-surface:#f9f0ff; --phone-line:#b1a0bd;
    --phone-ink:#2a183b; --phone-muted:#655473; --phone-azure:#0076ba; --phone-violet:#b01f81;
  }
  body#top[data-page='play'].phone-match-active #game-screen { background:var(--phone-field)!important; }
  body#top[data-page='play'].phone-match-active #game-screen::before,
  body#top[data-page='play'].phone-match-active #game-screen::after {
    content:''; position:absolute; inset:0; pointer-events:none; z-index:0; transition:opacity .55s ease;
    background:radial-gradient(ellipse at 10% 42%,#0099ff35,transparent 60%),radial-gradient(ellipse at 96% 68%,#ff2bb110,transparent 65%),repeating-radial-gradient(ellipse at 50% 50%,transparent 0 45px,#aabfff07 46px 47px,transparent 48px 70px);
  }
  body#top[data-page='play'].phone-match-active #game-screen::after {
    background:radial-gradient(ellipse at 90% 42%,#ff2bb135,transparent 60%),radial-gradient(ellipse at 4% 68%,#0099ff10,transparent 65%),repeating-radial-gradient(ellipse at 50% 50%,transparent 0 45px,#ddbaff07 46px 47px,transparent 48px 70px); opacity:0;
  }
  body#top[data-page='play'].phone-match-active[data-phone-active='p2'] #game-screen::before {opacity:0;}
  body#top[data-page='play'].phone-match-active[data-phone-active='p2'] #game-screen::after {opacity:1;}
  body#top[data-page='play'].phone-match-active #topographic-bg-container {display:none!important;}
  body#top[data-page='play'].phone-match-active #main-game-area {inset:var(--phone-safe-top) var(--phone-board-right) var(--phone-safe-bottom) var(--phone-board-left);z-index:1;overflow:visible!important;}
  body#top[data-page='play'].phone-match-active #board-col {padding:2px!important;}
  body#top[data-page='play'].phone-match-active .hex-glass-backdrop {display:none;}
  body#top[data-page='play'].phone-match-active .hex-poly {fill:#160f28e8!important;stroke:#756285!important;stroke-width:1.4!important;}
  body#top[data-page='play'].phone-match-active .hex-poly.hex-control {fill:#6b54194d!important;stroke:#d8ad45b3!important;}
  body#top[data-page='play'].phone-match-active .hex-poly.hex-center {fill:#c897296b!important;stroke:#f3ce69!important;}
  body#top[data-page='play'].phone-match-active .hex-poly.hex-deploy-p1 {fill:#0099ff32!important;stroke:#00b6ff!important;}
  body#top[data-page='play'].phone-match-active .hex-poly.hex-deploy-p2 {fill:#ff2bb132!important;stroke:#ff48ba!important;}
  body#top[data-page='play'].phone-match-active .hex-poly:is(.hex-valid,.hex-deploy-valid-p1,.hex-deploy-valid-p2) {fill:#00e5a328!important;stroke:#48ffca!important;stroke-width:2.8!important;}
  body#top[data-page='play'].phone-match-active .hex-poly.hex-attack {fill:#ff3b5c35!important;stroke:#ff8a9d!important;}
  body#top[data-page='play'].phone-match-active .hex-poly:is(.hex-selected,.hex-selected-p1,.hex-selected-p2) {stroke:#fff!important;stroke-width:2.6!important;}
  html[data-theme='light'] body#top[data-page='play'].phone-match-active .hex-poly {fill:#f9f0ffdf!important;stroke:#9b88ad!important;}
  html[data-theme='light'] body#top[data-page='play'].phone-match-active .hex-poly.hex-control {fill:#e6ce9177!important;stroke:#a57916!important;}
  html[data-theme='light'] body#top[data-page='play'].phone-match-active .hex-poly.hex-center {fill:#dcbd68!important;stroke:#80600e!important;}
  html[data-theme='light'] body#top[data-page='play'].phone-match-active .hex-poly.hex-deploy-p1 {fill:#83caff7f!important;stroke:#0076ba!important;}
  html[data-theme='light'] body#top[data-page='play'].phone-match-active .hex-poly.hex-deploy-p2 {fill:#ff8bd07f!important;stroke:#b01f81!important;}
  html[data-theme='light'] body#top[data-page='play'].phone-match-active .hex-poly:is(.hex-valid,.hex-deploy-valid-p1,.hex-deploy-valid-p2) {fill:#98efd28c!important;stroke:#007d57!important;}
  html[data-theme='light'] body#top[data-page='play'].phone-match-active .hex-poly:is(.hex-selected,.hex-selected-p1,.hex-selected-p2) {stroke:#28143c!important;}
  /* SVG focus uses the hex silhouette, never a rectangular tap outline. */
  body#top[data-page='play'].phone-match-active :is(#board-col,#hex-board,#hex-group g):focus {outline:none!important;}
  body#top[data-page='play'].phone-match-active #hex-group g:focus-visible .hex-poly {stroke:var(--phone-ink)!important;stroke-width:3!important;}
  body#top[data-page='play'].phone-match-active #action-bar-wrapper {inset:calc(12px + var(--phone-safe-top)) 0 auto;height:50px;}
  body#top[data-page='play'].phone-match-active .bar-right {right:calc(var(--phone-controls-end) + 52px);}
  body#top[data-page='play'].phone-match-active .hud-player {height:46px;padding:3px;border-radius:12px;border:1px solid #7a638a!important;background:linear-gradient(180deg,#28143de8,#120b1de8);box-shadow:0 6px 18px #0005;clip-path:none;}
  body#top[data-page='play'].phone-match-active .hp-main {padding-left:calc(var(--phone-portrait) - 11px);gap:3px;}
  body#top[data-page='play'].phone-match-active #hud-p2 .hp-main {padding-left:0;padding-right:calc(var(--phone-portrait) - 11px);}
  body#top[data-page='play'].phone-match-active .hp-name-col {order:1;}
  body#top[data-page='play'].phone-match-active .hp-tokens-slot {order:2;}
  body#top[data-page='play'].phone-match-active .plaque-mascot {width:var(--phone-portrait);height:var(--phone-portrait);left:-9px;right:auto;top:50%;transform:translateY(-50%)!important;opacity:1!important;filter:drop-shadow(0 3px 7px #0008)!important;}
  body#top[data-page='play'].phone-match-active #hud-p2 .plaque-mascot {left:auto;right:-9px;transform:translateY(-50%)!important;}
  body#top[data-page='play'].phone-match-active .hp-name {font:800 clamp(12px,1.9vw,16px)/1.2 Orbitron,sans-serif;letter-spacing:0;color:#f8f3ff;}
  body#top[data-page='play'].phone-match-active .player-identity-label {display:none!important;}
  body#top[data-page='play'].phone-match-active .hp-dot {display:none;}
  body#top[data-page='play'].phone-match-active .hp-pips {gap:4px;}
  body#top[data-page='play'].phone-match-active .pip {width:16px;height:18px;}
  body#top[data-page='play'].phone-match-active .pip:not(.filled) {background:#aa99bf!important;}
  body#top[data-page='play'].phone-match-active .pip:not(.filled)::after {background:#21132f!important;}
  body#top[data-page='play'].phone-match-active[data-phone-active='p1'] #hud-p1 {border-color:var(--phone-azure)!important;box-shadow:0 0 16px #0099ff30,inset 0 0 12px #0099ff20;}
  body#top[data-page='play'].phone-match-active[data-phone-active='p2'] #hud-p2 {border-color:var(--phone-violet)!important;box-shadow:0 0 16px #ff2bb130,inset 0 0 12px #ff2bb120;}
  html[data-theme='light'] body#top[data-page='play'].phone-match-active .hud-player {background:linear-gradient(180deg,#fff4ffed,#e9daf3ed);border-color:#b1a0bd!important;}
  html[data-theme='light'] body#top[data-page='play'].phone-match-active .hp-name {color:var(--phone-ink);}
  html[data-theme='light'] body#top[data-page='play'].phone-match-active .pip:not(.filled) {background:#8b749f!important;}
  html[data-theme='light'] body#top[data-page='play'].phone-match-active .pip:not(.filled)::after {background:#f3e8fa!important;}
  body#top[data-page='play'].phone-match-active .phone-match-status {top:calc(65px + var(--phone-safe-top));left:var(--phone-board-start);width:var(--hud-w);padding:1px 2px;z-index:55;}
  body#top[data-page='play'].phone-match-active[data-phone-active='p2'] .phone-match-status {left:auto;right:var(--phone-controls-end);text-align:right;}
  body#top[data-page='play'].phone-match-active .phone-status-title {font:700 10px/1.35 Orbitron,sans-serif;white-space:nowrap;color:var(--phone-ink);}
  body#top[data-page='play'].phone-match-active .phone-status-prompt {display:none!important;}
  body#top[data-page='play'].phone-match-active .phone-status-compact {display:block;font:600 11px/1.35 Inter,sans-serif;color:var(--phone-muted);}
  body#top[data-page='play'].phone-match-active .phone-action-count {display:inline-flex;gap:3px;margin-right:4px;vertical-align:middle;}
  body#top[data-page='play'].phone-match-active .phone-action-pip {width:5px;height:5px;border-radius:50%;background:var(--phone-muted);opacity:.25;}
  body#top[data-page='play'].phone-match-active .phone-action-pip.available {background:var(--phone-azure);opacity:1;box-shadow:0 0 5px currentColor;}
  body#top[data-page='play'].phone-match-active[data-phone-active='p2'] .phone-action-pip.available {background:var(--phone-violet);}
  body#top[data-page='play'].phone-match-active .phone-reserve-toggle {position:fixed;top:auto!important;bottom:calc(var(--phone-footer-inset) + 48px);width:var(--phone-reserve-width);height:44px;display:flex;justify-content:center;align-items:center;gap:6px;padding:4px;border:1px solid var(--phone-line);border-radius:9px;background:var(--phone-surface);color:var(--phone-ink);font:700 10px/1.2 Orbitron,sans-serif;z-index:56;}
  body#top[data-page='play'].phone-match-active #phone-reserve-p1 {left:var(--phone-board-start);}
  body#top[data-page='play'].phone-match-active #phone-reserve-p2 {right:var(--phone-controls-end);bottom:var(--phone-footer-inset);}
  body#top[data-page='play'].phone-match-active .phone-reserve-count {font-size:13px;}
  body#top[data-page='play'].phone-match-active .phone-reserve-count[hidden] {display:none!important;}
  /* Three original actions occupy the board's tapered empty lower-left corner. */
  body#top[data-page='play'].phone-match-active:not(.combat-active) #action-bar {inset:auto auto var(--phone-footer-inset) var(--phone-board-start);width:140px;height:44px;padding:0;border:0;background:transparent;}
  body#top[data-page='play'].phone-match-active:not(.combat-active) #action-bar .bar-center {display:grid!important;grid-template-columns:repeat(3,44px);grid-template-rows:44px;width:140px;height:44px;gap:4px;}
  body#top[data-page='play'].phone-match-active #action-bar .act-btn {min-width:44px;min-height:44px;padding:3px;border:1px solid var(--phone-line);border-radius:9px;background:linear-gradient(180deg,#2b1841,#170d26);color:var(--phone-ink);box-shadow:0 3px 9px #0004;}
  body#top[data-page='play'].phone-match-active #action-bar .act-text {font:700 10px/1.2 Inter,sans-serif;letter-spacing:0;}
  body#top[data-page='play'].phone-match-active #action-bar .act-btn:disabled {opacity:1!important;color:#a697b5;border-color:#46334f;background:#1d1129;}
  body#top[data-page='play'].phone-match-active #action-bar.ab-p1 .act-btn.act-active {border-color:var(--phone-azure);background:#03476b;color:#e4f7ff;box-shadow:0 0 14px #0099ff25;}
  body#top[data-page='play'].phone-match-active #action-bar.ab-p2 .act-btn.act-active {border-color:var(--phone-violet);background:#5d1649;color:#ffe8f9;box-shadow:0 0 14px #ff2bb125;}
  html[data-theme='light'] body#top[data-page='play'].phone-match-active #action-bar .act-btn {background:linear-gradient(180deg,#fff5ff,#eaddf2);}
  html[data-theme='light'] body#top[data-page='play'].phone-match-active #action-bar .act-btn:disabled {color:#857390;border-color:#c6b7d0;background:#ece0f3;}
  html[data-theme='light'] body#top[data-page='play'].phone-match-active #action-bar .act-btn.act-active {background:#bddaf5;color:#18445c;}
  html[data-theme] body#top[data-page='play'].phone-match-active .site-header .menu-toggle,
  html.site-menu-open body#top[data-page='play'].phone-match-active .site-header .menu-toggle {inset:calc(8px + var(--phone-safe-top)) var(--phone-controls-end) auto auto!important;border:1px solid var(--phone-line)!important;border-radius:10px!important;background:var(--phone-surface)!important;}
  body#top[data-page='play'].phone-match-active:not(.combat-active) #tutorial-banner {inset:auto var(--phone-controls-end) var(--phone-footer-inset) auto;width:var(--phone-reserve-width);max-width:none;transform:none;background:none;pointer-events:none;}
  body#top[data-page='play'].phone-match-active #tutorial-banner .tut-banner-left {display:none!important;}
  body#top[data-page='play'].phone-match-active #btn-tut-continue-step {min-height:44px;width:100%;border-radius:9px;font:700 10px/1.25 Orbitron,sans-serif;padding:7px;border:1px solid var(--phone-azure);background:#03476b;}
  body#top[data-page='play'].phone-match-active #btn-tut-continue-step::before,
  body#top[data-page='play'].phone-match-active #btn-tut-continue-step::after {display:none;}
  body#top[data-page='play'].phone-match-active:has(#btn-tut-continue-step:not([style*='none'])) #phone-reserve-p2 {bottom:calc(var(--phone-footer-inset) + 48px);}
  body#top[data-page='play'].phone-match-active #phone-unit-inspector[open] {background:var(--phone-surface);border-radius:14px;border-width:1px;border-top-width:3px;}
  body#top[data-page='play'].phone-match-active #core-tooltip {display:none;}
  body#top[data-page='play'].phone-match-active #core-tooltip.phone-core-open {display:block;position:fixed;left:50%!important;top:50%!important;transform:translate(-50%,-115%);width:min(290px,calc(100vw - 32px));opacity:1!important;visibility:visible!important;pointer-events:auto!important;padding:16px 56px 16px 16px;border:1px solid #d3b465;border-radius:14px;background:var(--phone-surface);color:var(--phone-ink);z-index:150;}
  body#top[data-page='play'].phone-match-active #core-tooltip .tt-title {color:#e5c673;font:800 14px/1.3 Orbitron,sans-serif;}
  body#top[data-page='play'].phone-match-active #core-tooltip .tt-desc {color:var(--phone-ink);font:500 13px/1.5 Inter,sans-serif;}
  body#top[data-page='play'].phone-match-active .phone-core-close {position:absolute;right:4px;top:4px;width:44px;height:44px;min-width:44px;min-height:44px;border:0;border-radius:8px;background:transparent;color:var(--phone-ink);font-size:26px;}
}
@media (orientation: landscape) and (max-width:1100px) and (max-height:350px) {
  body#top[data-page='play'].phone-match-active {--phone-reserve-top:calc(92px + var(--phone-safe-top));}
  body#top[data-page='play'].phone-match-active .phone-reserve-toggle {bottom:calc(var(--phone-footer-inset) + 48px);height:32px;min-height:32px;border:0;background:transparent;}
  body#top[data-page='play'].phone-match-active #phone-reserve-p2 {height:44px;bottom:var(--phone-footer-inset);}
}
@media (prefers-reduced-motion:reduce) {
  body#top[data-page='play'].phone-match-active #game-screen::before,
  body#top[data-page='play'].phone-match-active #game-screen::after {transition:none;}
}
@media (orientation:landscape) and (max-width:1100px) and (max-height:599px) {
 body#top[data-page='play'].phone-match-active .phone-reserve-toggle,
 body#top[data-page='play'].phone-match-active #phone-reserve-p2,
 body#top[data-page='play'].phone-match-active:has(#btn-tut-continue-step:not([style*='none'])) #phone-reserve-p2 {
  top:calc(12px + var(--phone-safe-top))!important;bottom:auto!important;left:var(--phone-board-start);right:auto;height:46px;min-height:44px;width:var(--hud-w);flex-direction:row;border:0;background:transparent;box-shadow:none;padding:0;color:transparent;
 }
 body#top[data-page='play'].phone-match-active #phone-reserve-p2 {left:auto;right:calc(var(--phone-controls-end) + 52px);}
 body#top[data-page='play'].phone-match-active .phone-reserve-toggle>* {visibility:hidden;}
 body#top[data-page='play'].phone-match-active #hex-board { -webkit-tap-highlight-color:transparent; }
 body#top[data-page='play'].phone-match-active .phone-reserve-markers {align-self:flex-start;}
 body#top[data-page='play'].phone-match-active .stash-p2 .phone-reserve-markers {align-self:flex-end;}
 body#top[data-page='play'].phone-match-active .phone-core-close[hidden] {display:none!important;}
  html[data-theme] body#top[data-page='play'].phone-match-active .site-header .main-nav.open {padding:calc(64px + var(--phone-safe-top)) max(24px,var(--phone-controls-end)) max(20px,var(--phone-footer-inset)) max(24px,var(--phone-board-start))!important;}
  html.site-menu-open body#top[data-page='play'].phone-match-active .site-header .brand {inset:calc(8px + var(--phone-safe-top)) auto auto max(24px,var(--phone-board-start))!important;}
  html.site-menu-open body#top[data-page='play'].phone-match-active .site-header .game-site-mode {inset:calc(23px + var(--phone-safe-top)) auto auto calc(max(24px,var(--phone-board-start)) + 56px);}
  body#top[data-page='play'].phone-match-active :is(#gcm-btn-cancel,#gcm-btn-confirm) {min-height:44px;}
}
