/* Shared match feedback: readable faction colours, control-zone warnings and
   a stable mobile HUD. This layer follows the responsive layout sheets. */
body#top[data-page='play'] {
  --match-azure:#00b6ff; --match-violet:#ff48ba;
  --match-ink:#f8f3ff; --match-muted:#c5b7d2;
}
html[data-theme='light'] body#top[data-page='play'] {
  --match-azure:#006c9d; --match-violet:#9c2475;
  --match-ink:#30213e; --match-muted:#62516f;
}

/* Four occupied control hexes warn of dominion before the next turn. Keep
   legal destinations and selections distinct from this persistent warning. */
body#top[data-page='play'] .hex-poly.hex-cz-anticipation-p1 { --dominion-colour:var(--match-azure); }
body#top[data-page='play'] .hex-poly.hex-cz-anticipation-p2 { --dominion-colour:var(--match-violet); }
html[data-theme] body#top[data-page='play'] .hex-poly:is(.hex-cz-anticipation-p1,.hex-cz-anticipation-p2):not(.hex-valid,.hex-attack,.hex-selected,.hex-deploy-valid-p1,.hex-deploy-valid-p2) {
  fill:color-mix(in srgb,var(--dominion-colour) 30%,transparent)!important;
  stroke:var(--dominion-colour)!important;
  stroke-width:2.5px!important;
  animation:dominion-beacon 2s ease-in-out infinite!important;
}
@keyframes dominion-beacon {
  0%,100% { filter:drop-shadow(0 0 3px var(--dominion-colour)); }
  50% { filter:drop-shadow(0 0 8px var(--dominion-colour)); }
}
@media(prefers-reduced-motion:reduce) {
  html[data-theme] body#top[data-page='play'] .hex-poly:is(.hex-cz-anticipation-p1,.hex-cz-anticipation-p2):not(.hex-valid,.hex-attack,.hex-selected,.hex-deploy-valid-p1,.hex-deploy-valid-p2) {
    animation:none!important; filter:drop-shadow(0 0 4px var(--dominion-colour));
  }
}

/* Light surfaces use faction ink, rather than the automatic white-to-black
   conversion used by the original theme. Both combat sides stay readable. */
html[data-theme='light'] body#top[data-page='play'] #stash-panel-p1 { --battle-ink:var(--match-azure); }
html[data-theme='light'] body#top[data-page='play'] #stash-panel-p2 { --battle-ink:var(--match-violet); }
html[data-theme='light'] body#top[data-page='play'] .combat-stash-content :is(.cb-role-badge,.csp-unit,.bg3-face-text,.bg3-boost-num,.bg3-final-boost,.bg3-prompt-text,.fht-text) {
  color:var(--battle-ink)!important; text-shadow:none!important;
}
html[data-theme='light'] body#top[data-page='play'] .combat-stash-content :is(.bg3-die-face-content svg,.bg3-final-symbol svg) {
  color:var(--battle-ink)!important; fill:var(--battle-ink)!important;
  filter:drop-shadow(0 2px 8px color-mix(in srgb,var(--battle-ink) 18%,transparent));
}
html[data-theme='light'] body#top[data-page='play'] .combat-stash-content .combat-matrix-cell {
  background:linear-gradient(155deg,color-mix(in srgb,var(--battle-ink) 7%,#fff),#faf6fd)!important;
  border-color:color-mix(in srgb,var(--battle-ink) 30%,transparent)!important;
}
html[data-theme='light'] body#top[data-page='play'] .combat-stash-content .bg3-prompt-badge {
  background:#fffafc!important; border-color:color-mix(in srgb,var(--battle-ink) 45%,transparent)!important;
}
html[data-theme='light'] body#top[data-page='play'] .combat-stash-content .bg3-effect-text {
  color:var(--match-muted)!important; text-shadow:none!important;
}
html[data-theme='light'] body#top[data-page='play'] .combat-stash-content .bg3-final-boost {
  text-shadow:0 2px 12px color-mix(in srgb,var(--battle-ink) 20%,transparent)!important;
}
html[data-theme='light'] body#top[data-page='play'] #game-screen > .row-popup { color:var(--match-ink); }
/* An opponent's die is informational rather than disabled content. Its waiting
   label should remain legible, including while the other player is rolling. */
body#top[data-page='play'] .bg3-battle-die-widget.cannot-roll:not(.is-locked),
body#top[data-page='play'] .bg3-battle-die-widget.cannot-roll:not(.is-locked) .bg3-prompt-badge {
  opacity:1; cursor:default;
}
html[data-theme='light'] body#top[data-page='play'] :is(#core-ready-status,#core-accept-countdown,#combat-accept-countdown) {
  color:var(--match-muted)!important;
}
html[data-theme='light'] body#top[data-page='play'] #core-modal-title { color:#866019!important; text-shadow:none; }
html[data-theme='light'] body#top[data-page='play'] #ftue-welcome-modal .preloader-logo-container { filter:brightness(.3); }

