/* Landscape phone layout. Desktop is unchanged: every rule hangs off html.touch-play. */

html.touch-play {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
html.touch-play,
html.touch-play body,
html.touch-play #app {
  position: fixed;
  top: var(--app-top, 0px);
  left: 0;
  width: 100%;
  height: var(--app-h, 100dvh);
  overflow: hidden;
  overscroll-behavior: none;
}
html.touch-play body {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}
html.touch-play input,
html.touch-play select,
html.touch-play textarea {
  font-size: 16px;
  min-height: 36px;
}
html.touch-play .chrome-btn { height: 28px; min-height: 28px; padding: 0 8px; font-size: 10px; }
html.touch-play #btn-status.status-btn,
html.touch-play #btn-lang.lang-btn { width: 28px; min-width: 28px; height: 28px; }
html.touch-play .float-menu button {
  min-height: 44px;
  font-size: 16px;
  padding: 8px 12px;
}

#touch-rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 400;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #100804;
  color: var(--gold-bright);
  text-align: center;
  font-family: var(--ui-display);
  letter-spacing: 0.08em;
  font-size: 22px;
}
html.touch-play.touch-portrait #touch-rotate { display: flex; }
#touch-rotate p { margin: 0; max-width: 16em; }

#touch-home-hint {
  position: fixed;
  z-index: 80;
  left: calc(8px + var(--sal));
  right: calc(8px + var(--sar));
  top: calc(42px + var(--sat));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(20, 12, 6, 0.94);
  border: 1px solid #c4a050;
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}
html.touch-home #screen-hub .hub-grid { margin-top: calc(108px + var(--sat)); }
#touch-home-hint p { margin: 0; flex: 1; }
#touch-home-hint button { width: auto; margin: 0; min-width: 72px; }
html.touch-portrait #touch-home-hint { display: none !important; }

html.touch-play #screen-login,
html.touch-play #screen-post {
  overflow: auto;
  padding: 8px calc(8px + var(--sar)) 8px calc(8px + var(--sal));
}
html.touch-play .login-card {
  width: min(640px, calc(100vw - 20px - var(--sal) - var(--sar)));
  max-height: none;
  border-width: 22px;
  padding: 2px 10px 10px;
}
html.touch-play .crest { width: 52px; height: 52px; margin: 0 auto 2px; }
html.touch-play h1 { font-size: 22px; margin: 2px 0; }
html.touch-play .tagline { margin: 2px 0; font-size: 14px; }
html.touch-play .login-card button.ghost,
html.touch-play #btn-new-account { margin-top: 2px; min-height: 36px; }
html.touch-play #btn-enter,
html.touch-play #btn-post-hub { margin-top: 8px; min-height: 44px; }
html.touch-play .post-stat-grid { grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin: 8px 0; }
html.touch-play .post-stat { padding: 6px 8px; font-size: 13px; }
html.touch-play .stale-banner {
  top: calc(6px + var(--sat));
  width: min(480px, calc(100vw - 16px));
}

html.touch-play .topbar {
  height: 40px;
  padding-left: calc(10px + var(--sal));
  padding-right: calc(8px + var(--sar));
}
html.touch-play #top-actions {
  top: calc(4px + var(--sat));
  right: calc(6px + var(--sar));
  left: auto;
  bottom: auto;
  transform: none;
  z-index: 30;
}
html.touch-play #top-actions.on-match { display: none !important; }
html.touch-play .fs-hint { display: none !important; }
#btn-enter-fullscreen,
#btn-enter-fullscreen-match { display: none; }
html.touch-play:not(.is-fullscreen):not(.touch-standalone) #hub-phone #btn-enter-fullscreen {
  display: flex;
  position: static;
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
  transform: none;
  width: 100%;
  min-height: 44px;
  margin: 0 0 6px;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
#btn-match-gear { display: none; }
html.touch-play.match-open #btn-match-gear {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  z-index: 45;
  top: calc(4px + var(--sat, 0px));
  left: 50%;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: rgba(255, 246, 216, 0.55);
  opacity: 0.72;
  transform: translateX(-50%);
  filter: none;
}
html.touch-play.match-open #btn-match-gear svg {
  width: 18px;
  height: 18px;
  display: block;
  pointer-events: none;
}
html.touch-play.match-open #btn-match-gear:hover,
html.touch-play.match-open #btn-match-gear:active {
  color: rgba(255, 246, 216, 0.92);
  opacity: 0.92;
  filter: none;
  background: transparent;
  box-shadow: none;
}
html.touch-play.match-open #match-clock,
html.touch-play.match-open #boss-bar,
html.touch-play.match-open #race-hud {
  top: calc(34px + var(--sat, 0px)) !important;
}
html.touch-play.match-open:not(.is-fullscreen):not(.touch-standalone) #btn-enter-fullscreen-match {
  display: flex;
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: calc(16px + var(--sab));
  transform: translateX(-50%);
  width: min(200px, 32vw);
  min-height: 40px;
  margin: 0;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

