/* MAGIC: The Anomaly — phone HUD declutter layer.
   Every rule is scoped to html.wx-touch, the class the game's own touch layer
   sets, so keyboard and mouse players see no change. Remove this file to roll back. */

/* loading screen: the title ran off the left edge in portrait */
@media (pointer: coarse) {
  #load .title{text-align:center;padding:0 16px;font-size:min(64px,8.4vw)}
}

html.wx-touch{--mx-top:max(10px,env(safe-area-inset-top));--mx-l:calc(env(safe-area-inset-left) + 12px);--mx-r:calc(env(safe-area-inset-right) + 12px)}

/* 1. a phone cannot be its own controller: drop the pairing button and panel */
html.wx-touch [data-feel="phone"]{display:none!important}

/* 2. text written for a keyboard, and panels that repeat each other */
html.wx-touch .anomaly-status,
html.wx-touch .magic-mission,
html.wx-touch .snap-power-hud p,
html.wx-touch .eclipse-power-hud p,
html.wx-touch .eclipse-power-hud .power-controls,
html.wx-touch .style-chip i,
html.wx-touch .magic-guide small,
html.wx-touch .magic-guide .g-how,
html.wx-touch .magic-guide .g-dots,
html.wx-touch .meridian-tutorial__eyebrow,
html.wx-touch .meridian-tutorial__footer kbd{display:none!important}

/* Keep the complete objective under the action bar, including during rotation. */
html.wx-touch .magic-guide:not([hidden]) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 8px;
}
html.wx-touch .magic-guide {
  top: calc(var(--mx-top) + 50px) !important;
  bottom: auto !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  width: min(410px, 48vw) !important;
  min-width: 0 !important;
  box-sizing: border-box;
  padding: 4px 10px !important;
  /* World labels move with the camera. Keep them behind the objective. */
  z-index: 20;
  background: #121a1c !important;
  border: 0 !important;
  border-radius: 6px;
}
html.wx-touch .magic-guide h2 { font: 700 11px/1.3 Arial,sans-serif; letter-spacing: .06em; margin: 0; }
html.wx-touch .magic-guide .g-text { grid-column: 1 / -1; font: 11px/1.3 Arial,sans-serif; margin: 0; overflow-wrap: anywhere; }
html.wx-touch .magic-guide .g-foot { grid-column: 2; grid-row: 1; margin: 0; }
html.wx-touch .magic-guide .g-btn { position: relative; padding: 3px 7px; font-size: 10px; }
html.wx-touch .magic-guide .g-btn::after { content: ""; position: absolute; inset: -4px -3px -12px; }