@media(orientation:landscape) and (max-width:1100px) and (max-height:599px) {
  /* Only the plaque surface is trimmed under the portrait. Clipping the HUD
     itself would clip the oversized die and its glow as well. */
  html[data-theme] body#top[data-page='play'].phone-match-active :is(#hud-p1,#hud-p2) {
    isolation:isolate; background:transparent!important; border-color:transparent!important; box-shadow:none!important;
  }
  body#top[data-page='play'].phone-match-active .hud-player::before {
    content:''; position:absolute; inset:-1px; z-index:-1; pointer-events:none;
    border:1px solid var(--phone-line); border-radius:12px;
    background:linear-gradient(180deg,color-mix(in srgb,var(--phone-surface) 92%,transparent),var(--phone-field));
  }
  body#top[data-page='play'].phone-match-active #hud-p1::before { clip-path:inset(0 0 0 calc(var(--phone-portrait) / 2 + 6px)); }
  body#top[data-page='play'].phone-match-active #hud-p2::before { clip-path:inset(0 calc(var(--phone-portrait) / 2 + 6px) 0 0); }
  body#top[data-page='play'].phone-match-active[data-phone-self='p2'] #hud-p1::before { clip-path:inset(0 calc(var(--phone-portrait) / 2 + 6px) 0 0); }
  body#top[data-page='play'].phone-match-active[data-phone-self='p2'] #hud-p2::before { clip-path:inset(0 0 0 calc(var(--phone-portrait) / 2 + 6px)); }
  body#top[data-page='play'].phone-match-active .hud-player.active::before {
    border:2px solid var(--phone-turn-accent);
    background:linear-gradient(140deg,color-mix(in srgb,var(--phone-turn-accent) 25%,var(--phone-surface)),color-mix(in srgb,var(--phone-turn-accent) 9%,var(--phone-surface)));
    box-shadow:inset 0 0 20px color-mix(in srgb,var(--phone-turn-accent) 30%,transparent);
  }
  body#top[data-page='play'].phone-match-active .hud-player:not(.active) {
    opacity:.78; filter:saturate(.75);
  }
  body#top[data-page='play'].phone-match-active .hud-player.active .plaque-mascot {
    filter:drop-shadow(0 0 12px color-mix(in srgb,var(--phone-turn-accent) 55%,transparent));
  }
  body#top[data-page='play'].phone-match-active:not(.combat-active)[data-phone-active='p1'] #stash-panel-p2,
  body#top[data-page='play'].phone-match-active:not(.combat-active)[data-phone-active='p2'] #stash-panel-p1 {
    opacity:.78;
  }
  body#top[data-page='play'].phone-match-active .phone-status-title {
    font-size:10px; font-weight:800;
    color:var(--phone-turn-accent); text-shadow:0 0 10px color-mix(in srgb,var(--phone-turn-accent) 30%,transparent);
  }
  body#top[data-page='play'].phone-match-active:not(.combat-active):has(.popup-observer) #phone-reference-toggle { visibility:visible; }
  body#top[data-page='play'].phone-match-active #online-turn-status-banner.my-turn[style*='flex'] {
    left:calc(var(--phone-player-left) + var(--phone-portrait) - var(--phone-player-inset)); right:auto;
  }
  body#top[data-page='play'].phone-match-active #online-turn-status-banner.opp-turn[style*='flex'] {
    left:auto; right:calc(var(--phone-player-right) + var(--phone-portrait) - var(--phone-player-inset));
  }
  body#top[data-page='play'].phone-match-active #online-turn-status-banner[style*='flex'] {
    top:calc(var(--phone-player-top) + var(--phone-hud-height) + 2px)!important;
    width:calc(var(--hud-w) - var(--phone-portrait) + var(--phone-player-inset) - 4px);
    max-width:none; height:3px; min-height:3px;
  }
  html[data-theme='light'] body#top[data-page='play'].phone-match-active .hex-poly.hex-mid { stroke:#897699!important; }
  html[data-theme='light'] body#top[data-page='play'].phone-match-active .phone-status-title { text-shadow:none; }
  html[data-theme='light'] body#top[data-page='play'].phone-match-active #core-tooltip .tt-title { color:#866019; }
  /* The choice text sits on dark faction buttons in both themes. */
  html[data-theme='light'] body#top[data-page='play'].phone-match-active #evade-decision-container .btn { color:#fff7ff!important; }
  /* The shared short-screen bag rule otherwise replaces the arena's safe-area
     padding with 16px, putting its close control in Safari's unsafe edge. */
}
/* Unavailable deployment still explains itself on touch and keyboard. */
body#top[data-page='play'] #act-deploy.deploy-blocked {
  opacity: .38 !important;
  filter: saturate(.25);
  cursor: not-allowed;
  box-shadow: none !important;
  animation: none !important;
}
body#top[data-page='play'] .die-chip.deploy-blocked { cursor: not-allowed; }
body#top[data-page='play'] .deploy-unavailable-tooltip {
  --notice-safe-left: env(safe-area-inset-left, 0px);
  --notice-safe-right: env(safe-area-inset-right, 0px);
  --notice-safe-top: env(safe-area-inset-top, 0px);
  --notice-safe-bottom: env(safe-area-inset-bottom, 0px);
  position: fixed;
  z-index: 100010;
  box-sizing: border-box;
  width: min(280px, calc(100vw - var(--notice-safe-left) - var(--notice-safe-right) - 16px));
  padding: 14px 16px;
  border: 1px solid var(--phone-line, #79658b);
  border-radius: 10px;
  background: var(--phone-surface, #21142e);
  color: var(--phone-ink, #f8f3ff);
  box-shadow: 0 8px 28px #0004;
  font: 500 13px/1.5 Inter, sans-serif;
  pointer-events: none;
}
html[data-theme='light'] body#top[data-page='play'] .deploy-unavailable-tooltip { background: var(--phone-surface, #faf4ff); color: var(--phone-ink, #2a183b); }