html.touch-play #screen-hub .hub-grid {
  margin-top: calc(40px + var(--sat));
  padding: 6px 8px calc(50px + var(--sab));
  display: grid;
  grid-template-columns: minmax(168px, 34%) minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}
html.touch-play .hub-stage { display: none; }
html.touch-play .hub-rail,
html.touch-play .queue-panel {
  overflow: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
html.touch-play .hub-rail { flex-direction: column; pointer-events: auto; }
html.touch-play .hub-rail > .panel,
html.touch-play .hub-rail > .live-matches-card {
  width: 100%;
  flex: 0 0 auto;
  max-height: none;
}
html.touch-play .panel,
html.touch-play .queue-card {
  border-width: 14px;
  border-image-width: 14px;
  padding: 2px 8px 8px;
}
html.touch-play .queue-card h2,
html.touch-play .panel h2 { margin: 0 0 6px; font-size: 12px; }
html.touch-play .play-modes { grid-template-columns: 1fr 1fr; gap: 8px; }
html.touch-play .class-picks {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 6px;
}
html.touch-play .class-pick { flex: 0 0 64px; padding: 2px; font-size: 11px; }
html.touch-play .class-pick::before { width: 28px; height: 28px; margin-bottom: 2px; }
html.touch-play .class-pick .role { display: none; }
html.touch-play #campaign-hint,
html.touch-play .queue-card .hint { display: none; }
html.touch-play .check { display: flex; align-items: center; gap: 6px; min-height: 28px; }
html.touch-play #hub-dock {
  bottom: calc(4px + var(--sab));
  gap: 4px;
}
html.touch-play .hub-dock-btn { min-width: 72px; min-height: 28px; padding: 4px 8px; font-size: 11px; }
@media (max-width: 700px) {
  html.touch-play #screen-hub .hub-grid {
    grid-template-columns: 1fr;
    overflow: auto;
  }
  html.touch-play .play-modes { grid-template-columns: 1fr; }
}

html.touch-play .wow-frame,
html.touch-play #settings-card,
html.touch-play #settings-card.controls-open,
html.touch-play #stats-card,
html.touch-play #resume-card {
  width: min(920px, calc(100vw - 12px - var(--sal) - var(--sar)));
  max-height: calc(var(--app-h, 100dvh) - 12px - var(--sat) - var(--sab));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
html.touch-play .talent-spec { min-height: 0; padding: 6px; }
html.touch-play .talent-spec-row { grid-template-columns: 1fr 1fr; gap: 8px; }
html.touch-play .wow-frame-x { min-width: 44px; min-height: 44px; }
html.touch-play .settings-tabs button,
html.touch-play .stats-tabs button { min-height: 40px; }
html.touch-play #hud-edit-overlay .wow-frame,
html.touch-play #hud-edit-overlay > div {
  max-height: calc(var(--app-h, 100dvh) - 12px);
  overflow: auto;
}

html.touch-play .lobby-chrome { top: calc(8px + var(--sat)); }
html.touch-play .lobby-roster { flex-wrap: wrap; gap: 8px; padding: 0 8px; }
html.touch-play .lobby-roster button { min-width: 88px; min-height: 44px; }