/* 4. tutorial: a compact translucent note in the same slot; it wins the slot while it is up */
html.wx-touch .meridian-tutorial{left:50%!important;right:auto!important;transform:translateX(-50%);top:calc(var(--mx-top) + 50px)!important;bottom:auto!important;
  width:min(330px,48vw)!important;max-height:none!important;overflow:visible!important;box-sizing:border-box;padding:6px 12px 7px!important;
  background:rgba(4,14,20,.64)!important;border-color:#b9a86a40!important;box-shadow:none!important;letter-spacing:.02em}
html.wx-touch .meridian-tutorial h2{font-size:12px!important;margin:0 0 2px!important}
html.wx-touch .meridian-tutorial__objective{font-size:11.5px;line-height:1.3}
html.wx-touch .meridian-tutorial__hint{font-size:10px!important;line-height:1.3;margin-top:2px!important}
html.wx-touch .meridian-tutorial__footer{position:absolute;right:6px;top:2px;margin:0!important}
html.wx-touch .meridian-tutorial h2{padding-right:64px}
html.wx-touch .meridian-tutorial button{min-height:28px;padding:4px 8px}
html.wx-touch #hud:has(.meridian-tutorial:not([hidden])) .magic-guide{display:none!important}

/* 5. Eclipse and Forge meters: a slim gauge under the health bar */
html.wx-touch .eclipse-power-hud{left:var(--mx-l)!important;right:auto!important;transform:none!important;top:calc(env(safe-area-inset-top) + 84px)!important;bottom:auto!important;
  width:148px!important;box-sizing:border-box;padding:4px 8px 5px!important;background:rgba(3,14,20,.4)!important;border-color:transparent!important;
  box-shadow:none!important;font-size:8px!important;letter-spacing:.08em!important}
html.wx-touch .eclipse-power-hud.super-ready{border-color:#ffd27a88!important}
html.wx-touch .eclipse-power-hud .power-status{font-size:0}
html.wx-touch .eclipse-power-hud .power-heading{line-height:1.2}
html.wx-touch .eclipse-power-hud .eclipse-icon{width:8px;height:8px;margin-right:5px;vertical-align:-1px}
html.wx-touch .eclipse-power-hud .power-track{margin:3px 0 4px!important}
html.wx-touch .eclipse-power-hud .forge-row{margin:0!important}
html.wx-touch .eclipse-power-hud .forge-row .fh{font-size:8px;line-height:1.2}
html.wx-touch .eclipse-power-hud .forge-row .ft{margin-top:2px;height:3px}

/* 5b. short status notes ("recovery paused") go to the bottom centre, under the hero's feet */
html.wx-touch .feel-status{top:auto!important;bottom:max(8px,env(safe-area-inset-bottom))!important;left:50%!important;transform:translateX(-50%)!important;font-size:9px;opacity:.85;white-space:nowrap}

/* 6. snap actions sat on top of GUARD and FIRE: move them to the left edge */
html.wx-touch .snap-power-hud{left:var(--mx-l)!important;right:auto!important;top:calc(env(safe-area-inset-top) + 134px)!important;bottom:auto!important;width:auto!important;z-index:26}
html.wx-touch .snap-actions button{min-height:40px;background:rgba(16,26,32,.6)}

/* 7. top action bar and style chip stay, but lighter */
html.wx-touch .feel-touch .feel-btn{background:rgba(3,14,20,.5);border-color:#b19d6a55}
html.wx-touch .style-chip{background:rgba(3,14,20,.45)!important;border-color:transparent!important;right:var(--mx-r)!important}

/* 8. the text toggle was drawn under the pause button: icon only, in the free gap beside it */
html.wx-touch .hud-toggle{top:calc(var(--mx-top) + 4px)!important;left:auto!important;right:calc(env(safe-area-inset-right) + 70px)!important;transform:none!important;
  width:36px;height:36px;padding:0!important;border-radius:50%;font-size:0!important;background:rgba(3,14,20,.5)!important;opacity:.8}
html.wx-touch .hud-toggle::before{content:"◐";font:16px/36px Arial,sans-serif;color:#e9e1cb}
html.wx-touch .hud-toggle[aria-pressed="true"]::before{content:"◑"}
html.wx-touch #hud.hud-minimal .magic-guide,
html.wx-touch #hud.hud-minimal .eclipse-power-hud,
html.wx-touch #hud.hud-minimal .style-chip{display:none!important}

/* 9. title screen on a short landscape phone: the tagline, premise and start button were stacked on each other */
@media (orientation:landscape) and (max-height:500px){
  html.wx-touch .wx .title .en,
  html.wx-touch .wx .title .edition{display:none!important}
  html.wx-touch .wx .title .col{top:6vh!important;left:calc(env(safe-area-inset-left) + 7vw)!important;max-width:44vw}
  html.wx-touch .wx .title .col .tg{font-size:9px!important}
  html.wx-touch .wx .title .col .tt{font-size:clamp(30px,11.5vh,46px)!important;line-height:1!important;margin-top:8px!important}
  html.wx-touch .wx .title .col .premise{font-size:12px!important;line-height:1.4!important;margin-top:10px!important;max-width:300px}
  html.wx-touch .wx .title .go{left:calc(env(safe-area-inset-left) + 7vw)!important;right:auto!important;bottom:7vh!important;padding:10px 18px!important;justify-content:flex-start!important}
  html.wx-touch .wx .title .go div.t b{font-size:13px!important;letter-spacing:.3em!important;padding-left:0!important}
  html.wx-touch .wx .title .go div.t i{font-size:11px!important;letter-spacing:.2em!important;margin-top:5px!important}
  html.wx-touch .feel-title{width:min(440px,48vw)!important;left:auto!important;right:calc(env(safe-area-inset-right) + 12px)!important;align-items:flex-end!important}
  html.wx-touch .feel-title .feel-btn{min-height:34px;padding:6px 10px;font-size:11px}
}

/* The browser bars can shorten the portrait viewport mid-session. Keep the
   story and mode choices in document flow and let the title itself scroll. */
@media (orientation: portrait) {
  html.wx-touch .wx .touch-title-menu {
    inset: calc(var(--mx-top) + 28px) 0 0;
    padding: clamp(8px, 3vh, 30px) var(--mx-r) max(16px, env(safe-area-inset-bottom)) var(--mx-l);
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    background: linear-gradient(90deg, rgba(3,13,15,.82), rgba(3,13,15,.30));
  }
  html.wx-touch .wx[data-state="title"] .touch-title-menu.on { pointer-events: auto; }
  html.wx-touch .wx .touch-title-menu :is(.go, .shade) { display: none; }
  html.wx-touch .wx .touch-title-menu .col {
    position: relative;
    inset: auto;
    max-width: 35rem;
    margin: 0 auto 18px;
    padding-inline: 8px;
  }
  html.wx-touch .wx .touch-title-menu .col .tt {
    font-size: clamp(36px, 10.5vw, 60px);
    margin: 12px 0;
  }
  html.wx-touch .wx .touch-title-menu .feel-title {
    position: relative;
    inset: auto;
    align-items: stretch;
    width: min(100%, 35rem);
    margin-inline: auto;
  }
  html.wx-touch .touch-title-menu .feel-row { justify-content: center; }
  html.wx-touch .touch-title-menu .first-time { grid-column: 1 / -1; }
  html.wx-touch .touch-title-menu .feel-row:first-child {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
html.wx-touch .feel-help .card { box-sizing: border-box; touch-action: pan-y; overscroll-behavior: contain; }

/* 10. portrait: the action bar covered the health bar and the pause button. Stack the rows instead. */
@media (orientation:portrait){
  /* Keep orientation guidance above the title and the mission view clear. */
  html.wx-touch .wx.touch.portrait .wxrot { display: none; }
  html.wx-touch .wx.touch.portrait[data-state="title"] .wxrot {
    display: block;
    top: max(8px, env(safe-area-inset-top));
  }
  html.wx-touch .wx.touch.portrait .wxrot :is(.ph, em),
  html.wx-touch .wx.touch.portrait .wxrot::before,
  html.wx-touch .wx .title :is(.en, .edition) { display: none; }

  html.wx-touch .feel-touch{top:calc(var(--mx-top) + 56px)!important}
  html.wx-touch .style-chip{top:calc(var(--mx-top) + 108px)!important}
  html.wx-touch .eclipse-power-hud{top:calc(var(--mx-top) + 108px)!important}
  html.wx-touch .magic-guide,
  html.wx-touch .meridian-tutorial{top:calc(var(--mx-top) + 164px)!important}
  html.wx-touch .magic-guide{width:min(410px,calc(100% - var(--mx-l) - var(--mx-r)))!important}
  html.wx-touch .meridian-tutorial{width:min(330px,calc(100vw - 24px))!important}
  html.wx-touch .snap-power-hud{top:calc(var(--mx-top) + 232px)!important}
}

/* Demo owns a different objective card than Mission. Give it the same space
   beneath the controls and keep its narrator separate from the action bar. */
html.wx-touch .demo-card {
  box-sizing: border-box;
  left: 50%;
  top: calc(var(--mx-top) + 56px);
  transform: translateX(-50%);
  width: min(410px, 48vw);
  padding: 4px 10px;
  z-index: 20;
  background: #121a1c;
  border: 0;
  border-radius: 6px;
  letter-spacing: normal;
}
html.wx-touch .demo-card small { float: right; margin-left: 8px; line-height: 15px; }
html.wx-touch .demo-card h2 { margin: 0; font: 700 12px/1.3 Arial,sans-serif; }
html.wx-touch .demo-card .obj { clear: both; font: 11px/1.3 Arial,sans-serif; }
html.wx-touch #hud.demo-on .demo-card .hint { display: block !important; margin: 2px 0 0; font: 11px/1.3 Arial,sans-serif; }
html.wx-touch .demo-card .dots { display: none; }
html.wx-touch #hud.demo-on .demo-line {
  top: auto;
  bottom: max(26px, env(safe-area-inset-bottom));
  width: min(38%, 28rem);
  padding: 4px 8px;
  font-size: 11px;
}
@media (orientation: portrait) {
  html.wx-touch .demo-card {
    top: calc(var(--mx-top) + 164px);
    width: min(410px, calc(100% - var(--mx-l) - var(--mx-r)));
  }
  html.wx-touch #hud.demo-on .snap-power-hud { top: auto !important; bottom: 25% !important; }
  html.wx-touch #hud.demo-on .demo-line { bottom: 36%; width: min(86%, 25rem); }
}

/* Guided practice. The underlying controls and their bindings stay the same.
   Once practice ends, its attributes are removed and the regular HUD returns. */
html.wx-touch #hud[data-training-stage] :is(.snap-power-hud, .snap-target-label, .portal-label, .portal-prompt, .danger-prompt, .forge-row, .feel-status),
html.wx-touch #hud[data-training-stage] .feel-touch :is([data-feel="help"], [data-feel="super"], [data-feel="forge"], [data-feel="portal"]),
html.wx-touch #hud[data-training-stage]:not([data-training-tools~="lock"]) [data-a="lock"],
html.wx-touch #hud[data-training-stage]:not([data-training-tools~="guard"]) [data-a="block"],
html.wx-touch #hud[data-training-stage]:not([data-training-tools~="dodge"]) [data-a="dodge"],
html.wx-touch #hud[data-training-stage]:not([data-training-tools~="fire"]) [data-a="fire"],
html.wx-touch #hud[data-training-stage]:not([data-training-tools~="style"]) :is(.style-chip, .feel-touch [data-feel="cycle"]),
html.wx-touch #hud[data-training-stage]:not([data-training-tools~="element"]) .feel-touch [data-feel="element"],
html.wx-touch #hud[data-training-stage]:not([data-training-tools~="special"]) .feel-touch [data-feel="special"],
html.wx-touch #hud[data-training-stage]:not([data-training-tools~="eclipse"]) :is(.eclipse-power-hud, [data-a="eclipse"]),
html.wx-touch #hud[data-training-stage]:not([data-training-tools~="teleport"]) .feel-touch [data-feel="snap"],
html.wx-touch #hud[data-training-stage]:not([data-training-tools~="flight"]) .feel-touch [data-feel="flight"],
html.wx-touch #hud[data-training-stage]:not([data-training-tools~="flight"]) [data-a="draw"] {
  display: none !important;
}
/* With the power bar still hidden, the opening instruction fits directly
   below the health meter. Leave the player and the opponent in view. */
html.wx-touch #hud[data-training-stage]:not([data-training-tools~="style"]) .meridian-tutorial {
  top: calc(var(--mx-top) + 58px) !important;
}
html.wx-touch #hud[data-training-stage="sword"] [data-a="light"] b,
html.wx-touch #hud[data-training-stage="block"] [data-a="block"] b,
html.wx-touch #hud[data-training-stage="dodge"] [data-a="dodge"] b {
  color: #ffdf83;
  text-shadow: 0 0 6px #241b09;
}
html.wx-touch #hud[data-training-stage] .meridian-tutorial {
  background: #101a1d !important;
  padding: 8px 12px !important;
}
html.wx-touch #hud[data-training-stage] .meridian-tutorial__objective { font-size: 13px; }
html.wx-touch #hud[data-training-stage] .meridian-tutorial__hint { font-size: 12px !important; }
html.wx-touch #hud[data-training-stage] [data-tutorial="skip"] {
  min-width: 44px;
  min-height: 36px;
  font-size: 12px;
}

.training-target {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 2px 6px;
  border-radius: 3px;
  background: #162324;
  color: #f8e7bc;
  font: 600 11px/1.35 Arial, sans-serif;
  white-space: nowrap;
  pointer-events: none;
}
.training-target span:not([hidden]) { display: inline-block; margin-right: 4px; }
/* Keep the two fighters in the middle visible while the player reads the cue. */
@media (orientation: landscape) and (max-height: 540px) {
  html.wx-touch #hud[data-training-stage]:not([data-training-tools~="style"]) .meridian-tutorial {
    left: var(--mx-l) !important;
    transform: none;
    width: min(32vw, 300px) !important;
  }
}
html.wx-touch #hud[data-training-stage] .meridian-tutorial { pointer-events: none; }
html.wx-touch #hud[data-training-stage] .meridian-tutorial button { pointer-events: auto; }