html.touch-play #screen-match { touch-action: none; }
html.touch-play #screen-match #action-bar,
html.touch-play.match-open #xp-bar,
html.touch-play #combat-meter,
html.touch-play #combat-log,
html.touch-play #match-meta { display: none !important; }
html.touch-play #target-frame { display: none !important; }
html.touch-play .unit-frame {
  width: 128px !important;
  padding: 2px 4px !important;
  gap: 4px !important;
}
html.touch-play .unit-frame .uf-class,
html.touch-play #player-frame .bar.cast { display: none !important; }
html.touch-play .unit-frame .name {
  font-size: 11px;
  line-height: 1.1;
  padding: 0;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html.touch-play .unit-frame .bar { height: 5px; margin-top: 1px; }
html.touch-play .unit-frame .bar.hp {
  height: 14px !important;
  overflow: hidden;
}
html.touch-play .unit-frame .bar.hp > span {
  left: 1px !important;
  right: 1px !important;
  top: 0 !important;
  height: 14px;
  line-height: 14px !important;
  font-size: 11px !important;
  text-align: center !important;
  white-space: nowrap;
}
html.touch-play .uf-port,
html.touch-play #player-frame .uf-port,
html.touch-play #party-frames .uf-port,
html.touch-play #enemy-frames .uf-port {
  width: 14px !important;
  height: 14px !important;
  min-height: 14px !important;
  min-width: 14px !important;
}
html.touch-play .unit-frame.sel {
  border-color: #fff1c0 !important;
  box-shadow: 0 0 0 2px #ffe08a, 0 0 12px rgba(255, 214, 80, 0.95) !important;
}
html.touch-play #player-frame {
  position: absolute !important;
  left: calc(4px + var(--sal)) !important;
  top: calc(2px + var(--sat)) !important;
  width: 128px !important;
  transform: none !important;
}
html.touch-play #party-frames {
  position: absolute !important;
  left: calc(4px + var(--sal)) !important;
  top: 40px !important;
  right: auto !important;
  width: 128px !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  transform: none !important;
}
html.touch-play #enemy-frames {
  position: absolute !important;
  left: auto !important;
  right: calc(4px + var(--sar)) !important;
  top: calc(2px + var(--sat)) !important;
  width: 128px !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  transform: none !important;
}
html.touch-play #party-frames .unit-frame,
html.touch-play #enemy-frames .unit-frame {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  width: 100% !important;
  margin-bottom: 3px !important;
}
html.touch-play #player-auras {
  left: calc(6px + var(--sal)) !important;
  right: auto !important;
  top: 46px !important;
  transform: scale(0.7) !important;
  transform-origin: top left !important;
}
html.touch-play #target-auras,
html.touch-play #target-auras.aura-row.target-auras {
  left: calc(152px + var(--sal)) !important;
  top: 46px !important;
  transform: scale(0.7) !important;
  transform-origin: top left !important;
}
html.touch-play #cast-bar {
  left: 50% !important;
  right: auto !important;
  top: auto !important;
  bottom: calc(92px + var(--sab)) !important;
  width: min(240px, 34vw) !important;
  padding: 3px 6px !important;
  gap: 6px !important;
  z-index: 12 !important;
  transform: translateX(-50%) !important;
}
html.touch-play #cast-bar .cast-icon { width: 20px !important; height: 20px !important; }
html.touch-play #cast-bar .cast-name { font-size: 12px; margin: 0 0 2px; }
html.touch-play #cast-bar .cast-track { height: 10px; }
html.touch-play #cast-bar .cast-time { width: 28px; font-size: 12px; }
html.touch-play #target-cast-bar {
  left: 50% !important;
  top: calc(78px + var(--sat)) !important;
  width: min(230px, 30vw) !important;
  padding: 3px 6px !important;
  gap: 6px !important;
  z-index: 12 !important;
  transform: translateX(-50%) !important;
}
html.touch-play #target-cast-bar .cast-icon { width: 20px !important; height: 20px !important; }
html.touch-play #target-cast-bar .cast-name { font-size: 12px; margin: 0 0 2px; }
html.touch-play #target-cast-bar .cast-track { height: 9px; }
html.touch-play #target-cast-bar .cast-time { width: 28px; font-size: 12px; }
/* Party and enemy frames: the cast bar takes the power bar's place while they cast. */
html.touch-play .unit-frame .bar.cast { height: 5px; margin-top: 1px; }
html.touch-play .unit-frame .bar.cast > span { display: none; }
html.touch-play .unit-frame .bar.power:has(+ .bar.cast:not(.hidden)) { display: none; }
html.touch-play #boss-bar,
html.touch-play #match-clock,
html.touch-play #race-hud {
  left: 50% !important;
  top: calc(6px + var(--sat)) !important;
  transform: translateX(-50%) !important;
}
html.touch-play #race-place { font-size: 20px; }
/* The tutorial's phone layout lives in tutorial-touch.css. */
html.touch-play #screen-match.ascent-play #combat-log,
html.touch-play #screen-match.ascent-play #combat-meter,
html.touch-play #screen-match.ascent-play #touch-spells { display: none !important; }

#touch-controls { display: none; }
html.touch-play #touch-controls {
  display: block;
  position: static;
  inset: auto;
  z-index: auto;
  pointer-events: none;
}
html.touch-play #screen-match.spectating #touch-controls { display: none !important; }
#touch-look {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: auto;
  touch-action: none;
}
#touch-stick {
  position: fixed;
  z-index: 50;
  left: 0;
  top: 0;
  width: calc(112px * var(--touch-scale, 1));
  height: calc(112px * var(--touch-scale, 1));
  margin: 0;
  opacity: 0;
  pointer-events: none;
  touch-action: none;
}
#touch-stick.live { opacity: 0.95; }
/* A fixed stick waits in its corner, dimmed. */
html.touch-stick-fixed #touch-stick.parked { opacity: 0.5; }
html.touch-stick-fixed #touch-stick.live { opacity: 0.95; }
.stick-base,
.stick-knob {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.stick-base {
  inset: 8%;
  background: radial-gradient(circle at 50% 45%, rgba(40, 28, 16, 0.55), rgba(8, 5, 3, 0.72));
  border: 2px solid rgba(224, 192, 120, 0.85);
  box-shadow: inset 0 0 0 1px #1a1008, 0 8px 18px rgba(0, 0, 0, 0.45);
}
.stick-knob {
  width: 42%;
  height: 42%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 40% 35%, #ffe7b0, #c4a050 55%, #6a4a18);
  border: 2px solid #1a1008;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
}
html.touch-swap #touch-right {
  right: auto;
  left: calc(6px + var(--sal));
  /* Mirrored from its left edge, then slid back on screen. */
  transform-origin: 0 100%;
  transform: translateX(calc(100% * var(--touch-scale, 1))) scale(calc(-1 * var(--touch-scale, 1)), var(--touch-scale, 1));
}
html.touch-swap #touch-jump .jump-mark,
html.touch-swap #touch-jump .jump-word,
html.touch-swap .touch-spell .touch-ico,
html.touch-swap .touch-spell .touch-cd {
  transform: scaleX(-1);
}
#touch-right {
  position: fixed;
  z-index: 50;
  right: calc(6px + var(--sar));
  bottom: calc(6px + var(--sab));
  /* Button size (Settings, Phone) grows the arc from its corner. */
  transform-origin: 100% 100%;
  transform: scale(var(--touch-scale, 1));
  width: 132px;
  height: 132px;
  pointer-events: none;
  touch-action: none;
}
#touch-spells {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
}
html.touch-play .touch-spell {
  position: absolute;
  width: 44px;
  height: 44px;
  min-height: 44px;
  min-width: 44px;
  pointer-events: auto;
  margin: 0;
  padding: 0;
  border-radius: 12px;
  border: 2px solid #e6c878;
  background: #140e08;
  box-shadow: 0 3px 0 #1a1008, inset 0 1px 0 rgba(255, 230, 170, 0.25);
  touch-action: none;
  overflow: hidden;
}
.touch-spell .touch-ico { position: absolute; inset: 3px; display: flex; align-items: center; justify-content: center; }
.touch-spell .touch-ico img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; pointer-events: none; }
.touch-spell .touch-cd {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 16px "Arial Narrow", Arial, sans-serif;
  color: #ffe068;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
  pointer-events: none;
}
.touch-spell.cd .touch-ico { filter: brightness(0.45); }
.touch-spell.oor .touch-ico { filter: grayscale(1) sepia(1) saturate(6) hue-rotate(-38deg) brightness(0.65); }
.touch-spell.oom .touch-ico { filter: grayscale(0.85) sepia(1) hue-rotate(175deg) saturate(3) brightness(0.55); }
.touch-spell.aiming { box-shadow: 0 0 0 2px #fff1c0, 0 0 12px rgba(255, 220, 120, 0.7); }
.touch-spell.pressed { transform: scale(0.94); }
/* Its size comes from S.touchArcSlots (client-mobile-arc.js). */
#touch-jump {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 112px;
  height: 112px;
  min-width: 112px;
  min-height: 112px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  pointer-events: auto;
  background: linear-gradient(180deg, #d4b060 0%, #a07830 42%, #6a4a16 56%, #3e2a0c 100%);
  color: #fff6d8;
  border-color: #f0d48a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  letter-spacing: 0.06em;
  font-size: 12px;
  line-height: 1;
  touch-action: none;
  box-shadow:
    0 4px 0 #1a1208,
    0 0 0 3px rgba(90, 60, 16, 0.9),
    inset 0 1px 0 rgba(255, 240, 200, 0.55);
}
#touch-jump .jump-mark { font-size: 26px; line-height: 1; pointer-events: none; }
#touch-jump .jump-word { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; pointer-events: none; }
#touch-jump.pressed { transform: scale(0.96); }
/* The Ascent has no spells: Jump alone takes the corner. */
html.touch-play #screen-match.ascent-play #touch-jump {
  width: 132px !important;
  height: 132px !important;
  min-width: 132px !important;
  min-height: 132px !important;
}
html.touch-play #screen-match.ascent-play #touch-jump .jump-mark { font-size: 30px; }
html.touch-play #screen-match.ascent-play #touch-jump .jump-word { font-size: 12px; }
html.touch-play #screen-match.ascent-play #touch-spells { display: none !important; }
