@font-face {
  font-family: "Rajdhani";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/critical/fonts/Rajdhani/Rajdhani-Bold.ttf") format("truetype");
}

@font-face {
  font-family: "Rajdhani";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/critical/fonts/Rajdhani/Rajdhani-SemiBold.ttf") format("truetype");
}

@font-face {
  font-family: "Lilita One";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/critical/fonts/Lilita_One/LilitaOne-Regular.ttf") format("truetype");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/critical/fonts/Inter/static/Inter_18pt-Medium.ttf") format("truetype");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/assets/critical/fonts/JetBrains_Mono/JetBrainsMono-VariableFont_wght.ttf") format("truetype");
}

:root {
  color-scheme: dark;
  --ink: #edf4ee;
  --muted: #9faea7;
  --panel: rgba(10, 16, 20, 0.82);
  --panel-strong: rgba(12, 20, 25, 0.94);
  --line: rgba(255, 255, 255, 0.13);
  --accent: #7ee0b8;
  --accent-2: #e9b35f;
  --danger: #f07c63;
  --shadow: rgba(0, 0, 0, 0.35);
  --font-heading: "Rajdhani";
  --font-label: "Rajdhani";
  --font-display: "Lilita One";
  --font-copy: "Inter";
  --font-stat: "JetBrains Mono";
  --z-world: 1;
  --z-actors: 2;
  --z-hud: 10;
  --z-hud-raised: 11;
  --z-hud-panel: 12;
  --z-battle-canvas: 20;
  --z-classroom-banner: 30;
  --z-auth: 40;
  --z-toast: 50;
  --z-profile-menu: 10000;
  --z-mobile-portrait-gate: 100000;
  --hud-raw-ref-px: min(0.0520833vw, 0.0925926vh);
  --hud-panel-ref-px: var(--hud-raw-ref-px);
  --hud-control-ref-px: var(--hud-raw-ref-px);
  --hud-prompt-ref-px: var(--hud-raw-ref-px);
  --hud-ref-px: var(--hud-panel-ref-px);
  --hud-edge-inset: min(1.3020833vw, 2.3148148vh);
  --starborn-viewport-w: 100vw;
  --starborn-viewport-h: 100dvh;
  --starborn-stage-background: #2f75d6;
  --world-viewport-x: 0px;
  --world-viewport-y: 0px;
  --world-viewport-w: 100vw;
  --world-viewport-h: var(--starborn-viewport-h);
  --world-visual-bottom-inset: 0px;
  --world-hud-panel-ref-px: var(--hud-panel-ref-px);
  --world-hud-control-ref-px: var(--hud-control-ref-px);
  --world-hud-prompt-ref-px: var(--hud-prompt-ref-px);
  font-family: var(--font-copy);
}

@media (max-width: 820px),
  (max-width: 980px) and (max-height: 520px) and (orientation: landscape),
  (hover: none) and (pointer: coarse) {
  :root {
    --hud-panel-ref-px: clamp(0.5px, var(--hud-raw-ref-px), 1px);
    --hud-control-ref-px: clamp(0.52px, var(--hud-raw-ref-px), 1px);
    --hud-prompt-ref-px: clamp(0.56px, var(--hud-raw-ref-px), 1px);
    --hud-ref-px: var(--hud-panel-ref-px);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #300f53;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  color: var(--ink);
  cursor: pointer;
}

.mobile-portrait-gate {
  position: fixed;
  inset: 0;
  z-index: var(--z-mobile-portrait-gate);
  display: none;
  align-items: center;
  justify-content: center;
  width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  padding:
    calc(24px + env(safe-area-inset-top, 0px))
    calc(22px + env(safe-area-inset-right, 0px))
    calc(24px + env(safe-area-inset-bottom, 0px))
    calc(22px + env(safe-area-inset-left, 0px));
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(5, 13, 21, 0.97), rgba(9, 28, 37, 0.98)),
    #071014;
  color: #edf4ee;
  font-family: var(--font-display), Rajdhani, Inter, system-ui, sans-serif;
  text-align: center;
  pointer-events: auto;
}

.mobile-portrait-gate::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("/assets/critical/bootstrap/potrait-splash-screen-bg-2d.webp") center/cover no-repeat;
  opacity: 0.18;
  pointer-events: none;
}

body.is-mobile-phone-portrait {
  touch-action: none;
}

body.is-mobile-phone-portrait .mobile-portrait-gate {
  display: flex;
}

.mobile-portrait-gate__content {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 14px;
  width: min(340px, 100%);
}

.mobile-portrait-gate__phone {
  position: relative;
  width: 86px;
  height: 54px;
  margin: 20px 42px;
  border: 4px solid rgba(126, 224, 184, 0.86);
  border-radius: 14px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.16) inset,
    0 18px 45px rgba(0, 0, 0, 0.4);
}

.mobile-portrait-gate__phone::before,
.mobile-portrait-gate__phone::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 30px;
  height: 72px;
  background: rgba(126, 224, 184, 0.9);
  pointer-events: none;
}

.mobile-portrait-gate__phone::before {
  right: calc(100% + 10px);
  transform: translateY(-50%);
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 44 112' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M28 16C9 35 9 76 27 96' fill='none' stroke='%23000' stroke-width='8' stroke-linecap='round'/%3E%3Cpath d='M27 96L12 91M27 96L31 80' fill='none' stroke='%23000' stroke-width='8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 44 112' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M28 16C9 35 9 76 27 96' fill='none' stroke='%23000' stroke-width='8' stroke-linecap='round'/%3E%3Cpath d='M27 96L12 91M27 96L31 80' fill='none' stroke='%23000' stroke-width='8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
}

.mobile-portrait-gate__phone::after {
  left: calc(100% + 10px);
  transform: translateY(-50%);
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 44 112' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M16 96C35 77 35 36 17 16' fill='none' stroke='%23000' stroke-width='8' stroke-linecap='round'/%3E%3Cpath d='M17 16L32 21M17 16L13 32' fill='none' stroke='%23000' stroke-width='8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 44 112' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M16 96C35 77 35 36 17 16' fill='none' stroke='%23000' stroke-width='8' stroke-linecap='round'/%3E%3Cpath d='M17 16L32 21M17 16L13 32' fill='none' stroke='%23000' stroke-width='8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
}

.mobile-portrait-gate h1,
.mobile-portrait-gate p {
  margin: 0;
}

.mobile-portrait-gate h1 {
  color: #fff7c7;
  font-size: 34px;
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: 0;
  text-transform: uppercase;
}

.mobile-portrait-gate p {
  max-width: 26ch;
  color: rgba(237, 244, 238, 0.78);
  font-size: 15px;
  line-height: 1.45;
}

@media (max-height: 560px) {
  .mobile-portrait-gate h1 {
    font-size: 28px;
  }
}

.shell,
.game-stage {
  position: relative;
  width: 100vw;
  width: var(--starborn-viewport-w, 100vw);
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  height: var(--starborn-viewport-h, 100dvh);
  max-height: 100vh;
  max-height: 100dvh;
  background: var(--starborn-stage-background);
  overflow: hidden;
}

.game-stage {
  overflow: clip;
}

.game-stage:fullscreen,
.game-stage:-webkit-full-screen {
  width: 100vw !important;
  max-width: none !important;
  height: 100vh !important;
  max-height: none !important;
}

#gameCanvas,
#roamCanvas {
  position: absolute;
  inset: 0;
  z-index: var(--z-world);
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  touch-action: none;
  overscroll-behavior: contain;
  -webkit-user-select: none;
  user-select: none;
}

#roamCanvas {
  background: #300f53;
}

.sky-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: transparent;
}

.terrain-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: transparent;
}

#gameCanvasFront {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: transparent;
}

.student-classroom-banner[hidden] {
  display: none;
}

.student-classroom-banner {
  box-sizing: border-box;
  position: fixed;
  top: calc(var(--world-viewport-y) + max(12px, env(safe-area-inset-top, 0px)));
  left: calc(
    var(--world-viewport-x)
    + env(safe-area-inset-left, 0px)
    + (var(--world-viewport-w) - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)) * 0.5
  );
  z-index: var(--z-classroom-banner);
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.2vw, 16px);
  width: min(
    760px,
    calc(
      var(--world-viewport-w)
      - 24px
      - env(safe-area-inset-left, 0px)
      - env(safe-area-inset-right, 0px)
    )
  );
  min-height: 56px;
  padding: clamp(10px, 1.2vw, 14px) clamp(14px, 1.8vw, 22px);
  border: 2px solid rgba(255, 216, 107, 0.82);
  border-radius: 16px;
  color: #fff7d6;
  background:
    linear-gradient(135deg, rgba(67, 29, 92, 0.97), rgba(20, 35, 65, 0.97)),
    #21183d;
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.4),
    0 0 18px rgba(255, 216, 107, 0.2);
  font: 600 clamp(0.82rem, 1.15vw, 1rem) / 1.35 var(--font-copy);
  pointer-events: auto;
  transform: translateX(-50%);
}

.student-classroom-banner__icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: clamp(30px, 3vw, 38px);
  height: clamp(30px, 3vw, 38px);
  border: 2px solid rgba(255, 255, 255, 0.74);
  border-radius: 50%;
  color: #301444;
  background: #ffd86b;
  box-shadow: 0 0 14px rgba(255, 216, 107, 0.42);
  font: 700 clamp(1.1rem, 1.7vw, 1.4rem) / 1 var(--font-heading);
}

.student-classroom-banner__message {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.student-classroom-banner strong {
  color: #ffd86b;
  font-family: var(--font-heading);
  font-size: 1.08em;
}

.student-classroom-banner__close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  position: relative;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.56);
  border-radius: 50%;
  color: #fff7d6;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
  cursor: pointer;
  touch-action: manipulation;
}

.student-classroom-banner__close > span {
  display: none;
}

.student-classroom-banner__close::before,
.student-classroom-banner__close::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 17px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
  transform-origin: center;
}

.student-classroom-banner__close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.student-classroom-banner__close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.student-classroom-banner__close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.student-classroom-banner__close:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 2px;
}

@media (max-width: 980px) and (max-height: 520px) and (orientation: landscape) {
  .student-classroom-banner {
    top: calc(var(--world-viewport-y) + max(8px, env(safe-area-inset-top, 0px)));
    gap: 8px;
    width: min(
      760px,
      calc(
        var(--world-viewport-w)
        - 16px
        - env(safe-area-inset-left, 0px)
        - env(safe-area-inset-right, 0px)
      )
    );
    min-height: 48px;
    padding: 8px 10px;
    border-radius: 12px;
    font-size: clamp(0.72rem, 2.6vh, 0.84rem);
  }

  .student-classroom-banner__icon {
    width: 28px;
    height: 28px;
    font-size: 1rem;
  }

  .student-classroom-banner__close {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 650px) and (max-height: 520px) and (orientation: landscape) {
  .student-classroom-banner {
    gap: 8px;
    min-height: 52px;
    padding: 7px 7px 7px 11px;
    text-align: left;
  }

  .student-classroom-banner__icon {
    display: none;
  }

  .student-classroom-banner strong {
    display: block;
  }

  .student-classroom-banner__close {
    width: 44px;
    height: 44px;
  }
}

/** Front canvas for tiles that sort in front of the actor layer (trees, props). */
#roamCanvasFront {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: transparent;
}

.roam-hud {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 4;
  margin: 0;
  padding: 10px 14px;
  max-width: min(420px, 92vw);
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted, #9fb5bc);
  background: rgba(8, 14, 18, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  pointer-events: none;
}

.actor-layer {
  position: absolute;
  inset: 0;
  z-index: var(--z-actors);
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.portal-reality-transition {
  position: absolute;
  inset: 0;
  z-index: 10000;
  display: none;
  overflow: hidden;
  background: #020711;
  isolation: isolate;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease-out;
}

.portal-reality-transition.is-active {
  display: flex;
}

.portal-reality-transition.is-visible {
  opacity: 1;
}

.portal-reality-transition.is-exiting {
  opacity: 0;
  transition-duration: 320ms;
}

.portal-reality-transition canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at center, rgba(22, 205, 224, 0.2), transparent 34%),
    radial-gradient(circle at center, #321150 0%, #100528 58%, #020711 100%);
}

.portal-reality-transition__loading {
  position: absolute;
  bottom: 5.5556%;
  left: 50%;
  z-index: 1;
  display: flex;
  width: clamp(280px, 32.6563vw, 627px);
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2.4vh, 26px);
  transform: translateX(-50%);
}

.portal-reality-transition__text {
  position: relative;
  color: #fff;
  font-family: "Rajdhani", Inter, system-ui, sans-serif;
  font-size: clamp(1rem, 1.25vw, 1.5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  text-align: center;
  text-shadow:
    -2px -2px 0 #05030c,
    2px -2px 0 #05030c,
    -2px 2px 0 #05030c,
    2px 2px 0 #05030c,
    0 0 9px rgba(247, 121, 255, 0.5);
}

.portal-reality-transition__progress-track {
  box-sizing: border-box;
  width: 100%;
  height: clamp(12px, 2.1296vh, 23px);
  overflow: hidden;
  border: 1px solid rgba(247, 121, 255, 0.95);
  border-radius: 999px;
  background: rgba(6, 3, 18, 0.94);
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.62);
}

.portal-reality-transition__progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #f779ff;
  box-shadow: 0 0 12px rgba(247, 121, 255, 0.7);
}

.portal-reality-transition.is-visible .portal-reality-transition__progress-fill {
  animation: portal-reality-loading-progress 3s cubic-bezier(0.16, 0.7, 0.25, 1) forwards;
}

@keyframes portal-reality-loading-progress {
  0% { width: 4%; }
  72% { width: 82%; }
  100% { width: 100%; }
}

.battle-canvas-panel {
  position: absolute;
  top: var(--world-viewport-y);
  right: auto;
  bottom: auto;
  left: var(--world-viewport-x);
  z-index: var(--z-battle-canvas);
  display: none;
  align-items: center;
  justify-content: center;
  width: var(--world-viewport-w);
  height: var(--world-viewport-h);
  background: #020711;
}

.battle-canvas-panel.is-open {
  display: flex;
}

.battle-canvas-panel.is-closing {
  background: #020711;
  pointer-events: none;
}

#battle-loading-screen {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: none;
  overflow: hidden;
  background: #020711;
  color: #fff;
  font-family: "Rajdhani", sans-serif;
  isolation: isolate;
  opacity: 1;
}

#battle-loading-screen.is-active {
  display: block;
}

#battle-loading-screen.is-exiting {
  opacity: 0;
  transition: opacity 360ms ease-in;
}

.battle-transition-rive {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at center, rgba(22, 205, 224, 0.28), transparent 33%),
    radial-gradient(circle at center, #321150 0%, #100528 58%, #020711 100%);
  transform: translateX(3.5%) scale(1.08);
  transform-origin: center;
  will-change: transform;
}

.battle-vs-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.battle-vs-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: transparent url("/assets/critical/battle/battle-dim-bg.png") center / 100% 100% no-repeat;
  opacity: 0;
  pointer-events: none;
  transform: scale(1.04);
  will-change: transform, opacity;
}

#battle-loading-screen.is-sequencing .battle-vs-stage::before {
  animation: battle-vs-dim-enter 700ms ease-out 1000ms both;
}

.battle-vs-stage img {
  position: absolute;
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}

.battle-vs-panel-frame {
  top: 48.9%;
  left: 50%;
  z-index: 1;
  width: 86.7%;
  height: auto;
  opacity: 0;
  transform: translate3d(-50%, -50%, 0) scale(0.40);
  transform-origin: center;
  will-change: transform, opacity;
}

.battle-vs-creature {
  position: absolute;
  top: 28.2407%;
  z-index: 2;
  width: 22.1875%;
  aspect-ratio: 1;
  opacity: 0;
  will-change: transform, opacity;
}

.battle-vs-creature--buddy {
  left: 17.65625%;
  transform: translate3d(-92vw, 0, 0) scale(0.86);
}

.battle-vs-creature--opponent {
  right: 19.6875%;
  transform: translate3d(92vw, 0, 0) scale(0.86);
}

.battle-vs-creature-frame,
.battle-vs-creature-thumbnail {
  inset: 0;
  width: 100%;
  height: 100%;
}

.battle-vs-creature-frame {
  z-index: 1;
}

.battle-vs-creature-thumbnail {
  z-index: 2;
  box-sizing: border-box;
  padding: 4.25%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  clip-path: circle(45.75% at 50% 50%);
}

.battle-vs-creature--opponent .battle-vs-creature-thumbnail {
  transform: scaleX(-1);
}

.battle-vs-stage.is-monster-opponent .battle-vs-creature--opponent .battle-vs-creature-thumbnail {
  transform: scaleX(1);
}

.battle-vs-spark-rive {
  position: absolute;
  top: -15%;
  left: -12%;
  z-index: 3;
  display: block;
  width: 130%;
  height: 130%;
  opacity: 0;
  pointer-events: none;
  transform: scale(1.25);
  transform-origin: center;
  will-change: transform, opacity;
}

.battle-vs-text {
  top: 47.9167%;
  left: 50%;
  z-index: 4;
  width: 10%;
  height: 11.1%;
  object-fit: contain;
  opacity: 0;
  transform: translate3d(-50%, -50%, 0) scale(0.24);
  transform-origin: center;
  will-change: transform, opacity;
}

#battle-loading-screen.is-sequencing .battle-vs-panel-frame {
  animation:
    battle-vs-panel-pop 600ms cubic-bezier(0.22, 0.72, 0.24, 1.08) 350ms both,
    battle-vs-panel-fade 240ms ease-out 350ms both;
}

#battle-loading-screen.is-sequencing .battle-vs-text {
  animation: battle-vs-text-pop 380ms cubic-bezier(0.16, 1, 0.3, 1) 750ms both;
}

#battle-loading-screen.is-sequencing .battle-vs-creature--buddy {
  animation: battle-vs-buddy-pop 550ms cubic-bezier(0.16, 1, 0.3, 1) 1100ms both;
}

#battle-loading-screen.is-sequencing .battle-vs-creature--opponent {
  animation: battle-vs-opponent-pop 550ms cubic-bezier(0.16, 1, 0.3, 1) 1100ms both;
}

#battle-loading-screen.is-sequencing .battle-vs-spark-rive {
  animation: battle-vs-spark-pop 750ms cubic-bezier(0.33, 0, 0.2, 1) 1100ms forwards;
}

@keyframes battle-vs-dim-enter {
  0% { opacity: 0; transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes battle-vs-panel-pop {
  0% { transform: translate3d(-50%, -50%, 0) scale(0.32); }
  100% { transform: translate3d(-50%, -50%, 0) scale(1); }
}

@keyframes battle-vs-panel-fade {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes battle-vs-text-pop {
  0% { opacity: 0; transform: translate3d(-50%, -50%, 0) scale(0.24); }
  68% { opacity: 1; transform: translate3d(-50%, -50%, 0) scale(1.22); }
  100% { opacity: 1; transform: translate3d(-50%, -50%, 0) scale(1); }
}

@keyframes battle-vs-buddy-pop {
  0% { opacity: 0; transform: translate3d(-92vw, 0, 0) scale(0.86); }
  72% { opacity: 1; transform: translate3d(1.8vw, 0, 0) scale(1.045); }
  100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes battle-vs-opponent-pop {
  0% { opacity: 0; transform: translate3d(92vw, 0, 0) scale(0.86); }
  72% { opacity: 1; transform: translate3d(-1.8vw, 0, 0) scale(1.045); }
  100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes battle-vs-spark-pop {
  0% { opacity: 0.6; transform: scale(1.15); }
  20% { opacity: 0.6; transform: scale(1.15); }
  100% { opacity: 1; transform: scale(1.25); }
}

.battle-loading-content {
  position: absolute;
  bottom: 5.5556%;
  left: 50%;
  z-index: 8;
  transform: translateX(-50%);
  width: clamp(280px, 32.6563vw, 627px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2.4vh, 26px);
  transition: opacity 180ms ease-out;
}

#battle-loading-screen.is-ready .battle-loading-content {
  opacity: 0;
}

.battle-loading-progress-track {
  box-sizing: border-box;
  height: clamp(12px, 2.1296vh, 23px);
  width: 100%;
  background: rgba(6, 3, 18, 0.94);
  border: 1px solid rgba(247, 121, 255, 0.95);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.62);
}

.battle-loading-progress-fill {
  height: 100%;
  width: 0%;
  background: #F779FF;
  border-radius: inherit;
  box-shadow: 0 0 12px rgba(247, 121, 255, 0.7);
  transition: width 0.3s ease-out;
}

#battle-loading-screen.is-loading-prelude .battle-loading-progress-fill {
  animation: battle-loading-prelude-progress 2s cubic-bezier(0.2, 0.72, 0.2, 1) both;
}

@keyframes battle-loading-prelude-progress {
  0% { width: 3%; }
  70% { width: 76%; }
  100% { width: 90%; }
}

.battle-loading-text {
  font-size: clamp(1rem, 1.25vw, 1.5rem);
  line-height: 1;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow:
    -2px -2px 0 #05030c,
    2px -2px 0 #05030c,
    -2px 2px 0 #05030c,
    2px 2px 0 #05030c,
    0 0 9px rgba(247, 121, 255, 0.5);
  font-weight: 700;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  #battle-loading-screen.is-sequencing .battle-vs-panel-frame,
  #battle-loading-screen.is-sequencing .battle-vs-creature,
  #battle-loading-screen.is-sequencing .battle-vs-spark-rive,
  #battle-loading-screen.is-sequencing .battle-vs-text,
  #battle-loading-screen.is-sequencing .battle-vs-stage::before {
    animation-duration: 1ms;
  }
}

.battle-begin-banner {
  position: absolute;
  top: 16%;
  left: 50%;
  z-index: 30;
  display: block;
  width: clamp(170px, 13.2%, 254px);
  height: auto;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  transform: translate3d(-50%, -12px, 0) scale(0.9);
  transform-origin: center;
  transition:
    opacity 240ms ease-out,
    transform 340ms cubic-bezier(0.22, 1.18, 0.36, 1);
  will-change: opacity, transform;
}

.battle-begin-banner.is-visible {
  opacity: 1;
  transform: translate3d(-50%, 0, 0) scale(1);
}

.battle-begin-banner.is-hiding {
  opacity: 0;
  transform: translate3d(-50%, -8px, 0) scale(0.98);
  transition-timing-function: ease-in;
  transition-duration: 320ms;
}

.math-challenge-panel {
  position: fixed;
  top: calc(var(--world-viewport-y) + var(--world-viewport-h) * 0.3);
  right: auto;
  bottom: auto;
  left: var(--world-viewport-x);
  width: var(--world-viewport-w);
  height: calc(var(--world-viewport-h) * 0.7);
  z-index: var(--z-battle-canvas);
  background: linear-gradient(to top, rgba(13, 27, 30, 0.95), rgba(13, 27, 30, 0.7));
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-top: 3px solid var(--accent-2);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
  transform: translateY(100%);
  visibility: hidden;
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.15), visibility 0s 0.5s;
}

.math-challenge-panel.is-open {
  transform: translateY(0);
  visibility: visible;
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.15), visibility 0s;
}

.math-challenge-panel.is-rescue,
.math-challenge-panel.is-chest,
.math-challenge-panel.is-recharge {
  top: var(--world-viewport-y);
  right: auto;
  bottom: auto;
  left: var(--world-viewport-x);
  width: var(--world-viewport-w);
  height: var(--world-viewport-h);
  justify-content: stretch;
  background:
    radial-gradient(circle at 50% 10%, rgba(126, 224, 184, 0.18), transparent 38%),
    linear-gradient(180deg, rgba(5, 13, 17, 0.98), rgba(6, 12, 18, 0.96));
  border-top: 0;
  transform: translateY(100%);
}

.math-challenge-panel.is-rescue.is-open,
.math-challenge-panel.is-chest.is-open,
.math-challenge-panel.is-recharge.is-open {
  transform: translateY(0);
}

.math-challenge-close {
  position: absolute;
  top: clamp(12px, 2vw, 24px);
  right: clamp(12px, 2vw, 24px);
  z-index: 8;
  display: none;
  width: clamp(58px, 5.1vw, 72px);
  height: clamp(58px, 5.1vw, 72px);
  padding: 0;
  border: 0;
  border-radius: 0;
  color: transparent;
  background: transparent url("/assets/lazy/common/close-button-default.png") center / contain no-repeat;
  box-shadow: none;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.42));
  font-size: 0;
  line-height: 1;
  cursor: pointer;
  transition: filter 140ms ease, transform 140ms ease;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.math-challenge-panel.is-rescue.is-open .math-challenge-close,
.math-challenge-panel.is-chest.is-open .math-challenge-close,
.math-challenge-panel.is-recharge.is-open .math-challenge-close {
  display: block;
}

.math-challenge-close:hover,
.math-challenge-close:focus-visible,
.math-challenge-close:active {
  background-image: url("/assets/lazy/common/close-button-hover.png");
  filter: drop-shadow(0 12px 22px rgba(98, 230, 253, 0.3)) drop-shadow(0 8px 18px rgba(0, 0, 0, 0.36));
  outline: none;
}

.math-challenge-panel.is-rescue .math-challenge-close,
.math-challenge-panel.is-chest .math-challenge-close,
.math-challenge-panel.is-recharge .math-challenge-close {
  background-image: url("/assets/lazy/common/close-button-blue-default.png");
}

.math-challenge-panel.is-rescue .math-challenge-close:hover,
.math-challenge-panel.is-rescue .math-challenge-close:focus-visible,
.math-challenge-panel.is-rescue .math-challenge-close:active,
.math-challenge-panel.is-chest .math-challenge-close:hover,
.math-challenge-panel.is-chest .math-challenge-close:focus-visible,
.math-challenge-panel.is-chest .math-challenge-close:active,
.math-challenge-panel.is-recharge .math-challenge-close:hover,
.math-challenge-panel.is-recharge .math-challenge-close:focus-visible,
.math-challenge-panel.is-recharge .math-challenge-close:active {
  background-image: url("/assets/lazy/common/close-button-blue-hover.png");
}

.math-challenge-close:active {
  transform: scale(0.97);
}

.math-challenge-shell {
  width: 100%;
  height: 100%;
  position: relative;
}

.math-challenge-panel.is-rescue .math-challenge-shell,
.math-challenge-panel.is-chest .math-challenge-shell,
.math-challenge-panel.is-recharge .math-challenge-shell {
  height: 70%;
  min-height: 0;
}

.rescue-challenge-stage {
  position: relative;
  isolation: isolate;
  display: none;
  width: 100%;
  height: 30%;
  min-height: 176px;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  border-bottom: 2px solid rgba(216, 175, 106, 0.56);
  background:
    radial-gradient(circle at 50% 72%, rgba(232, 212, 178, 0.58), transparent 30%),
    radial-gradient(circle at 50% 12%, rgba(84, 185, 234, 0.3), transparent 44%),
    linear-gradient(180deg, rgba(22, 26, 55, 0.94), rgba(31, 35, 55, 0.9) 56%, rgba(49, 40, 65, 0.92)),
    repeating-linear-gradient(90deg, rgba(216, 175, 106, 0.06) 0 1px, transparent 1px 48px);
}

.math-challenge-panel.is-rescue .rescue-challenge-stage,
.math-challenge-panel.is-chest .rescue-challenge-stage,
.math-challenge-panel.is-recharge .rescue-challenge-stage {
  display: flex;
}

.math-challenge-panel.is-recharge .rescue-challenge-stage {
  min-height: 0;
}

.math-challenge-panel.is-chest .rescue-challenge-stage,
.math-challenge-panel.is-recharge .rescue-challenge-stage {
  background:
    radial-gradient(circle at 50% 72%, rgba(232, 212, 178, 0.38), transparent 30%),
    url("../assets/lazy/effects/rescue-healing-background-battle-stage-1280x216.png") center / cover no-repeat,
    linear-gradient(180deg, rgba(22, 26, 55, 0.94), rgba(31, 35, 55, 0.9) 56%, rgba(49, 40, 65, 0.92));
}

.rescue-challenge-vfx {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.math-challenge-panel.is-chest .rescue-challenge-vfx {
  z-index: 4;
}

.rescue-challenge-vfx canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.rescue-challenge-frame {
  --rescue-challenge-frame-offset-y: 0px;
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  display: block;
  width: min(28vh, 270px);
  height: min(28vh, 270px);
  object-fit: contain;
  filter: drop-shadow(0 22px 18px rgba(0, 0, 0, 0.42));
  transform: translate(-50%, calc(-50% + var(--rescue-challenge-frame-offset-y)));
  transition: opacity 180ms ease, transform 160ms ease;
}

.rescue-challenge-frame--previous {
  z-index: 2;
  pointer-events: none;
}

.rescue-challenge-stage[data-rescue-actor-type="rive"] .rescue-challenge-frame {
  --rescue-challenge-frame-offset-y: 50px;
}

.rescue-challenge-stage.has-pixi-vfx .rescue-challenge-frame {
  opacity: 0;
}

.chest-challenge-sprite {
  --chest-challenge-offset-x: 20px;
  --chest-challenge-offset-y: 50px;
  position: relative;
  z-index: 3;
  display: none;
  width: min(32vh, 320px);
  height: min(22vh, 220px);
  background-repeat: no-repeat;
  filter: drop-shadow(0 22px 18px rgba(0, 0, 0, 0.42));
  transform: translate(var(--chest-challenge-offset-x), var(--chest-challenge-offset-y)) scale(1);
  transform-origin: 50% 80%;
  will-change: transform;
}

.math-challenge-panel.is-chest .rescue-challenge-frame {
  display: none;
}

.math-challenge-panel.is-recharge .rescue-challenge-frame,
.math-challenge-panel.is-recharge .chest-challenge-sprite,
.math-challenge-panel.is-recharge .rescue-challenge-status {
  display: none;
}

.math-challenge-panel.is-chest .chest-challenge-sprite {
  display: block;
  animation: chestChallengeBob 2.7s ease-in-out infinite;
}

.chest-challenge-sprite.is-fallback {
  width: min(16.8vh, 156px);
  height: min(12.8vh, 117px);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 0 14%, rgba(255, 232, 152, 0.56) 14% 18%, transparent 18% 82%, rgba(255, 232, 152, 0.56) 82% 86%, transparent 86%),
    linear-gradient(180deg, #d89043 0%, #9b522a 48%, #6d331f 100%);
  border: 3px solid #2b1d18;
  box-shadow: inset 0 16px 0 rgba(255, 226, 138, 0.18), inset 0 -18px 0 rgba(0, 0, 0, 0.16);
}

.chest-challenge-sprite.is-fallback::before,
.chest-challenge-sprite.is-fallback::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.chest-challenge-sprite.is-fallback::before {
  left: -3px;
  right: -3px;
  top: -34%;
  height: 44%;
  border: 3px solid #2b1d18;
  border-radius: 48% 48% 8px 8px;
  background: linear-gradient(180deg, #f3be62 0%, #b76831 100%);
  box-shadow: inset 0 12px 0 rgba(255, 244, 180, 0.24);
}

.chest-challenge-sprite.is-fallback::after {
  left: 50%;
  top: 42%;
  width: 20%;
  height: 30%;
  border: 2px solid #3d2b20;
  border-radius: 4px;
  background: #f2d57c;
  transform: translateX(-50%);
}

.resource-recharge-stage {
  position: relative;
  z-index: 4;
  display: none;
  align-items: center;
  justify-content: center;
  width: min(1040px, 94vw, calc((30vh - 18px) * 6.1593));
  aspect-ratio: 2088 / 339;
  filter: drop-shadow(0 24px 34px rgba(0, 0, 0, 0.42));
}

.math-challenge-panel.is-recharge .resource-recharge-stage {
  display: flex;
}

.resource-recharge-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.resource-recharge-stage.is-charging .resource-recharge-canvas {
  animation: resourceRechargeCanvasPulse 520ms ease-out;
}

@keyframes resourceRechargeCanvasPulse {
  0%,
  100% {
    filter: brightness(1);
    transform: scale(1);
  }
  38% {
    filter: brightness(1.28);
    transform: scale(1.018);
  }
}

@keyframes chestChallengeBob {
  0%,
  100% {
    transform: translate(var(--chest-challenge-offset-x), var(--chest-challenge-offset-y)) scale(1);
  }
  48% {
    transform: translate(var(--chest-challenge-offset-x), calc(var(--chest-challenge-offset-y) - 7px)) scale(1.012);
  }
}

@media (prefers-reduced-motion: reduce) {
  .math-challenge-panel.is-chest .chest-challenge-sprite,
  .math-question-loading span,
  .resource-recharge-stage.is-charging .resource-recharge-canvas {
    animation: none;
  }
}

.rescue-challenge-status {
  position: absolute;
  right: clamp(14px, 4vw, 52px);
  top: clamp(10px, 1.6vh, 18px);
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: center;
  align-items: center;
  width: min(clamp(300px, 21vw, 360px), calc(var(--world-viewport-w) - 104px));
  min-width: 0;
  aspect-ratio: 707 / 353;
  box-sizing: border-box;
  gap: clamp(5px, 0.58vw, 9px) clamp(10px, 1vw, 16px);
  padding: clamp(26px, 3vw, 36px) clamp(32px, 3.8vw, 46px) clamp(28px, 3.2vw, 40px);
  border: 0;
  border-radius: 0;
  background: url("/assets/lazy/effects/rescue-base-options/math-popup-style/question-frame-strched_final.png") center / 100% 100% no-repeat;
  box-shadow: none;
  font-family: var(--font-heading);
}

.math-challenge-panel.is-rescue .rescue-challenge-status,
.math-challenge-panel.is-chest .rescue-challenge-status {
  top: clamp(10px, 1.6vh, 18px);
  right: auto;
  bottom: auto;
  left: clamp(14px, 4vw, 52px);
  z-index: 5;
  transform: none;
}

.rescue-challenge-status strong,
.rescue-challenge-status span {
  min-width: 0;
  white-space: nowrap;
  font-family: var(--font-heading);
  font-weight: 800;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.56);
}

.rescue-challenge-status strong {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(1rem, 2vw, 1.35rem);
  color: #fff7df;
}

.rescue-challenge-status span {
  justify-self: end;
  font-size: clamp(0.92rem, 1.7vw, 1.16rem);
  color: #ffffff;
}

.rescue-challenge-status i {
  grid-column: 1 / -1;
  position: relative;
  display: block;
  height: clamp(22px, 2.2vw, 30px);
  overflow: hidden;
  border-radius: 999px;
  background: rgba(211, 245, 246, 0.55);
  clip-path: inset(0 round 999px);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.66),
    inset 0 0 0 3px rgba(255, 255, 255, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.18);
}

.rescue-challenge-status b {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  display: block;
  width: 0%;
  height: 100%;
  min-width: 0;
  max-width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7ee0b8, #e9b35f);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.66),
    0 0 12px rgba(126, 224, 184, 0.42);
  transition: width 0.24s ease;
}

#mathWebappIframe {
  width: 100%;
  height: 100%;
  border: none;
}

.math-question-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: #243039;
  text-align: center;
  pointer-events: none;
  background: #ffffff;
}

.math-challenge-panel.is-awaiting-question .math-question-loading {
  display: grid;
}

.math-question-loading span {
  width: 46px;
  height: 46px;
  border: 4px solid rgba(36, 48, 57, 0.16);
  border-top-color: #2f99d3;
  border-right-color: #63d7b1;
  border-radius: 50%;
  animation: mathQuestionSpinner 0.8s linear infinite;
}

.math-question-loading strong {
  font: 800 1.05rem var(--font-heading);
  letter-spacing: 0;
  text-shadow: none;
}

@keyframes mathQuestionSpinner {
  to {
    transform: rotate(360deg);
  }
}

.battle-canvas-shell {
  position: relative;
  width: min(100%, calc(var(--world-viewport-h) * 3840 / 2160));
  max-height: 100%;
  aspect-ratio: 3840 / 2160;
  overflow: hidden;
  background: #020711;
  opacity: 1;
  transition: opacity 240ms ease;
}

/* Freeing a gripped creature: the move bubble and Rest, over the 16:9 canvas (positions in 1280 x 720 units). */
.battle-canvas-shell {
  container-type: inline-size;
}

.battle-rest-button {
  position: absolute;
  left: 50%;
  bottom: calc(205 / 720 * 100%);
  transform: translateX(-50%);
  padding: 0.7cqw 2cqw;
  border: 0.2cqw solid #83d7ff;
  border-radius: 99px;
  background: #1d4ed8;
  color: #fff;
  font: 900 1.5cqw "Nunito", system-ui, sans-serif;
  cursor: pointer;
}

.battle-rest-button span {
  font-weight: 700;
  opacity: 0.85;
}

.battle-rest-button:focus-visible {
  outline: 0.25cqw solid #fff;
  outline-offset: 0.2cqw;
}

/* Buddy Switch in a challenge: a picker of the team (HANDOFF.md §5, "Buddy Switch") */
.battle-switch {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(8 4 20 / 66%);
}

.battle-switch[hidden] { display: none; }

.battle-switch-card {
  width: calc(1040 / 1280 * 100%);
  padding: 1.4cqw 1.8cqw;
  border: 0.22cqw solid #f779ff;
  border-radius: 1.6cqw;
  background: rgb(18 10 36 / 95%);
  color: #f2efe7;
  font: 700 1.1cqw/1.3 "Nunito", system-ui, sans-serif;
  text-align: center;
}

.battle-switch-card h3 { margin: 0 0 1cqw; font: 900 2.2cqw "Lilita One", "Nunito", sans-serif; color: #ffdf24; }
.battle-switch-card > p { margin: 1cqw 0 0; opacity: 0.85; }

.battle-switch-tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1cqw;
}

.battle-switch-tile {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3cqw 0.9cqw;
  width: calc(310 / 1280 * 100cqw);
  padding: 0.9cqw;
  border: 0.2cqw solid #8b5cf6;
  border-radius: 1.2cqw;
  background: rgb(30 16 58 / 92%);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.battle-switch-tile:hover:not(:disabled),
.battle-switch-tile:focus-visible { border-color: #ffd76a; outline: none; }
.battle-switch-tile:disabled { cursor: default; opacity: 0.55; border-color: #4b3a6e; }

.battle-switch-face { position: relative; grid-row: span 3; }

.battle-switch-face img {
  width: 5.2cqw;
  height: 5.2cqw;
  border: 0.2cqw solid #f779ff;
  border-radius: 50%;
  object-fit: cover;
  background: #1d4995;
}

.battle-switch-face i {
  position: absolute;
  right: -0.4cqw;
  bottom: 0;
  padding: 0 0.4cqw;
  border-radius: 99px;
  background: #13081a;
  font: 800 0.75cqw "Nunito", sans-serif;
  font-style: normal;
  text-transform: uppercase;
}

.battle-switch-tile .tag { justify-self: start; padding: 0 0.6cqw; border-radius: 99px; font-size: 0.85cqw; font-weight: 900; }
.battle-switch-tile .tag[data-state="ready"] { background: #14532d; color: #7dff9a; }
.battle-switch-tile .tag[data-state="ring"] { background: #0e3a4a; color: #7fe9ff; }
.battle-switch-tile .tag[data-state="out"] { background: #4a1020; color: #ff9aa2; }
.battle-switch-tile .name { font: 900 1.4cqw "Lilita One", "Nunito", sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.battle-switch-tile .hit { grid-column: 1 / -1; font-weight: 800; }
.battle-switch-tile .hit[data-match="strong"] b { color: #ff8a8a; }
.battle-switch-tile .hit[data-match="weak"] b { color: #8fc8ff; }

.battle-switch-bar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 2.6cqw 1fr 4.4cqw;
  align-items: center;
  gap: 0.5cqw;
  font-size: 0.9cqw;
}

.battle-switch-bar span { height: 0.8cqw; border-radius: 99px; background: rgb(255 255 255 / 12%); overflow: hidden; }
.battle-switch-bar span::before { content: ""; display: block; width: var(--fill); height: 100%; background: #ec1e2c; }
.battle-switch-bar[data-key="mp"] span::before { background: #3fa0ff; }

.battle-switch-hand { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.3cqw; }
.battle-switch-hand small { padding: 0.1cqw 0.5cqw; border-radius: 0.5cqw; background: rgb(255 255 255 / 8%); font-size: 0.8cqw; }

.battle-switch-back {
  margin-top: 0.9cqw;
  padding: 0.4cqw 2cqw;
  border: 0.18cqw solid #a78bfa;
  border-radius: 99px;
  background: transparent;
  color: #f2efe7;
  font: 900 1.2cqw "Nunito", sans-serif;
  cursor: pointer;
}

/* A challenge's screen pieces, ported from prototypes/battle-scene/css/battle.css. They sit on a 1280 x 720 layer
   (.battle-stage, scaled to the canvas by 15-battle-canvas.js), so the prototype's pixel sizes carry over unchanged. */
.battle-stage {
  --ink: #1a0b3d;
  --panel: rgb(20 12 56 / 95%);
  --line: #c07bff;
  --gold: #ffc531;
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 720px;
  transform-origin: 0 0;
  pointer-events: none;
  color: #fff;
  font-family: "Nunito", system-ui, sans-serif;
}

.battle-stage > * { pointer-events: auto; }
.battle-stage [hidden] { display: none !important; }

/* top centre: only the goal, in a small pill */
.battle-goal {
  position: absolute;
  left: 50%;
  top: 28px;
  transform: translateX(-50%);
  padding: 5px 16px 6px;
  border: 2px solid #f779ff;
  border-radius: 16px;
  background: rgb(28 23 51 / 92%);
  box-shadow: 0 2px 8px rgb(0 0 0 / 45%), 0 0 8px rgb(227 150 254 / 45%);
  font: 800 13px "Nunito", sans-serif;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
  pointer-events: none;
}

/* the move bubble: the move's element in a violet ring, NEXT MOVE, the number for the Buddy in the ring, the move's
   name, and STRONG or WEAK on its top edge; a pointer hangs under its right end */
.battle-intent {
  --bc: #ff9a6b;
  z-index: 3;
  --glow: rgb(255 154 107 / 50%);
  position: absolute;
  width: 200px;
  min-height: 74px;
  margin-left: -100px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 9px;
  border: 3px solid var(--bc);
  border-radius: 18px;
  background: #100830;
  box-shadow: 0 8px 18px rgb(0 0 0 / 50%), 0 0 16px var(--glow);
  transform-origin: 70% 125%;
  transition: opacity 0.18s ease, transform 0.16s ease;
  pointer-events: none;
}

.battle-intent.is-guard, .battle-intent.is-weak { --bc: #7fd0ff; --glow: rgb(127 208 255 / 50%); }
.battle-intent.is-recover { --bc: #c98cff; --glow: rgb(201 140 255 / 50%); }
.battle-intent.is-powerup { --bc: #ffd84d; --glow: rgb(255 216 77 / 60%); }
.battle-intent.is-strong { --bc: #ff5a6a; --glow: rgb(255 90 106 / 60%); }
.battle-intent.is-big { --bc: #ff4d5e; --glow: rgb(255 77 94 / 90%); }

.intent-tail { position: absolute; top: 100%; right: 12px; width: 36px; height: 22px; overflow: visible; filter: drop-shadow(0 4px 3px rgb(0 0 0 / 35%)); }
.intent-tail .t-fill { fill: #100830; }
.intent-tail .t-line { fill: none; stroke: var(--bc); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.intent-emblem {
  flex: none;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #4a1690 0%, #1a0838 72%);
  box-shadow: 0 0 0 3px #b14bff, 0 0 14px rgb(177 75 255 / 75%);
}
.intent-emblem img { width: 32px; height: 32px; filter: drop-shadow(0 0 5px rgb(255 255 255 / 45%)); }
.intent-emblem.is-icon { background: none; box-shadow: none; }
.intent-emblem svg { width: 40px; height: 40px; }
.intent-main { flex: 1; text-align: center; line-height: 1; }
.intent-cap { font: 900 12px "Nunito", sans-serif; letter-spacing: 1px; opacity: 0.9; text-transform: uppercase; white-space: nowrap; }
.intent-val {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 1px 0;
  font: 34px "Lilita One", sans-serif;
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
}
.intent-val img { width: 27px; height: 27px; }
.intent-val s { font-size: 22px; opacity: 0.6; text-decoration-thickness: 3px; }
.intent-val .is-forecast { color: #8fe9ff; }
.intent-val.is-text { font-size: 19px; letter-spacing: 0.6px; }
.intent-name { font: 12px "Lilita One", sans-serif; letter-spacing: 0.5px; text-transform: uppercase; opacity: 0.92; }
.intent-match {
  position: absolute;
  left: 50%;
  top: -27px;
  transform: translateX(-50%);
  padding: 3px 8px;
  border: 2px solid;
  border-radius: 9px;
  font: 900 11px "Nunito", sans-serif;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.intent-match.is-strong { color: #fff; background: #c8243a; border-color: #ff9a8c; }
.intent-match.is-weak { color: #06213a; background: #8fe9ff; border-color: #d8f6ff; }

/* its life in a round (prototype ui.js): pops in and bobs, steps away while a power plays, pulses before the creature moves */
.battle-intent[data-stage="away"] { opacity: 0; transform: scale(0.4); }
.battle-intent[data-stage="faded"] { opacity: 0; }
.battle-intent[data-stage="shown"].is-animating { animation: battle-intent-pop 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.4), battle-intent-bob 2.2s ease-in-out 0.34s infinite; }
.battle-intent.is-big[data-stage="shown"].is-animating { animation: battle-intent-pop 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.4), battle-intent-big 0.6s ease-in-out 0.34s infinite; }
.battle-intent.is-powerup[data-stage="shown"].is-animating { animation: battle-intent-pop 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.4), battle-intent-jitter 0.35s linear 0.34s infinite; }
.battle-intent[data-stage="cue"].is-animating { animation: battle-intent-cue 0.42s ease-out; }
@keyframes battle-intent-jitter { 25% { transform: translate(-2px, 1px); } 50% { transform: translate(2px, -1px); } 75% { transform: translate(-1px, -2px); } }
@keyframes battle-intent-pop { 0% { transform: scale(0); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes battle-intent-bob { 50% { transform: translateY(-7px); } }
@keyframes battle-intent-big { 50% { transform: scale(1.1); } }
@keyframes battle-intent-cue { 40% { transform: scale(1.14); } }

/* while a shield is up, a small shield with its number by the creature it protects */
.battle-shield-chip {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 10px 1px 5px;
  border: 2px solid #9aeaff;
  border-radius: 15px;
  background: rgb(12 6 40 / 92%);
  box-shadow: 0 0 12px rgb(154 234 255 / 70%);
  transform: translate(-50%, -50%);
  font: 22px "Lilita One", sans-serif;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  pointer-events: none;
}
.battle-shield-chip img { width: 24px; height: 24px; }

/* the card preview: compact, the cost on PLAY */
.battle-preview {
  position: absolute;
  left: 50%;
  bottom: 306px;
  transform: translateX(-50%);
  min-width: 320px;
  max-width: 470px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 8px 8px 16px;
  border: 2px solid var(--gold);
  border-radius: 16px;
  background: rgb(14 8 46 / 97%);
  box-shadow: 0 10px 26px rgb(0 0 0 / 55%), 0 0 16px rgb(255 197 49 / 35%);
  animation: battle-popin 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
.pv-text { flex: 1; min-width: 0; text-align: left; }
.pv-title { display: flex; align-items: center; gap: 7px; font: 18px/1.1 "Lilita One", sans-serif; letter-spacing: 0.5px; text-transform: uppercase; white-space: nowrap; }
.pv-tag { padding: 2px 7px 1px; border: 2px solid #fff; border-radius: 9px; font: 10.5px "Lilita One", sans-serif; }
.pv-tag:empty { display: none; }
.pv-tag.is-strong { background: #1fae4b; }
.pv-tag.is-weak { background: #c8364a; }
.pv-line { margin-top: 2px; font: 700 14px/1.25 "Nunito", sans-serif; }
.pv-line b { font: 400 18px "Lilita One", sans-serif; color: var(--gold); }
.pv-sub { margin-top: 1px; font: 700 11.5px/1.3 "Nunito", sans-serif; opacity: 0.75; }
.pv-warn { color: #ffb0a0; opacity: 1; }
.play-btn {
  flex: none;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px 9px 20px;
  border: none;
  border-radius: 13px;
  background: linear-gradient(#ffe98a, #ffb21a 60%, #ee8600);
  box-shadow: 0 0 0 3px #7a4a12, 0 5px 0 3px rgb(0 0 0 / 40%), inset 0 3px 0 rgb(255 255 255 / 65%);
  color: #3a1a00;
  font: 21px "Lilita One", sans-serif;
  letter-spacing: 1px;
  cursor: pointer;
  animation: battle-pulse 1.1s ease-in-out infinite;
}
.play-btn:active { transform: translateY(3px); }
.pv-cost { position: relative; width: 34px; height: 34px; margin-top: -6px; }
.pv-cost svg { position: absolute; inset: 0; width: 34px; height: 34px; overflow: visible; }
.pv-cost .d-body { fill: #3fa0ff; stroke: #0b1a4d; stroke-width: 2.4; stroke-linejoin: round; }
.pv-cost .d-shade { fill: #1d6fd6; }
.pv-cost .d-shine { fill: none; stroke: #fff; stroke-opacity: 0.8; stroke-width: 2.2; stroke-linecap: round; }
.pv-cost b {
  position: absolute;
  left: 0;
  right: 0;
  top: 11px;
  color: #fff;
  font: 15px/17px "Lilita One", sans-serif;
  text-align: center;
  -webkit-text-stroke: 2.6px #0b1a4d;
  paint-order: stroke fill;
}
@keyframes battle-pulse { 50% { transform: scale(1.06); } }
@keyframes battle-popin { from { opacity: 0; transform: translateX(-50%) scale(0.85); } }

/* a played card on its way into the Buddy (prototype .show-card) */
.battle-show-card {
  position: absolute;
  left: 0;
  top: 0;
  width: 124px;
  height: 166px;
  border-radius: 12px;
  background-position: center;
  background-size: cover;
  box-shadow: 0 0 34px rgb(255 232 160 / 95%), 0 16px 30px rgb(0 0 0 / 60%);
  pointer-events: none;
  will-change: transform;
}

/* a spar's 30-second ring for the player's turn (§11, "Turn timer") */
.battle-spar-timer {
  --left: 1;
  position: absolute;
  left: 340px;
  top: 128px;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#ffc531 calc(var(--left) * 360deg), rgb(255 255 255 / 12%) 0);
  pointer-events: none;
}
.battle-spar-timer::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: #100830; }
.battle-spar-timer span { position: relative; font: 22px "Lilita One", sans-serif; }
.battle-spar-timer.is-low { background: conic-gradient(#ff5a6a calc(var(--left) * 360deg), rgb(255 255 255 / 12%) 0); }
.spar-results-badge { font-size: 13px !important; opacity: 0.8 !important; }
.battle-modal .spar-results-xp { color: #8fe9ff; font: 20px "Lilita One", sans-serif; letter-spacing: 0.5px; }
/* a row per Buddy: "Ember  +33 XP" (§11, "TRAINING XP") */
.spar-results-team { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.spar-results-team:empty { display: none; }
.spar-results-team div { padding: 5px 12px; border-radius: 999px; background: rgb(143 233 255 / 14%); font: 700 14px "Nunito", sans-serif; }
.spar-results-team b { margin-left: 6px; color: #8fe9ff; font: 15px "Lilita One", sans-serif; }
.spar-results-actions { display: flex; justify-content: center; gap: 14px; margin-top: 4px; }
.big-btn.is-quiet { background: rgb(255 255 255 / 14%); color: #fff; box-shadow: none; }

/* full-screen moments: the start screen and the face-off */
.battle-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(6 3 24 / 74%); }
.battle-modal {
  position: relative;
  padding: 26px 36px 28px;
  border: 2px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: 0 0 0 4px rgb(10 4 40 / 90%), 0 0 40px rgb(192 123 255 / 60%), inset 0 0 50px rgb(110 60 255 / 25%);
  text-align: center;
  animation: battle-modalin 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.25);
}
@keyframes battle-modalin { from { opacity: 0; transform: translateY(30px) scale(0.92); } }
.battle-modal h1 { margin: 0; color: #ffe14d; font: 46px "Lilita One", sans-serif; letter-spacing: 1.5px; -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; }
.battle-modal p { margin: 8px 0 0; font: 700 16px "Nunito", sans-serif; opacity: 0.92; text-wrap: balance; }
.big-btn {
  margin-top: 20px;
  padding: 12px 40px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(#ffe98a, #ffb21a 60%, #ee8600);
  box-shadow: 0 0 0 4px #7a4a12, 0 7px 0 4px rgb(0 0 0 / 40%), inset 0 4px 0 rgb(255 255 255 / 65%);
  color: #3a1a00;
  font: 26px "Lilita One", sans-serif;
  letter-spacing: 1.2px;
  cursor: pointer;
}
.big-btn:hover { transform: translateY(-2px); }
.big-btn:active { transform: translateY(3px); }
.start-kicker { font: 900 13px "Nunito", sans-serif; letter-spacing: 3px; opacity: 0.8; text-transform: uppercase; }
.start-face { display: flex; align-items: flex-end; justify-content: center; gap: 26px; height: 150px; margin: 12px 0 4px; }
.start-face img { height: 130px; filter: drop-shadow(0 6px 0 rgb(0 0 0 / 35%)); }
.start-face img.opp { height: 150px; filter: drop-shadow(0 0 14px #a43cff); }
.start-face img.is-flipped { transform: scaleX(-1); }
.start-face .vs { align-self: center; color: #ffe14d; font: 44px "Lilita One", sans-serif; -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; }
.legend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.legend div { width: 150px; padding: 9px 8px 8px; border-radius: 14px; background: rgb(255 255 255 / 7%); font: 700 12.5px/1.25 "Nunito", sans-serif; }
.legend img { display: block; width: 30px; height: 30px; margin: 0 auto 3px; }
.legend b { display: block; font: 16px "Lilita One", sans-serif; letter-spacing: 0.6px; }
.battle-modal .start-tip { margin-top: 14px; font-size: 14.5px; }
.start-tip b { color: #ffb38a; }

.battle-faceoff { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(6 3 24 / 55%); pointer-events: auto; }
.vs-wrap { position: relative; width: 100%; height: 240px; }
.vs-side { position: absolute; top: 60px; font: 74px "Lilita One", sans-serif; letter-spacing: 2px; text-transform: uppercase; -webkit-text-stroke: 12px var(--ink); paint-order: stroke fill; }
.vs-left { right: 56%; color: #8fe9ff; animation: battle-vs-left 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.1); }
.vs-right { left: 56%; color: #e2a6ff; animation: battle-vs-right 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.1); }
.vs-mid { position: absolute; left: 50%; top: 52px; transform: translateX(-50%); color: #ffe14d; font: 92px "Lilita One", sans-serif; -webkit-text-stroke: 14px var(--ink); paint-order: stroke fill; animation: battle-vs-mid 0.28s cubic-bezier(0.3, 0, 0.2, 1) 0.22s both; }
.vs-goal { position: absolute; left: 0; right: 0; top: 176px; text-align: center; font: 26px "Lilita One", sans-serif; letter-spacing: 1px; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; animation: battle-vs-goal 0.3s ease 0.48s both; }
@keyframes battle-vs-left { from { transform: translateX(-700px); } }
@keyframes battle-vs-right { from { transform: translateX(700px); } }
@keyframes battle-vs-mid { from { transform: translateX(-50%) scale(5); opacity: 0; } }
@keyframes battle-vs-goal { from { opacity: 0; transform: translateY(20px); } }

@media (prefers-reduced-motion: reduce) {
  .battle-intent[data-stage].is-animating,
  .battle-preview, .play-btn, .battle-modal, .vs-left, .vs-right, .vs-mid, .vs-goal { animation: none; }
}

.battle-canvas-panel.is-closing .battle-canvas-shell {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .battle-canvas-shell {
    transition: none;
  }
}

.battle-canvas-debug-controls {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 55;
  display: none;
  width: min(320px, calc(100% - 36px));
  padding: 14px 14px 12px;
  border: 1px solid rgba(123, 241, 255, 0.5);
  border-radius: 14px;
  background: rgba(6, 10, 24, 0.86);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  color: #f6f2ff;
  font-family: Inter, system-ui, sans-serif;
  pointer-events: auto;
}

.battle-canvas-debug-controls.is-active {
  display: block;
}

.battle-canvas-debug-controls__eyebrow {
  margin: 0 0 6px;
  color: #7bf1ff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.battle-canvas-debug-controls__title {
  margin: 0 0 8px;
  font: 800 20px/1.05 "Lilita One", Rajdhani, Inter, system-ui, sans-serif;
}

.battle-canvas-debug-controls__hint {
  margin: 0 0 12px;
  color: rgba(235, 240, 255, 0.82);
  font-size: 12px;
  line-height: 1.45;
}

.battle-canvas-debug-controls__readout {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.battle-canvas-debug-controls__target {
  color: #fff4b2;
  font: 800 16px/1.1 "Lilita One", Rajdhani, Inter, system-ui, sans-serif;
}

.battle-canvas-debug-controls__values {
  color: #e7f8ff;
  font: 700 13px/1.4 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: pre-wrap;
}

.battle-canvas-debug-controls__controls {
  display: grid;
  gap: 14px;
}

.battle-canvas-debug-controls__move {
  display: grid;
  gap: 8px;
}

.battle-canvas-debug-controls__move-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.battle-canvas-debug-controls__move-row--up {
  width: calc((100% - 16px) / 3);
  margin: 0 auto;
}

.battle-canvas-debug-controls__scale {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.battle-canvas-debug-controls__button {
  min-height: 42px;
  padding: 0 8px;
  border: 1px solid rgba(143, 229, 255, 0.36);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(39, 54, 91, 0.96) 0%, rgba(17, 23, 45, 0.96) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  color: #f5fbff;
  font: 800 13px/1 "Lilita One", Rajdhani, Inter, system-ui, sans-serif;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
}

.battle-canvas-debug-controls__button:hover {
  filter: brightness(1.08);
}

.battle-canvas-debug-controls__button:active {
  transform: translateY(1px);
}

.battle-canvas-debug-highlight {
  position: absolute;
  z-index: 54;
  display: none;
  border: 2px solid #7bf1ff;
  border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(8, 15, 32, 0.82) inset, 0 0 18px rgba(123, 241, 255, 0.28);
  background: rgba(123, 241, 255, 0.08);
  pointer-events: none;
}

.battle-canvas-debug-highlight.is-active {
  display: block;
}

#battleCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #020711;
}

.hud {
  position: absolute;
  z-index: var(--z-hud);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 48px var(--shadow);
  backdrop-filter: blur(14px);
}

/* HUD button micro-interactions */
.hud button,
.buddy-book-button,
.player-profile-button,
.touch-pad button,
.action-strip button,
.buddy-book-header button,
.buddy-entry__resource button {
  transition: transform 0.18s cubic-bezier(0.25, 1, 0.5, 1);
}

.hud button:not(:disabled):hover,
.buddy-book-button:not(:disabled):hover,
.player-profile-button:not(:disabled):hover,
.touch-pad button:not(:disabled):hover,
.action-strip button:not(:disabled):hover,
.buddy-book-header button:not(:disabled):hover,
.buddy-entry__resource button:not(:disabled):hover {
  transform: scale(1.05);
}

.hud button:not(:disabled):active,
.buddy-book-button:not(:disabled):active,
.player-profile-button:not(:disabled):active,
.touch-pad button:not(:disabled):active,
.action-strip button:not(:disabled):active,
.buddy-book-header button:not(:disabled):active,
.buddy-entry__resource button:not(:disabled):active {
  transform: scale(0.95);
}

.hud .player-profile-button {
  transition: none;
}

.hud .player-profile-button:not(:disabled):hover,
.hud .player-profile-button:not(:disabled):active {
  transform: none;
}

.hud-settings-button,
.hud-element-info-button,
.hud-player-search-button {
  --settings-button-scale: 0.8;
  --settings-ref-px: var(--world-hud-control-ref-px, var(--hud-control-ref-px));
  --settings-panel-ref-px: var(--world-hud-panel-ref-px, var(--hud-panel-ref-px));
  --settings-mini-map-w: calc(281 * var(--settings-panel-ref-px));
  --settings-gap-to-map: calc(21 * var(--settings-ref-px));
  --settings-button-w: calc(92 * var(--settings-ref-px) * var(--settings-button-scale));
  --settings-button-h: calc(89 * var(--settings-ref-px) * var(--settings-button-scale));
  --settings-button-hover-h: calc(94 * var(--settings-ref-px) * var(--settings-button-scale));
  --settings-button-hover-y: calc(-5 * var(--settings-ref-px) * var(--settings-button-scale));
  --settings-art-y: 0px;
  --settings-art-h: var(--settings-button-h);
  --settings-hex-frame-h: calc(81 * var(--settings-ref-px) * var(--settings-button-scale));
  --settings-gear-size: calc(44 * var(--settings-ref-px) * var(--settings-button-scale));
  --settings-gear-frame-y: calc(18.5 * var(--settings-ref-px) * var(--settings-button-scale));
  position: absolute;
  z-index: var(--z-hud-raised);
  top: calc(var(--world-viewport-y) + calc(30 * var(--settings-panel-ref-px)));
  right: calc(100% - var(--world-viewport-x) - var(--world-viewport-w) + calc(30 * var(--settings-panel-ref-px)) + var(--settings-mini-map-w) + var(--settings-gap-to-map));
  display: block;
  width: var(--settings-button-w);
  height: var(--settings-button-h);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  color: transparent;
  cursor: pointer;
  overflow: visible;
  transition: opacity 160ms ease, transform 160ms ease, visibility 0s;
}

.hud-element-info-button {
  top: calc(var(--world-viewport-y) + calc(30 * var(--settings-panel-ref-px)) + var(--settings-button-h) + calc(12 * var(--settings-ref-px)));
}

.hud-player-search-button {
  top: calc(var(--world-viewport-y) + calc(30 * var(--settings-panel-ref-px)) + calc(2 * var(--settings-button-h)) + calc(24 * var(--settings-ref-px)));
}

.hud-fullscreen-button {
  --settings-button-scale: 0.74;
  --fullscreen-edge-margin: calc(13 * var(--settings-ref-px));
  top: auto;
  right: calc(100% - var(--world-viewport-x) - var(--world-viewport-w) + var(--fullscreen-edge-margin));
  bottom: calc(100% - var(--world-viewport-y) - var(--world-viewport-h) + var(--world-visual-bottom-inset, 0px) + var(--fullscreen-edge-margin));
}

.hud-settings-button::before,
.hud-element-info-button::before,
.hud-player-search-button::before {
  content: "";
  position: absolute;
  left: 0;
  top: var(--settings-art-y);
  z-index: 0;
  width: var(--settings-button-w);
  height: var(--settings-art-h);
  background: transparent url("/assets/critical/game-hud/button-setting-default.png") left top / 100% 100% no-repeat;
  pointer-events: none;
}

.hud-settings-button:not(:disabled):not([aria-disabled="true"]):not(.is-inactive):hover,
.hud-element-info-button:not(:disabled):not([aria-disabled="true"]):not(.is-inactive):hover,
.hud-player-search-button:not(:disabled):not([aria-disabled="true"]):not(.is-inactive):hover {
  --settings-art-y: var(--settings-button-hover-y);
  --settings-art-h: var(--settings-button-hover-h);
}

.hud-settings-button:not(:disabled):not([aria-disabled="true"]):not(.is-inactive):hover::before,
.hud-element-info-button:not(:disabled):not([aria-disabled="true"]):not(.is-inactive):hover::before,
.hud-player-search-button:not(:disabled):not([aria-disabled="true"]):not(.is-inactive):hover::before {
  background-image: url("/assets/critical/game-hud/button-setting-hover.png");
}

.hud-settings-button:not(:disabled):not([aria-disabled="true"]):not(.is-inactive):active,
.hud-element-info-button:not(:disabled):not([aria-disabled="true"]):not(.is-inactive):active,
.hud-player-search-button:not(:disabled):not([aria-disabled="true"]):not(.is-inactive):active {
  --settings-art-y: 0px;
  --settings-art-h: var(--settings-button-h);
}

.hud-settings-button:not(:disabled):not([aria-disabled="true"]):not(.is-inactive):active::before,
.hud-element-info-button:not(:disabled):not([aria-disabled="true"]):not(.is-inactive):active::before,
.hud-player-search-button:not(:disabled):not([aria-disabled="true"]):not(.is-inactive):active::before {
  background-image: url("/assets/critical/game-hud/button-setting-pressed.png");
}

.hud-settings-button:disabled,
.hud-settings-button[aria-disabled="true"],
.hud-settings-button.is-inactive,
.hud-element-info-button:disabled,
.hud-element-info-button[aria-disabled="true"],
.hud-element-info-button.is-inactive,
.hud-player-search-button:disabled,
.hud-player-search-button[aria-disabled="true"],
.hud-player-search-button.is-inactive {
  --settings-art-y: 0px;
  --settings-art-h: var(--settings-button-h);
}

.hud-settings-button:disabled::before,
.hud-settings-button[aria-disabled="true"]::before,
.hud-settings-button.is-inactive::before,
.hud-element-info-button:disabled::before,
.hud-element-info-button[aria-disabled="true"]::before,
.hud-element-info-button.is-inactive::before,
.hud-player-search-button:disabled::before,
.hud-player-search-button[aria-disabled="true"]::before,
.hud-player-search-button.is-inactive::before {
  background-image: url("/assets/critical/game-hud/button-setting-inactive.png");
}

.hud-settings-button:disabled,
.hud-settings-button[aria-disabled="true"],
.hud-settings-button.is-inactive,
.hud-element-info-button:disabled,
.hud-element-info-button[aria-disabled="true"],
.hud-element-info-button.is-inactive,
.hud-player-search-button:disabled,
.hud-player-search-button[aria-disabled="true"],
.hud-player-search-button.is-inactive {
  cursor: default;
}

.hud-settings-button:focus,
.hud-element-info-button:focus,
.hud-player-search-button:focus {
  outline: none;
}

.hud-settings-button:focus-visible,
.hud-element-info-button:focus-visible,
.hud-player-search-button:focus-visible {
  outline: calc(3 * var(--settings-ref-px)) solid rgba(126, 224, 184, 0.84);
  outline-offset: calc(4 * var(--settings-ref-px));
  border-radius: calc(16 * var(--settings-ref-px));
}

.hud-settings-button__icon,
.hud-element-info-button__icon,
.hud-player-search-button__icon {
  position: absolute;
  left: calc(24 * var(--settings-ref-px) * var(--settings-button-scale));
  top: calc(var(--settings-art-y) + var(--settings-gear-frame-y));
  z-index: 1;
  width: var(--settings-gear-size);
  height: var(--settings-gear-size);
  background: transparent url("/assets/critical/game-hud/icons/gear.png") center / 100% 100% no-repeat;
  pointer-events: none;
}

.hud-element-info-button__icon {
  background-image: url("/assets/critical/game-hud/icons/element-effectiveness-icon.png");
  background-size: contain;
}

.hud-player-search-button__icon {
  background-image: url("/assets/critical/game-hud/icons/player-search-icon.png");
  background-size: contain;
}

.hud-fullscreen-button__icon {
  display: grid;
  place-items: center;
  color: #f5fbff;
  background: none;
  font-family: Arial, sans-serif;
  font-size: calc(42 * var(--settings-ref-px) * var(--settings-button-scale));
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 0 calc(8 * var(--settings-ref-px)) rgba(79, 220, 255, 0.8);
}

.hud-fullscreen-button.is-fullscreen-active .hud-fullscreen-button__icon {
  color: #ffe98f;
  text-shadow: 0 0 calc(10 * var(--settings-ref-px)) rgba(255, 216, 107, 0.9);
}

.hud-canvas-control {
  --hud-trigger-ref-px: var(--world-hud-control-ref-px, var(--hud-control-ref-px));
  --hud-trigger-safe-bottom: var(--world-visual-bottom-inset, 0px);
  --hud-trigger-mobile-landscape-offset-y: 0px;
  position: absolute;
  z-index: var(--z-hud-raised);
  width: calc(116 * var(--hud-trigger-ref-px));
  height: calc(137 * var(--hud-trigger-ref-px));
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  opacity: 0;
  cursor: pointer;
}

.hud-canvas-control:focus {
  outline: none;
}

.hud-canvas-control:focus-visible {
  outline: calc(3 * var(--hud-trigger-ref-px)) solid rgba(126, 224, 184, 0.84);
  outline-offset: calc(4 * var(--hud-trigger-ref-px));
  border-radius: calc(16 * var(--hud-trigger-ref-px));
}

.hud-canvas-control--cards {
  --hud-trigger-left-inset: max(12px, calc(30 * var(--hud-trigger-ref-px)));
  --hud-trigger-group-h: calc(137 * var(--hud-trigger-ref-px));
  --hud-trigger-stack-gap: calc(40 * var(--hud-trigger-ref-px));
  left: calc(var(--world-viewport-x) + var(--hud-trigger-left-inset));
  top: calc(
    var(--world-viewport-y)
    + (var(--world-viewport-h) * 0.5)
    - var(--hud-trigger-group-h)
    - (var(--hud-trigger-stack-gap) * 0.5)
    + var(--hud-trigger-mobile-landscape-offset-y)
  );
}

.hud-canvas-control--buddies {
  --hud-trigger-left-inset: max(12px, calc(30 * var(--hud-trigger-ref-px)));
  --hud-trigger-stack-gap: calc(40 * var(--hud-trigger-ref-px));
  left: calc(var(--world-viewport-x) + var(--hud-trigger-left-inset));
  top: calc(
    var(--world-viewport-y)
    + (var(--world-viewport-h) * 0.5)
    + (var(--hud-trigger-stack-gap) * 0.5)
    + var(--hud-trigger-mobile-landscape-offset-y)
  );
}

.hud-joystick {
  --hud-joystick-ref-px: var(--world-hud-control-ref-px, var(--hud-control-ref-px));
  --hud-joystick-offset-x: 0px;
  --hud-joystick-offset-y: 0px;
  --hud-joystick-rest-offset-y: calc(-3 * var(--hud-joystick-ref-px));
  --hud-joystick-size: calc(191 * var(--hud-joystick-ref-px));
  --hud-joystick-cursor-size: calc(114 * var(--hud-joystick-ref-px));
  position: absolute;
  right: calc(100% - var(--world-viewport-x) - var(--world-viewport-w) + calc(72 * var(--hud-joystick-ref-px)));
  bottom: calc(100% - var(--world-viewport-y) - var(--world-viewport-h) + var(--world-visual-bottom-inset, 0px) + calc(58 * var(--hud-joystick-ref-px)));
  z-index: var(--z-hud-raised);
  width: var(--hud-joystick-size);
  height: var(--hud-joystick-size);
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.hud-joystick.is-active {
  cursor: grabbing;
}

.hud-joystick__base,
.hud-joystick__cursor {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hud-joystick__base {
  background: transparent url("/assets/critical/game-hud/joystick-outer-circle.png") center / 100% 100% no-repeat;
  filter: drop-shadow(0 10px 18px rgba(4, 7, 20, 0.42));
}

.hud-joystick__cursor {
  top: 50%;
  left: 50%;
  width: var(--hud-joystick-cursor-size);
  height: var(--hud-joystick-cursor-size);
  background: transparent url("/assets/critical/game-hud/joystick-cursor.png") center / 100% 100% no-repeat;
  transform: translate(
    -50%,
    -50%
  ) translate(
    var(--hud-joystick-offset-x),
    calc(var(--hud-joystick-offset-y) + var(--hud-joystick-rest-offset-y))
  );
  transition: transform 140ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.hud-joystick.is-active .hud-joystick__cursor {
  transition: none;
}

.starborn-canvas-button-host {
  position: relative;
  color: transparent;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.starborn-canvas-button-host::before {
  display: none !important;
  content: none !important;
}

.starborn-canvas-button-host > .starborn-canvas-button {
  position: absolute;
  bottom: 0;
  left: 50%;
  z-index: 1;
  display: block;
  pointer-events: none;
  transform: translateX(-50%);
}

.starborn-canvas-button-host > :not(.starborn-canvas-button) {
  visibility: hidden;
}


body.is-overlay-ui-hidden .mvp-hud,
body.is-overlay-ui-hidden .stat-panel,
body.is-overlay-ui-hidden .buddy-recharge-tray,
body.is-overlay-ui-hidden .mini-map-wrap,
body.is-overlay-ui-hidden .hud-settings-button,
body.is-overlay-ui-hidden .hud-element-info-button,
body.is-overlay-ui-hidden .hud-player-search-button,
body.is-overlay-ui-hidden .dev-mod-panel,
body.is-overlay-ui-hidden .hud-canvas-control,
body.is-overlay-ui-hidden .hud-joystick,
body.is-overlay-ui-hidden .buddy-book-button,
body.is-overlay-ui-hidden .touch-pad {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px) scale(0.985);
}

body.is-tutorial-framed-popup-hud-hidden .mvp-hud,
body.is-tutorial-framed-popup-hud-hidden .stat-panel,
body.is-tutorial-framed-popup-hud-hidden .buddy-recharge-tray,
body.is-tutorial-framed-popup-hud-hidden .mini-map-wrap,
body.is-tutorial-framed-popup-hud-hidden .hud-settings-button,
body.is-tutorial-framed-popup-hud-hidden .hud-element-info-button,
body.is-tutorial-framed-popup-hud-hidden .hud-player-search-button,
body.is-tutorial-framed-popup-hud-hidden .dev-mod-panel,
body.is-tutorial-framed-popup-hud-hidden .hud-canvas-control,
body.is-tutorial-framed-popup-hud-hidden .hud-joystick,
body.is-tutorial-framed-popup-hud-hidden .buddy-book-button,
body.is-tutorial-framed-popup-hud-hidden .touch-pad {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px) scale(0.985);
}

body.is-overlay-ui-hidden .action-strip {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, 8px) scale(var(--action-strip-overlay-scale));
}

body.is-tutorial-framed-popup-hud-hidden .action-strip {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, 8px) scale(var(--action-strip-overlay-scale));
}

body.is-tutorial-conversation-input-locked .mvp-hud,
body.is-tutorial-conversation-input-locked .stat-panel,
body.is-tutorial-conversation-input-locked .buddy-recharge-tray,
body.is-tutorial-conversation-input-locked .mini-map-wrap,
body.is-tutorial-conversation-input-locked .hud-settings-button,
body.is-tutorial-conversation-input-locked .hud-element-info-button,
body.is-tutorial-conversation-input-locked .hud-player-search-button,
body.is-tutorial-conversation-input-locked .dev-mod-panel,
body.is-tutorial-conversation-input-locked .hud-canvas-control,
body.is-tutorial-conversation-input-locked .hud-joystick,
body.is-tutorial-conversation-input-locked .action-strip,
body.is-tutorial-conversation-input-locked .buddy-book-button,
body.is-tutorial-conversation-input-locked .touch-pad {
  pointer-events: none;
}

body.is-overlay-ui-hidden .mvp-hud,
body.is-overlay-ui-hidden .stat-panel,
body.is-overlay-ui-hidden .buddy-recharge-tray,
body.is-overlay-ui-hidden .mini-map-wrap,
body.is-overlay-ui-hidden .hud-settings-button,
body.is-overlay-ui-hidden .hud-element-info-button,
body.is-overlay-ui-hidden .hud-player-search-button,
body.is-overlay-ui-hidden .dev-mod-panel,
body.is-overlay-ui-hidden .hud-canvas-control,
body.is-overlay-ui-hidden .hud-joystick,
body.is-overlay-ui-hidden .action-strip,
body.is-overlay-ui-hidden .buddy-book-button,
body.is-overlay-ui-hidden .touch-pad {
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    visibility 0s 160ms;
}

.mvp-hud {
  --mvp-hud-left-offset: calc(-30 * var(--hud-ref-px));
  position: absolute;
  top: calc(var(--world-viewport-y) + calc(30 * var(--hud-ref-px)));
  left: calc(var(--world-viewport-x) + var(--mvp-hud-left-offset));
  z-index: var(--z-hud);
  width: calc(400 * var(--hud-ref-px));
  height: calc(234 * var(--hud-ref-px));
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transform-origin: top left;
}

.mvp-hud * {
  pointer-events: none;
}

.hud-top {
  top: 0;
  left: 0;
  right: auto;
  position: absolute;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background-color: transparent;
  background-image: url("/assets/critical/game-hud/profile-section-frame.png");
  background-position: left calc(-1 * var(--hud-ref-px));
  background-repeat: no-repeat;
  background-size: calc(401 * var(--hud-ref-px)) calc(317 * var(--hud-ref-px));
  box-shadow: none;
  backdrop-filter: none;
  transform-origin: top left;
}

.brand,
.brand-mark,
.brand-copy {
  display: none;
}

.player-chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: end;
  min-width: 0;
  min-height: 32px;
}

.player-chip[hidden] {
  display: none;
}

.player-chip__name {
  min-width: 0;
  overflow: hidden;
  color: #dce8e2;
  font-family: var(--font-stat);
  font-size: 14px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.player-profile-button {
  --profile-trigger-image: radial-gradient(circle at 50% 40%, #3e6f98 0%, #3e6f98 18%, #173d63 54%, #081c35 100%);
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  min-width: 0;
  max-width: none;
  height: 100%;
  min-height: 0;
  max-height: none;
  overflow: visible;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

.player-profile-button:not(:disabled):hover,
.player-profile-button:not(:disabled):active {
  transform: none;
}

.player-profile-button span {
  --profile-avatar-art-position-y: calc(50% + 4.65%);
  --profile-avatar-art-scale: 113.95%;
  --profile-avatar-inner-mask-start: 96%;
  --profile-avatar-inner-mask-end: 98%;
  position: absolute;
  left: calc(38 * var(--hud-ref-px));
  top: calc(54.1 * var(--hud-ref-px));
  display: block;
  width: calc(126.8 * var(--hud-ref-px));
  height: calc(126.8 * var(--hud-ref-px));
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 0;
  background:
    url("/assets/critical/game-hud/hud-avatar-frame.png")
    center / contain
    no-repeat;
  pointer-events: none;
}

.player-profile-button span::before {
  position: absolute;
  inset: 0;
  border-radius: 0;
  background-image: var(--profile-trigger-image);
  background-position: center var(--profile-avatar-art-position-y);
  background-repeat: no-repeat;
  background-size: var(--profile-avatar-art-scale) var(--profile-avatar-art-scale);
  content: "";
  -webkit-mask:
    radial-gradient(circle closest-side at center, #000 var(--profile-avatar-inner-mask-start), transparent var(--profile-avatar-inner-mask-end));
  mask:
    radial-gradient(circle closest-side at center, #000 var(--profile-avatar-inner-mask-start), transparent var(--profile-avatar-inner-mask-end));
  z-index: 1;
}

.player-profile-button span::after {
  position: absolute;
  inset: 0;
  background:
    url("/assets/critical/game-hud/hud-avatar-frame.png")
    center / contain
    no-repeat;
  content: "";
  -webkit-mask:
    radial-gradient(circle closest-side at center, transparent var(--profile-avatar-inner-mask-start), #000 var(--profile-avatar-inner-mask-end));
  mask:
    radial-gradient(circle closest-side at center, transparent var(--profile-avatar-inner-mask-start), #000 var(--profile-avatar-inner-mask-end));
  z-index: 2;
}

.profile-summary {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.profile-summary__name {
  position: absolute;
  left: calc(174 * var(--hud-ref-px));
  top: calc(49 * var(--hud-ref-px));
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: calc(176 * var(--hud-ref-px));
  height: calc(22 * var(--hud-ref-px));
  min-width: 0;
  overflow: hidden;
  color: #ffffff;
  font-family: "Lilita One", Rajdhani, Inter, system-ui, sans-serif;
  font-size: calc(20 * var(--hud-ref-px));
  font-weight: 400;
  line-height: 1;
  text-align: left;
  text-overflow: ellipsis;
  text-shadow:
    0 3px 0 #0b0718,
    0 0 6px rgba(0, 0, 0, 0.72);
  text-transform: uppercase;
  white-space: nowrap;
}

.profile-summary__tag {
  --profile-tag-bg: url("/assets/critical/game-hud/button-profile-world-tab-default.png");
  --profile-tag-image-top: 0px;
  --profile-tag-source-aspect: 154 / 46;
  --profile-tag-face-height: calc(48 * var(--hud-ref-px));
  --profile-tag-face-center-y: calc(24 * var(--hud-ref-px));
  --profile-tag-text-inset-left: calc(50 * var(--hud-ref-px));
  --profile-tag-text-inset-right: calc(8 * var(--hud-ref-px));
  position: absolute;
  display: grid;
  place-items: center;
  height: calc(52.57 * var(--hud-ref-px));
  min-width: 0;
  margin-top: 0;
  color: #ffffff;
  font-family: var(--font-display), Rajdhani, Inter, system-ui, sans-serif;
  font-size: calc(18 * var(--hud-ref-px));
  font-weight: 400;
  line-height: 0.95;
  text-align: center;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.72);
  text-transform: uppercase;
  background: transparent;
  overflow: visible;
}

.profile-summary__tag::before {
  position: absolute;
  top: var(--profile-tag-image-top);
  left: 0;
  z-index: 0;
  width: 100%;
  height: auto;
  aspect-ratio: var(--profile-tag-source-aspect);
  background-image: var(--profile-tag-bg);
  background-position: top center;
  background-repeat: no-repeat;
  background-size: 100% auto;
  content: "";
  pointer-events: none;
}

.profile-summary__tag::after {
  position: absolute;
  left: calc(12 * var(--hud-ref-px));
  top: calc(var(--profile-tag-image-top) + var(--profile-tag-face-center-y) - calc(15 * var(--hud-ref-px)));
  z-index: 1;
  width: calc(30 * var(--hud-ref-px));
  height: calc(30 * var(--hud-ref-px));
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  content: "";
  pointer-events: none;
}

.profile-summary__tag--world {
  left: calc(174 * var(--hud-ref-px));
  top: calc(81 * var(--hud-ref-px));
  width: calc(176 * var(--hud-ref-px));
  --profile-tag-bg: url("/assets/critical/game-hud/button-profile-world-tab-default.png");
  --profile-tag-source-aspect: 154 / 46;
  --profile-tag-text-inset-right: calc(12 * var(--hud-ref-px));
}

.profile-summary__tag--world::after {
  background-image: url("/assets/critical/game-hud/icons/worlds.png");
}

.profile-summary__tag--reality {
  left: calc(174 * var(--hud-ref-px));
  top: calc(142 * var(--hud-ref-px));
  width: calc(176 * var(--hud-ref-px));
  --profile-tag-bg: url("/assets/critical/game-hud/button-game-hud-secondary-default.png");
  --profile-tag-source-aspect: 154 / 46;
}

.profile-summary__tag--reality::after {
  background-image: url("/assets/critical/game-hud/icons/realities.png");
}

.profile-summary__tag[data-state="hover"] {
  --profile-tag-image-top: calc(-3.43 * var(--hud-ref-px));
  --profile-tag-source-aspect: 154 / 49;
}

.profile-summary__tag--world[data-state="hover"] {
  --profile-tag-bg: url("/assets/critical/game-hud/button-profile-world-tab-hover.png");
}

.profile-summary__tag--world[data-state="pressed"] {
  --profile-tag-bg: url("/assets/critical/game-hud/button-profile-world-tab-pressed.png");
  --profile-tag-image-top: 0px;
  --profile-tag-source-aspect: 154 / 46;
}

.profile-summary__tag--world[data-state="inactive"] {
  --profile-tag-bg: url("/assets/critical/game-hud/button-game-hud-inactive.png");
  --profile-tag-image-top: 0px;
  --profile-tag-source-aspect: 154 / 46;
}

.profile-summary__tag--reality[data-state="hover"] {
  --profile-tag-bg: url("/assets/critical/game-hud/button-game-hud-secondary-hover.png");
}

.profile-summary__tag--reality[data-state="pressed"] {
  --profile-tag-bg: url("/assets/critical/game-hud/button-game-hud-secondary-pressed.png");
  --profile-tag-image-top: 0px;
  --profile-tag-source-aspect: 154 / 46;
}

.profile-summary__tag--reality[data-state="inactive"] {
  --profile-tag-bg: url("/assets/critical/game-hud/button-game-hud-inactive.png");
  --profile-tag-image-top: 0px;
  --profile-tag-source-aspect: 154 / 46;
}

.player-profile-button:disabled + .profile-summary .profile-summary__tag,
.player-profile-button[aria-disabled="true"] + .profile-summary .profile-summary__tag,
.player-profile-button.is-inactive + .profile-summary .profile-summary__tag {
  --profile-tag-bg: url("/assets/critical/game-hud/button-game-hud-inactive.png");
  --profile-tag-image-top: 0px;
  --profile-tag-source-aspect: 154 / 46;
}

.profile-summary__tag span {
  position: absolute;
  top: var(--profile-tag-image-top);
  left: var(--profile-tag-text-inset-left);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(100% - var(--profile-tag-text-inset-left) - var(--profile-tag-text-inset-right));
  height: var(--profile-tag-face-height);
  margin: 0;
  overflow: hidden;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-summary__tag.profile-summary__tag--world span,
.profile-summary__tag.profile-summary__tag--reality span {
  justify-content: flex-start;
  text-align: left;
}

.player-profile-overlay-button {
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.player-profile-overlay-button:focus {
  outline: none;
}

.player-profile-overlay-button:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(255, 248, 210, 0.96),
    0 0 0 5px rgba(117, 214, 255, 0.36),
    0 0 20px rgba(117, 214, 255, 0.42);
}

.player-profile-overlay-button.is-focused {
  box-shadow:
    0 0 0 2px rgba(255, 248, 210, 0.96),
    0 0 0 5px rgba(117, 214, 255, 0.36),
    0 0 20px rgba(117, 214, 255, 0.42);
}

.player-profile-call-sign-input {
  position: absolute;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff8ef;
  font-family: "Lilita One", Rajdhani, Inter, sans-serif;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.9), 0 0 5px rgba(0, 0, 0, 0.72);
  outline: none;
  caret-color: #ffd329;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-fill-color: #fff8ef;
}

.player-profile-call-sign-input::placeholder {
  color: rgba(191, 239, 255, 0.56);
  opacity: 1;
  text-shadow: none;
  -webkit-text-fill-color: rgba(191, 239, 255, 0.56);
}

.player-profile-call-sign-input:disabled {
  cursor: default;
  -webkit-text-fill-color: rgba(255, 248, 239, 0.58);
}

.player-profile-close-button:focus-visible,
.player-profile-avatar-button:focus-visible,
.player-profile-close-button.is-focused,
.player-profile-avatar-button.is-focused {
  border-radius: 999px;
}

.player-profile-avatar-switch-button {
  color: transparent;
}

.player-profile-avatar-switch-button:disabled {
  cursor: default;
}

.player-profile-avatar-switch-button--card:focus-visible {
  background: rgba(117, 214, 255, 0.08);
}

.player-profile-avatar-switch-button--card.is-focused {
  background: rgba(117, 214, 255, 0.08);
}

.player-profile-avatar-switch-button--card.is-selected:focus-visible,
.player-profile-avatar-switch-button--card.is-selected.is-focused {
  box-shadow:
    0 0 0 2px rgba(255, 232, 119, 0.98),
    0 0 0 5px rgba(117, 214, 255, 0.38),
    0 0 22px rgba(255, 216, 106, 0.34);
}

.touch-pad button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  outline: none;
}

.stat-panel {
  --stat-panel-scale: 1.1;
  --stat-panel-ref-px: var(--hud-ref-px);
  --stat-panel-frame-w: calc(399.987 * var(--stat-panel-ref-px));
  --stat-panel-frame-h: calc(159.624 * var(--stat-panel-ref-px));
  --stat-panel-content-x: calc(83.38 * var(--stat-panel-ref-px));
  --stat-panel-row-w: calc(245.36 * var(--stat-panel-ref-px));
  --stat-panel-track-h: calc(20.208 * var(--stat-panel-ref-px));
  --stat-panel-value-w: calc(74 * var(--stat-panel-ref-px));
  --stat-panel-label-w: calc(157.317 * var(--stat-panel-ref-px));
  --stat-panel-side-x: calc(364.31 * var(--stat-panel-ref-px));
  --stat-panel-left-offset: calc(-57.99 * var(--stat-panel-ref-px));
  --stat-panel-left: calc(var(--world-viewport-x) + max(0px, var(--stat-panel-left-offset)));
  --stat-panel-slide-x: 0px;
  --stat-panel-rail-peek-x: 0px;
  left: var(--stat-panel-left);
  top: calc(var(--world-viewport-y) + calc(210 * var(--stat-panel-ref-px)));
  display: block;
  width: calc(var(--stat-panel-frame-w) * var(--stat-panel-scale));
  height: calc(var(--stat-panel-frame-h) * var(--stat-panel-scale));
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  transform: translateX(var(--stat-panel-slide-x));
  transition: opacity 160ms ease, transform 160ms ease, visibility 0s;
  will-change: transform;
}

.stat-panel.is-collapsed {
  --stat-panel-slide-x: calc((var(--stat-panel-left) * -1) - (var(--stat-panel-side-x) * var(--stat-panel-scale)) + var(--stat-panel-rail-peek-x));
}

.stat-panel-menu {
  position: relative;
  display: block;
  width: var(--stat-panel-frame-w);
  height: var(--stat-panel-frame-h);
  background: transparent url("/assets/critical/game-hud/recharge-tray-frame.png") center / 100% 100% no-repeat;
  transform: scale(var(--stat-panel-scale));
  transform-origin: top left;
}

.stat-panel__row {
  position: absolute;
  left: var(--stat-panel-content-x);
  display: grid;
  gap: calc(8.47 * var(--stat-panel-ref-px));
  width: var(--stat-panel-row-w);
  min-height: calc(48 * var(--stat-panel-ref-px));
}

.stat-panel__row:first-child {
  top: calc(22.452 * var(--stat-panel-ref-px));
}

.stat-panel__row:nth-child(2) {
  top: calc(90.282 * var(--stat-panel-ref-px));
}

.stat-panel__label {
  position: relative;
  display: block;
  width: var(--stat-panel-row-w);
  height: calc(17.13 * var(--stat-panel-ref-px));
}

.stat-panel__label span,
.stat-panel__label strong {
  color: #ffffff;
  font-family: "Lilita One", Rajdhani, Inter, system-ui, sans-serif;
  font-size: calc(16 * var(--stat-panel-ref-px));
  font-variant-numeric: tabular-nums;
  font-weight: 400;
  line-height: normal;
  text-shadow:
    0 2px 0 #080513,
    0 0 5px rgba(0, 0, 0, 0.85);
  text-transform: uppercase;
}

.stat-panel__label span {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: var(--stat-panel-label-w);
  font-family: "Inter", system-ui, sans-serif;
  font-weight: 500;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-panel__label strong {
  position: absolute;
  right: 0;
  top: calc(-0.79 * var(--stat-panel-ref-px));
  display: block;
  width: var(--stat-panel-value-w);
  min-width: 0;
  text-align: right;
  white-space: nowrap;
}

.stat-panel__track {
  --stat-panel-progress-radius: calc(var(--stat-panel-track-h) * 4 / 15.208);
  --stat-panel-progress-border: calc(var(--stat-panel-track-h) * 2 / 15.208);
  position: relative;
  width: var(--stat-panel-row-w);
  height: var(--stat-panel-track-h);
  overflow: hidden;
  border: 0;
  border-radius: var(--stat-panel-progress-radius);
  background: #050715;
  box-shadow:
    inset 0 0 0 var(--stat-panel-progress-border) #474747,
    inset 0 0 0 calc(var(--stat-panel-progress-border) + 1px) rgba(255, 255, 255, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.18);
}

.stat-panel__fill {
  --stat-panel-fill-border-color: #ddfff9;
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  width: 0%;
  height: 100%;
  overflow: hidden;
  border-radius: var(--stat-panel-progress-radius);
  transition: width 180ms ease;
}

.stat-panel__fill::before {
  position: absolute;
  z-index: 1;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 var(--stat-panel-progress-border) var(--stat-panel-fill-border-color);
  content: "";
  pointer-events: none;
}

.stat-panel__progress-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.stat-panel__progress-canvas.is-pixi-ready {
  opacity: 1;
}

.buddy-recharge-tray__progress-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.buddy-recharge-tray__progress-canvas.is-pixi-ready {
  opacity: 1;
}

.stat-panel__fill--buddies {
  --stat-panel-fill-border-color: #ddfff9;
  background: linear-gradient(90deg, #1fd99f 0%, #44efc4 100%);
}

.stat-panel__fill--monsters {
  --stat-panel-fill-border-color: #ffe2e6;
  background: linear-gradient(90deg, #ff334d 0%, #ff577a 100%);
}

.stat-panel__players {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.stat-panel__side-label {
  --rail-arrow-offset-x: calc(1px * var(--stat-panel-scale));
  position: absolute;
  left: var(--stat-panel-side-x);
  top: calc(37.191 * var(--stat-panel-ref-px));
  display: block;
  width: calc(24.756 * var(--stat-panel-ref-px));
  height: calc(84.169 * var(--stat-panel-ref-px));
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #ffffff;
  cursor: pointer;
  font-family: "Lilita One", Rajdhani, Inter, system-ui, sans-serif;
  font-size: calc(10 * var(--stat-panel-ref-px));
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1;
  opacity: 1;
  text-align: center;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8);
  text-transform: uppercase;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.stat-panel__side-label::before {
  position: absolute;
  left: calc(50% + var(--rail-arrow-offset-x, 0px));
  top: calc(11.17 * var(--stat-panel-ref-px));
  display: block;
  width: calc(11.978 * var(--stat-panel-ref-px));
  height: calc(11.17 * var(--stat-panel-ref-px));
  background: transparent url("/assets/critical/game-hud/progress-polygon-icon.png") center / 100% 100% no-repeat;
  content: "";
  transform: translateX(-50%);
  transition: transform 160ms ease;
}

.stat-panel.is-collapsed .stat-panel__side-label::before {
  transform: translateX(-50%) scaleX(-1);
}

.stat-panel__side-label span {
  position: absolute;
  left: 50%;
  top: calc(25.34 * var(--stat-panel-ref-px));
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(24.756 * var(--stat-panel-ref-px));
  height: calc(47.659 * var(--stat-panel-ref-px));
  transform: translateX(-50%);
  writing-mode: vertical-rl;
}

.hud .stat-panel__side-label,
.hud .stat-panel__side-label:not(:disabled):hover,
.hud .stat-panel__side-label:not(:disabled):active {
  transform: none;
}

.stat-panel__side-label:focus-visible,
.buddy-recharge-tray__rail:focus-visible {
  outline: none;
  filter: drop-shadow(0 0 calc(7 * var(--stat-panel-ref-px, 1px)) rgba(255, 248, 210, 0.9));
}

.stat-panel {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

.stat-panel *,
.stat-panel__side-label {
  pointer-events: none;
}

.buddy-recharge-tray {
  --recharge-tray-ref-px: var(--hud-ref-px);
  --recharge-tray-scale: 1.15;
  --recharge-tray-frame-w: calc(360 * var(--recharge-tray-ref-px));
  --recharge-tray-frame-h: calc(223 * var(--recharge-tray-ref-px));
  --recharge-tray-roster-only-h: calc(83 * var(--recharge-tray-ref-px));
  --recharge-tray-left: calc(-39 * var(--recharge-tray-ref-px));
  --recharge-tray-bottom: calc(24 * var(--recharge-tray-ref-px));
  --recharge-tray-safe-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--world-visual-bottom-inset, 0px));
  --recharge-tray-rail-x: calc(360 * var(--recharge-tray-ref-px));
  --recharge-tray-slide-x: 0px;
  --recharge-tray-rail-peek-x: 0px;
  left: calc(var(--world-viewport-x) + var(--recharge-tray-left));
  bottom: calc(100% - var(--world-viewport-y) - var(--world-viewport-h) + var(--recharge-tray-bottom) + var(--recharge-tray-safe-bottom));
  z-index: var(--z-hud-raised);
  display: block;
  width: calc(var(--recharge-tray-frame-w) * var(--recharge-tray-scale));
  height: calc(var(--recharge-tray-frame-h) * var(--recharge-tray-scale));
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  opacity: 0;
  overflow: visible;
  pointer-events: none;
  transform: translateX(var(--recharge-tray-slide-x));
  transition: opacity 160ms ease, transform 160ms ease, visibility 0s;
  will-change: transform;
}

.buddy-recharge-tray.is-roster-only {
  height: calc(var(--recharge-tray-roster-only-h) * var(--recharge-tray-scale));
}

.buddy-recharge-tray.is-collapsed {
  --recharge-tray-slide-x: calc((var(--recharge-tray-left) * -1) - (var(--recharge-tray-rail-x) * var(--recharge-tray-scale)) + var(--recharge-tray-rail-peek-x));
}

.buddy-recharge-tray[hidden] {
  display: none;
}

.buddy-recharge-tray * {
  pointer-events: none;
}

.buddy-recharge-tray__panel {
  position: relative;
  display: block;
  width: var(--recharge-tray-frame-w);
  height: var(--recharge-tray-frame-h);
  background: transparent url("/assets/critical/game-hud/recharge-tray-panel-frame.png") center / 100% 100% no-repeat;
  transform: scale(var(--recharge-tray-scale));
  transform-origin: top left;
}

.buddy-recharge-tray.is-roster-only .buddy-recharge-tray__panel {
  height: var(--recharge-tray-roster-only-h);
  border-radius: calc(24 * var(--recharge-tray-ref-px));
  background-color: #080626;
  background-image: url("/assets/critical/game-hud/recharge-tray-compact-frame.png");
}

.buddy-recharge-tray.is-roster-only .buddy-recharge-tray__frame-ornament,
.buddy-recharge-tray.is-roster-only .buddy-recharge-tray__portrait,
.buddy-recharge-tray.is-roster-only .buddy-recharge-tray__name,
.buddy-recharge-tray.is-roster-only .buddy-recharge-tray__resource,
.buddy-recharge-tray.is-roster-only .buddy-recharge-tray__warning,
.buddy-recharge-tray.is-roster-only .buddy-recharge-tray__rail {
  display: none;
}

.buddy-recharge-tray__frame-ornament {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  display: none;
  pointer-events: none;
}

.buddy-recharge-tray__portrait,
.buddy-recharge-tray__name,
.buddy-recharge-tray__resource-icon,
.buddy-recharge-tray__meter,
.buddy-recharge-tray__button,
.buddy-recharge-tray__warning,
.buddy-recharge-tray__rail {
  z-index: 1;
}

.buddy-recharge-tray__portrait {
  --recharge-tray-avatar-inset: calc(2.5 * var(--recharge-tray-ref-px));
  position: absolute;
  left: calc(60 * var(--recharge-tray-ref-px));
  top: calc(23 * var(--recharge-tray-ref-px));
  width: calc(63 * var(--recharge-tray-ref-px));
  height: calc(63 * var(--recharge-tray-ref-px));
  border-radius: 999px;
  cursor: default;
  overflow: hidden;
  pointer-events: auto;
}

.buddy-recharge-tray[data-can-collapse-roster="true"] .buddy-recharge-tray__portrait {
  cursor: pointer;
}

.buddy-recharge-tray__portrait::before {
  position: absolute;
  inset: var(--recharge-tray-avatar-inset);
  z-index: 1;
  border-radius: 999px;
  background:
    radial-gradient(circle at 42% 28%, #57f4ff 0 10%, #0c78da 52%, #10195c 100%);
  content: "";
}

.buddy-recharge-tray__portrait::after {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: transparent url("/assets/critical/game-hud/recharge-buddy-selected-frame.png") center / 100% 100% no-repeat;
  content: "";
}

.buddy-recharge-tray__portrait img {
  position: absolute;
  left: var(--recharge-tray-avatar-inset);
  top: var(--recharge-tray-avatar-inset);
  z-index: 2;
  display: block;
  width: calc(100% - var(--recharge-tray-avatar-inset) - var(--recharge-tray-avatar-inset));
  height: calc(100% - var(--recharge-tray-avatar-inset) - var(--recharge-tray-avatar-inset));
  border-radius: 999px;
  object-fit: contain;
}

.buddy-recharge-tray__portrait img:not([src]),
.buddy-recharge-tray__portrait img[src=""] {
  display: none;
}

.buddy-recharge-tray__name,
.buddy-recharge-tray__status,
.buddy-recharge-tray__rail-label,
.buddy-recharge-tray__value {
  color: #ffffff;
  font-family: "Lilita One", Rajdhani, Inter, system-ui, sans-serif;
  font-weight: 400;
  letter-spacing: 0;
  text-shadow:
    0 2px 0 #000000,
    0 0 5px rgba(0, 0, 0, 0.85);
  text-transform: uppercase;
}

.buddy-recharge-tray__name {
  position: absolute;
  left: calc(140 * var(--recharge-tray-ref-px));
  top: calc(24 * var(--recharge-tray-ref-px));
  display: block;
  width: calc(97 * var(--recharge-tray-ref-px));
  height: calc(24 * var(--recharge-tray-ref-px));
  overflow: hidden;
  font-size: calc(18 * var(--recharge-tray-ref-px));
  line-height: calc(24 * var(--recharge-tray-ref-px));
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.buddy-recharge-tray__resource-icon,
.buddy-recharge-tray__meter,
.buddy-recharge-tray__button {
  position: absolute;
}

.buddy-recharge-tray__resource {
  display: contents;
}

.buddy-recharge-tray__resource--hp .buddy-recharge-tray__resource-icon {
  left: calc(138 * var(--recharge-tray-ref-px));
  top: calc(61 * var(--recharge-tray-ref-px));
  width: calc(23 * var(--recharge-tray-ref-px));
  height: calc(20 * var(--recharge-tray-ref-px));
  background: transparent url("/assets/critical/icons/heart.png") center / 100% 100% no-repeat;
}

.buddy-recharge-tray__resource--mp .buddy-recharge-tray__resource-icon {
  left: calc(133 * var(--recharge-tray-ref-px));
  top: calc(100.5 * var(--recharge-tray-ref-px));
  width: calc(32 * var(--recharge-tray-ref-px));
  height: calc(32 * var(--recharge-tray-ref-px));
  background: transparent url("/assets/critical/icons/mp.png") center / 100% 100% no-repeat;
}

.buddy-recharge-tray__meter {
  --recharge-tray-progress-radius: calc(19 * var(--recharge-tray-ref-px) * 4 / 15.208);
  --recharge-tray-progress-border: calc(19 * var(--recharge-tray-ref-px) * 2 / 15.208);
  --recharge-tray-progress-highlight-h: calc(19 * var(--recharge-tray-ref-px) * 6.083 / 15.208);
  width: calc(127 * var(--recharge-tray-ref-px));
  height: calc(19 * var(--recharge-tray-ref-px));
  overflow: hidden;
  border-radius: var(--recharge-tray-progress-radius);
  background: #000000;
  box-shadow:
    inset 0 0 0 var(--recharge-tray-progress-border) #474747,
    0 1px 0 rgba(255, 255, 255, 0.15);
}

.buddy-recharge-tray__resource--hp .buddy-recharge-tray__meter {
  left: calc(170 * var(--recharge-tray-ref-px));
  top: calc(61 * var(--recharge-tray-ref-px));
}

.buddy-recharge-tray__resource--mp .buddy-recharge-tray__meter {
  left: calc(170 * var(--recharge-tray-ref-px));
  top: calc(107 * var(--recharge-tray-ref-px));
}

.buddy-recharge-tray__fill {
  --recharge-tray-fill-border-color: #ddfff9;
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  width: 0%;
  height: 100%;
  overflow: hidden;
  border-radius: var(--recharge-tray-progress-radius);
  transition: width 180ms ease;
}

.buddy-recharge-tray__fill::before {
  position: absolute;
  z-index: 2;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 var(--recharge-tray-progress-border) var(--recharge-tray-fill-border-color);
  content: "";
  pointer-events: none;
}

.buddy-recharge-tray__fill::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  content: "";
}

.buddy-recharge-tray__fill--hp {
  --recharge-tray-fill-border-color: #ff8d94;
  background: linear-gradient(180deg, #ec1e2c 0%, #710008 100%);
}

.buddy-recharge-tray__fill--hp::after {
  background: #ff5560;
}

.buddy-recharge-tray__fill--mp {
  --recharge-tray-fill-border-color: #b690ff;
  background: linear-gradient(180deg, #915eff 0%, #3718b5 100%);
}

.buddy-recharge-tray__fill--mp::after {
  background: #a272ff;
}

.buddy-recharge-tray__button {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  box-shadow: none;
  color: transparent;
  font-family: "Lilita One", Rajdhani, Inter, system-ui, sans-serif;
  line-height: 1;
}

.buddy-recharge-tray__button--hp {
  left: calc(309 * var(--recharge-tray-ref-px));
  top: calc(53 * var(--recharge-tray-ref-px));
  width: calc(35 * var(--recharge-tray-ref-px));
  height: calc(36 * var(--recharge-tray-ref-px));
  background-image: url("/assets/critical/game-hud/pet-hp-plus-button-default.png");
}

.buddy-recharge-tray__button--mp {
  left: calc(309 * var(--recharge-tray-ref-px));
  top: calc(99 * var(--recharge-tray-ref-px));
  width: calc(35 * var(--recharge-tray-ref-px));
  height: calc(36 * var(--recharge-tray-ref-px));
  background-image: url("/assets/critical/game-hud/pet-mp-plus-button-default.png");
}

.buddy-recharge-tray__button--hp:not(:disabled):hover {
  --recharge-plus-y-offset: calc(-36 * var(--recharge-tray-ref-px) * 2 / 59);
  background-image: url("/assets/critical/game-hud/pet-hp-plus-button-hover.png");
}

.buddy-recharge-tray__button--mp:not(:disabled):hover {
  --recharge-plus-y-offset: calc(-36 * var(--recharge-tray-ref-px) * 2 / 59);
  background-image: url("/assets/critical/game-hud/pet-mp-plus-button-hover.png");
}

.buddy-recharge-tray__button--hp:not(:disabled):active {
  --recharge-plus-y-offset: 0px;
  background-image: url("/assets/critical/game-hud/pet-hp-plus-button-pressed.png");
}

.buddy-recharge-tray__button--mp:not(:disabled):active {
  --recharge-plus-y-offset: 0px;
  background-image: url("/assets/critical/game-hud/pet-mp-plus-button-pressed.png");
}

.buddy-recharge-tray__button:disabled {
  cursor: default;
  background-image: url("/assets/critical/game-hud/pet-hp-mp-button-inactive.png");
}

.buddy-recharge-tray__button::after {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  content: "+";
  font-size: calc(22 * var(--recharge-tray-ref-px));
  line-height: 1;
  paint-order: stroke fill;
  pointer-events: none;
  transform: translate(var(--recharge-plus-x-offset, 0px), var(--recharge-plus-y-offset, 0px));
  text-shadow:
    -1px -1px 0 #6b0012,
    1px -1px 0 #6b0012,
    -1px 1px 0 #6b0012,
    1px 1px 0 #6b0012,
    0 1px 0 rgba(0, 0, 0, 0.45);
  -webkit-text-stroke: calc(1.8 * var(--recharge-tray-ref-px)) #6b0012;
}

.buddy-recharge-tray__button:disabled::after {
  text-shadow:
    -1px -1px 0 #515b84,
    1px -1px 0 #515b84,
    -1px 1px 0 #515b84,
    1px 1px 0 #515b84,
    0 1px 0 rgba(0, 0, 0, 0.35);
  -webkit-text-stroke-color: #515b84;
}

.hud .buddy-recharge-tray__button,
.hud .buddy-recharge-tray__button:not(:disabled):hover,
.hud .buddy-recharge-tray__button:not(:disabled):active {
  transform: none;
}

.buddy-recharge-tray__button-label,
.buddy-recharge-tray__value {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.buddy-recharge-tray__warning {
  position: absolute;
  left: calc(218 * var(--recharge-tray-ref-px));
  top: 0;
  width: calc(141 * var(--recharge-tray-ref-px));
  height: calc(39 * var(--recharge-tray-ref-px));
  background: transparent url("/assets/critical/game-hud/recharge-warning-hp-frame.png") center / 100% 100% no-repeat;
}

.buddy-recharge-tray[data-warning-kind="mp"] .buddy-recharge-tray__warning {
  background-image: url("/assets/critical/game-hud/recharge-warning-mp-frame.png");
}

.buddy-recharge-tray__panel::after {
  position: absolute;
  left: calc(4 * var(--recharge-tray-ref-px));
  top: calc(145 * var(--recharge-tray-ref-px));
  z-index: 0;
  width: calc(352 * var(--recharge-tray-ref-px));
  height: calc(75 * var(--recharge-tray-ref-px));
  background: transparent url("/assets/critical/game-hud/recharge-tray-roster-panel.png") center / 100% 100% no-repeat;
  content: "";
  pointer-events: none;
}

.buddy-recharge-tray.is-roster-only .buddy-recharge-tray__panel::after {
  display: none;
}

.buddy-recharge-tray__roster {
  position: absolute;
  left: calc(61 * var(--recharge-tray-ref-px));
  top: calc(160 * var(--recharge-tray-ref-px));
  z-index: 2;
  display: flex;
  gap: calc(13 * var(--recharge-tray-ref-px));
}

.buddy-recharge-tray.is-roster-only .buddy-recharge-tray__roster {
  left: calc(61 * var(--recharge-tray-ref-px));
  top: calc(19 * var(--recharge-tray-ref-px));
}

.buddy-recharge-tray__roster-buddy {
  position: relative;
  width: calc(45 * var(--recharge-tray-ref-px));
  height: calc(45 * var(--recharge-tray-ref-px));
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: calc(1.5 * var(--recharge-tray-ref-px));
  border: 0;
  border-radius: 999px;
  background: transparent url("/assets/critical/game-hud/recharge-buddy-portrait-frame.png") center / 100% 100% no-repeat;
  cursor: pointer;
  pointer-events: auto;
}

.buddy-recharge-tray__roster-buddy[data-selected="true"] {
  background-image: url("/assets/critical/game-hud/recharge-buddy-selected-frame.png");
}

.buddy-recharge-tray__roster-buddy--placeholder {
  background-image: url("/assets/critical/game-hud/recharge-buddy-placeholder-frame.png");
  cursor: default;
  pointer-events: none;
}

.buddy-recharge-tray__roster-buddy img {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  object-fit: contain;
}

.buddy-recharge-tray__warning-icon {
  position: absolute;
  left: calc(18 * var(--recharge-tray-ref-px));
  top: calc(10 * var(--recharge-tray-ref-px));
  width: calc(17.66 * var(--recharge-tray-ref-px));
  height: calc(19 * var(--recharge-tray-ref-px));
  background: transparent url("/assets/critical/game-hud/recharge-warning-icon.png") center / 100% 100% no-repeat;
  opacity: 0.9;
}

.buddy-recharge-tray__status {
  position: absolute;
  left: calc(43 * var(--recharge-tray-ref-px));
  top: calc(10 * var(--recharge-tray-ref-px));
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(80 * var(--recharge-tray-ref-px));
  height: calc(19 * var(--recharge-tray-ref-px));
  overflow: hidden;
  font-size: calc(11 * var(--recharge-tray-ref-px));
  line-height: 1;
  opacity: 0.95;
  text-align: center;
  text-transform: uppercase;
}

.buddy-recharge-tray__status span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.buddy-recharge-tray__rail {
  --rail-arrow-offset-x: calc(1px * var(--recharge-tray-scale));
  position: absolute;
  left: var(--recharge-tray-rail-x);
  top: calc(52.916 * var(--recharge-tray-ref-px));
  display: none;
  width: calc(24.756 * var(--recharge-tray-ref-px));
  height: calc(84.169 * var(--recharge-tray-ref-px));
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  pointer-events: auto;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.buddy-recharge-tray__rail-arrow {
  position: absolute;
  left: calc(50% + var(--rail-arrow-offset-x, 0px));
  top: calc(11.17 * var(--recharge-tray-ref-px));
  display: block;
  width: calc(11.978 * var(--recharge-tray-ref-px));
  height: calc(11.17 * var(--recharge-tray-ref-px));
  background: transparent url("/assets/critical/game-hud/progress-polygon-icon.png") center / 100% 100% no-repeat;
  transform: translateX(-50%);
  transition: transform 160ms ease;
}

.buddy-recharge-tray.is-collapsed .buddy-recharge-tray__rail-arrow {
  transform: translateX(-50%) scaleX(-1);
}

.buddy-recharge-tray__rail-label {
  position: absolute;
  left: 50%;
  top: calc(25.34 * var(--recharge-tray-ref-px));
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(24.756 * var(--recharge-tray-ref-px));
  height: calc(47.659 * var(--recharge-tray-ref-px));
  color: #ffffff;
  font-size: calc(10 * var(--recharge-tray-ref-px));
  line-height: 1;
  opacity: 1;
  transform: translateX(-50%);
  writing-mode: vertical-rl;
}

.hud .buddy-recharge-tray__rail,
.hud .buddy-recharge-tray__rail:not(:disabled):hover,
.hud .buddy-recharge-tray__rail:not(:disabled):active {
  transform: none;
}

.buddy-recharge-tray .buddy-recharge-tray__rail,
.buddy-recharge-tray .buddy-recharge-tray__button {
  pointer-events: none;
}

body.is-overlay-ui-hidden .stat-panel {
  transform: translate(var(--stat-panel-slide-x), 8px) scale(0.985);
}

body.is-overlay-ui-hidden .buddy-recharge-tray {
  transform: translate(var(--recharge-tray-slide-x), 8px) scale(0.985);
}

body.is-tutorial-framed-popup-hud-hidden .stat-panel {
  transform: translate(var(--stat-panel-slide-x), 8px) scale(0.985);
}

body.is-tutorial-framed-popup-hud-hidden .buddy-recharge-tray {
  transform: translate(var(--recharge-tray-slide-x), 8px) scale(0.985);
}

.mini-map-wrap {
  --mini-map-ref-px: var(--world-hud-panel-ref-px, var(--hud-ref-px));
  --mini-map-details-w: calc(317 * var(--mini-map-ref-px));
  --mini-map-details-h: calc(355 * var(--mini-map-ref-px));
  right: calc(100% - var(--world-viewport-x) - var(--world-viewport-w) + calc(12 * var(--mini-map-ref-px)));
  top: calc(var(--world-viewport-y) + calc(10 * var(--mini-map-ref-px)));
  display: block;
  width: var(--mini-map-details-w);
  height: var(--mini-map-details-h);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  overflow: visible;
  transition: opacity 160ms ease, transform 160ms ease, visibility 0s;
  cursor: zoom-in;
  pointer-events: auto;
  touch-action: manipulation;
}

.mini-map-wrap:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.86);
  outline-offset: 2px;
}

.mini-map-wrap[aria-expanded="true"]:focus-visible {
  outline: none;
}

.dev-mod-panel {
  --dev-mod-ref-px: var(--world-hud-panel-ref-px, var(--hud-ref-px));
  position: absolute;
  z-index: var(--z-hud-raised);
  top: calc(var(--world-viewport-y) + calc(382 * var(--dev-mod-ref-px)));
  right: calc(100% - var(--world-viewport-x) - var(--world-viewport-w) + calc(14 * var(--dev-mod-ref-px)));
  width: calc(252 * var(--dev-mod-ref-px));
  padding: calc(10 * var(--dev-mod-ref-px));
  border: 1px solid rgba(112, 242, 255, 0.45);
  border-radius: 8px;
  background: rgba(8, 18, 28, 0.88);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35), inset 0 0 18px rgba(80, 221, 255, 0.12);
  color: #e8fbff;
  font-family: "Rajdhani", "Arial Narrow", Arial, sans-serif;
  pointer-events: auto;
  transition: opacity 160ms ease, transform 160ms ease, visibility 0s;
}

.dev-mod-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #8eefff;
  font-size: 14px;
  line-height: 1;
  text-transform: uppercase;
}

.dev-mod-panel__row {
  display: grid;
  grid-template-columns: 18px minmax(52px, 1fr) 56px 30px;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  font-size: 15px;
  line-height: 1;
}

.dev-mod-panel__checkbox {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #6fefff;
}

.dev-mod-panel__label {
  min-width: 0;
  overflow: hidden;
  color: #ffffff;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dev-mod-panel__value {
  width: 56px;
  min-width: 0;
  padding: 4px 5px;
  border: 1px solid rgba(142, 239, 255, 0.55);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.32);
  color: #ffffff;
  font: inherit;
  line-height: 1.1;
}

.dev-mod-panel__readout {
  color: #c8f8ff;
  font-weight: 700;
  text-align: right;
}

.dev-mod-panel__section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(112, 242, 255, 0.28);
}

.dev-mod-panel__section-title {
  display: block;
  margin-bottom: 6px;
  color: #8eefff;
  font-size: 13px;
  line-height: 1;
  text-transform: uppercase;
}

.dev-mod-panel__row--teleport {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px;
}

.dev-mod-panel__field {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.dev-mod-panel__field-label {
  color: #ffffff;
  font-weight: 700;
}

.dev-mod-panel__field .dev-mod-panel__value {
  width: 100%;
}

.dev-mod-panel__button {
  padding: 5px 6px;
  border: 1px solid rgba(142, 239, 255, 0.55);
  border-radius: 6px;
  background: rgba(80, 221, 255, 0.16);
  color: #e8fbff;
  font: inherit;
  font-weight: 700;
  line-height: 1.1;
  text-transform: uppercase;
  cursor: pointer;
}

.dev-mod-panel__button:hover {
  background: rgba(80, 221, 255, 0.3);
}

.dev-mod-panel__button:active {
  transform: translateY(1px);
}

.mini-map-zoom {
  position: fixed;
  z-index: calc(var(--z-hud) - 1);
  display: block;
  --mini-map-zoom-from-x: 0px;
  --mini-map-zoom-from-y: 0px;
  --mini-map-zoom-from-scale: 0.25;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  opacity: 0;
  transform: translate(var(--mini-map-zoom-from-x), var(--mini-map-zoom-from-y)) scale(var(--mini-map-zoom-from-scale));
  transform-origin: top left;
  transition:
    opacity 160ms ease,
    transform 220ms cubic-bezier(0.2, 0.82, 0.2, 1);
  will-change: opacity, transform;
  pointer-events: auto;
  touch-action: none;
}

.mini-map-zoom[data-state="open"] {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}

.mini-map-zoom[data-state="closing"] {
  pointer-events: none;
}

.mini-map-zoom[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .mini-map-zoom {
    transition: opacity 1ms linear;
    transform: translate(0, 0) scale(1);
  }
}

.action-strip {
  --hud-ref-px: var(--world-hud-prompt-ref-px, var(--hud-prompt-ref-px));
  --action-strip-w: calc(554 * var(--hud-ref-px));
  --action-strip-h: calc(183 * var(--hud-ref-px));
  --action-strip-half-w: calc(277 * var(--hud-ref-px));
  --action-strip-bottom: calc(-44.7035 * var(--hud-ref-px));
  --action-strip-safe-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--world-visual-bottom-inset, 0px));
  --action-strip-slide-out-ratio: 16.393443%;
  --action-strip-active-y: 0px;
  --action-strip-hidden-y: min(0.4166667vw, 0.7407407vh);
  --action-strip-scale: 1;
  --action-strip-hidden-scale: 0.98;
  --action-strip-overlay-scale: 0.985;
  --action-strip-enter-duration: 260ms;
  --action-strip-exit-duration: 200ms;
  --action-strip-enter-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --action-strip-exit-ease: cubic-bezier(0.4, 0, 1, 1);
  --action-content-gap: calc(13 * var(--hud-ref-px));
  --action-copy-w: calc(200 * var(--hud-ref-px));
  --action-panel-frame: url("/assets/critical/game-hud/prompt-section-frame.png");
  --action-strip-left: calc(var(--world-viewport-x) + var(--world-viewport-w) / 2);
  left: var(--action-strip-left);
  bottom: calc(100% - var(--world-viewport-y) - var(--world-viewport-h) + var(--action-strip-bottom) + var(--action-strip-safe-bottom));
  display: block;
  width: min(var(--action-strip-w), max(1px, calc(var(--world-viewport-w) - 16px)));
  height: var(--action-strip-h);
  max-width: none;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent var(--action-panel-frame) center / contain no-repeat;
  box-shadow: none;
  backdrop-filter: none;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, var(--action-strip-hidden-y)) scale(var(--action-strip-hidden-scale));
  transition:
    opacity var(--action-strip-exit-duration) ease-in,
    transform var(--action-strip-exit-duration) var(--action-strip-exit-ease),
    visibility 0s var(--action-strip-exit-duration);
  overflow: visible;
  visibility: hidden;
}

.action-strip[data-layout="compact"] {
  --action-copy-w: calc(220 * var(--hud-ref-px));
}

.action-strip.is-message-only {
  --action-copy-w: calc(235 * var(--hud-ref-px));
}

.action-strip.is-active {
  transform: translate(-50%, var(--action-strip-active-y)) scale(var(--action-strip-scale));
  opacity: 1;
  transition:
    opacity var(--action-strip-enter-duration) ease-out,
    transform var(--action-strip-enter-duration) var(--action-strip-enter-ease),
    visibility 0s;
  visibility: visible;
}

body.is-mobile-landscape-action-prompt .action-strip {
  --action-strip-bottom: calc(-1 * var(--action-strip-safe-bottom, 0px));
  --action-strip-active-y: var(--action-strip-slide-out-ratio);
}

.action-strip__content {
  position: absolute;
  left: 0;
  top: calc(51 * var(--hud-ref-px));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--action-content-gap);
  width: 100%;
  height: calc(64 * var(--hud-ref-px));
  min-width: 0;
  pointer-events: none;
}

.action-strip__portrait {
  position: relative;
  flex: 0 0 calc(63 * var(--hud-ref-px));
  display: block;
  width: calc(63 * var(--hud-ref-px));
  height: calc(63 * var(--hud-ref-px));
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  overflow: visible;
}

.action-strip__portrait[hidden] {
  display: none;
}

.action-strip__portrait::before,
.action-strip__portrait::after,
.action-strip__portrait-fallback {
  position: absolute;
  border-radius: 999px;
  content: "";
}

.action-strip__portrait::before {
  inset: 5.5%;
  z-index: 2;
  background-color: #07152a;
  background-image: var(--action-portrait-image, none);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 0;
}

.action-strip.has-action-portrait .action-strip__portrait::before {
  opacity: 1;
}

.action-strip__portrait::after {
  inset: 0;
  z-index: 1;
  background: transparent url("/assets/critical/game-hud/hud-avatar-frame.png") center / contain no-repeat;
  pointer-events: none;
}

.action-strip__portrait-fallback {
  inset: 5.5%;
  z-index: 2;
  display: grid;
  place-items: center;
  color: #ffffff;
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.24), transparent 36%),
    linear-gradient(180deg, #253d79 0%, #121835 100%);
  font-family: "Lilita One", Rajdhani, Inter, system-ui, sans-serif;
  font-size: min(1.0416667vw, 1.8518519vh);
  font-weight: 400;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(5, 4, 18, 0.82);
  text-transform: uppercase;
}

.action-strip.has-action-portrait .action-strip__portrait-fallback {
  display: none;
}

.action-strip__copy {
  display: flex;
  flex: 0 1 var(--action-copy-w);
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: calc(3 * var(--hud-ref-px));
  width: var(--action-copy-w);
  height: calc(58 * var(--hud-ref-px));
  min-width: 0;
  pointer-events: none;
}

.action-strip__level {
  position: relative;
  flex: 0 0 calc(38 * var(--hud-ref-px));
  align-self: flex-start;
  display: grid;
  place-items: center;
  width: calc(38 * var(--hud-ref-px));
  height: calc(21 * var(--hud-ref-px));
  top: calc(2.5 * var(--hud-ref-px));
  color: #ffffff;
  font-family: "Lilita One", Rajdhani, Inter, system-ui, sans-serif;
  font-size: calc(11 * var(--hud-ref-px));
  font-weight: 400;
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px 0 #050312;
  background: transparent url("/assets/critical/game-hud/interact-level-tag-frame.png") center / contain no-repeat;
}

.action-strip__level[hidden] {
  display: none;
}

.action-strip__title,
.action-strip__subtitle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: normal;
}

.action-strip__title {
  height: calc(28 * var(--hud-ref-px));
  color: #ffffff;
  font-family: "Lilita One", Rajdhani, Inter, system-ui, sans-serif;
  font-size: var(--action-title-font-size, calc(22 * var(--hud-ref-px)));
  font-weight: 400;
  line-height: 1;
  text-shadow:
    0 2px 0 #080513,
    0 0 6px rgba(0, 0, 0, 0.75);
  text-transform: uppercase;
}

.action-strip.has-dynamic-title-fit .action-strip__title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-strip__subtitle {
  height: calc(22 * var(--hud-ref-px));
  color: rgba(255, 255, 255, 0.94);
  font-family: "Inter", system-ui, sans-serif;
  font-size: calc(12 * var(--hud-ref-px));
  font-weight: 500;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8);
}

/* Label-only prompts pass no subtitle; collapse the row so the title does not
   sit above an empty band. */
.action-strip__subtitle:empty {
  height: 0;
}

.action-strip button {
  position: relative;
  flex: 0 0 calc(128 * var(--hud-ref-px));
  display: block;
  width: calc(128 * var(--hud-ref-px));
  height: calc(64 * var(--hud-ref-px));
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #ffffff;
  background: transparent;
  box-shadow: none;
  font-family: "Lilita One", Rajdhani, Inter, system-ui, sans-serif;
  font-size: calc(18 * var(--hud-ref-px));
  font-weight: 400;
  line-height: 1;
  text-align: center;
  text-shadow: 0 2px 0 #3a0711;
  text-transform: uppercase;
  pointer-events: auto;
  overflow: visible;
}

.action-strip button:not(:disabled):hover,
.action-strip button:not(:disabled):active {
  transform: none;
}

.action-strip.is-message-only button {
  display: none;
}

.action-strip__button-icon {
  position: absolute;
  top: 50%;
  right: calc(18 * var(--hud-ref-px));
  z-index: 1;
  display: block;
  width: calc(28 * var(--hud-ref-px));
  height: calc(28 * var(--hud-ref-px));
  transform: translateY(-50%);
  background-image: url("/assets/critical/icons/sword.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.action-strip__button-icon[hidden] {
  display: none;
}

.action-strip[data-button-icon="heal"] .action-strip__button-icon {
  display: block;
  width: calc(34 * var(--hud-ref-px));
  height: calc(34 * var(--hud-ref-px));
  background-image: url("/assets/critical/game-hud/icons/heal.png");
}

.action-strip[data-button-icon="chest"] .action-strip__button-icon {
  display: block;
  width: calc(34 * var(--hud-ref-px));
  height: calc(34 * var(--hud-ref-px));
  background-image: url("/assets/critical/game-hud/icons/treasure-closed.png");
}

.action-strip button:disabled {
  color: rgba(255, 255, 255, 0.68);
  background: transparent;
  box-shadow: none;
  cursor: default;
}

#actionButtonText {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  padding: 0 calc(34 * var(--hud-ref-px)) 0 calc(12 * var(--hud-ref-px));
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-strip[data-button-icon="none"] #actionButtonText {
  padding: 0 calc(12 * var(--hud-ref-px));
}

.profile-summary__name,
.profile-summary__tag,
.profile-summary__tag span,
.stat-panel__label span,
.stat-panel__label strong,
.stat-panel__side-label,
.buddy-recharge-tray__name,
.buddy-recharge-tray__status,
.buddy-recharge-tray__status span,
.buddy-recharge-tray__rail-label,
.buddy-recharge-tray__rail-label span,
.buddy-recharge-tray__value,
.buddy-recharge-tray__button-label,
.action-strip__portrait-fallback,
.action-strip__level,
.action-strip__title,
.action-strip__subtitle,
.action-strip button,
#actionButtonText {
  font-family: var(--font-display), Rajdhani, Inter, system-ui, sans-serif;
  paint-order: stroke fill;
  text-shadow:
    -1px -1px 0 #000000,
    1px -1px 0 #000000,
    -1px 1px 0 #000000,
    1px 1px 0 #000000,
    0 2px 0 #000000;
  -webkit-text-stroke: var(--hud-text-stroke-width, 5px) #000000;
}

.profile-summary__name,
.stat-panel__label span,
.stat-panel__label strong,
.buddy-recharge-tray__name,
.buddy-recharge-tray__value,
.action-strip__portrait-fallback,
.action-strip__title,
.action-strip button,
#actionButtonText {
  --hud-text-stroke-width: 5px;
}

.profile-summary__tag,
.profile-summary__tag span {
  --hud-text-stroke-width: calc(2.4 * var(--hud-ref-px));
}

.buddy-recharge-tray__status,
.buddy-recharge-tray__status span,
.buddy-recharge-tray__button-label,
.action-strip__subtitle,
.action-strip__level {
  --hud-text-stroke-width: 2.5px;
}

.stat-panel__label span,
.buddy-recharge-tray__status,
.buddy-recharge-tray__status span,
.action-strip__subtitle {
  font-family: "Inter", system-ui, sans-serif;
  font-weight: 500;
}

.stat-panel__label span {
  --hud-text-stroke-width: 2.5px;
}

.stat-panel__side-label,
.stat-panel__side-label span,
.buddy-recharge-tray__rail-label,
.buddy-recharge-tray__rail-label span {
  --hud-text-stroke-width: 4px;
}

.buddy-book-button {
  right: 14px;
  bottom: 18px;
  z-index: var(--z-hud-raised);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 108px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.buddy-book-button {
  width: 96px;
  height: 96px;
}

.buddy-book-button[hidden] {
  display: none;
}

.buddy-book-button__icon {
  position: relative;
  width: 78px;
  height: 78px;
  border: 2px solid rgba(217, 251, 255, 0.72);
  border-radius: 50%;
  background:
    radial-gradient(circle at 37% 38%, #edf4ee 0 7px, transparent 8px),
    radial-gradient(circle at 61% 39%, #071014 0 5px, transparent 6px),
    linear-gradient(145deg, #7ee0b8, #4f826a 68%);
  box-shadow:
    inset -10px -10px 0 rgba(7, 16, 20, 0.18),
    0 9px 14px rgba(0, 0, 0, 0.36);
  flex: 0 0 auto;
}

.buddy-book-button__icon::after {
  position: absolute;
  top: -9px;
  left: 18px;
  width: 38px;
  height: 25px;
  border-radius: 50% 50% 38% 38%;
  background: linear-gradient(145deg, #d7f2a4, #6fb870);
  content: "";
  transform: rotate(-12deg);
}

.buddy-book-button:focus-visible {
  outline: 2px solid rgba(126, 224, 184, 0.78);
  outline-offset: -8px;
}

.buddy-book-button span:not(.buddy-book-button__icon),
.buddy-book-button strong {
  display: none;
}

.buddy-book-panel {
  right: calc(100% - var(--world-viewport-x) - var(--world-viewport-w) + 14px);
  bottom: calc(100% - var(--world-viewport-y) - var(--world-viewport-h) + 78px);
  z-index: var(--z-hud-panel);
  display: none;
  width: min(386px, calc(var(--world-viewport-w) - 28px));
  max-height: min(620px, calc(var(--world-viewport-h) - 116px));
  overflow: hidden;
  border-radius: 8px;
  background: rgba(10, 16, 20, 0.94);
}

.buddy-book-panel.is-open {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.buddy-book-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.buddy-book-header span,
.buddy-book-summary span,
.buddy-entry__meta {
  color: var(--muted);
}

.buddy-book-header span {
  display: block;
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.buddy-book-header h2 {
  margin: 2px 0 0;
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: 0;
}

.buddy-book-header button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 24px;
  line-height: 1;
}

.buddy-book-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.buddy-book-summary strong {
  font-size: 15px;
}

.buddy-book-summary span {
  font-size: 12px;
}

.buddy-book-list {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 14px 14px;
  scrollbar-color: rgba(126, 224, 184, 0.55) rgba(255, 255, 255, 0.08);
  scrollbar-width: thin;
}

.buddy-book-list:focus {
  outline: 1px solid rgba(126, 224, 184, 0.42);
  outline-offset: -2px;
}

.buddy-entry {
  display: grid;
  gap: 8px;
  min-height: 126px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.buddy-entry {
  min-height: 150px;
}

.buddy-entry__top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.buddy-entry__name {
  min-width: 0;
}

.buddy-entry__name strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.15;
}

.buddy-entry__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  margin-top: 5px;
  font-size: 11px;
  text-transform: uppercase;
}

.buddy-entry__resources {
  display: grid;
  gap: 8px;
}

.buddy-entry__resource {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.buddy-entry__resource span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.buddy-entry__resource div {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.buddy-entry__resource i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7ee0b8, #c6fbff);
}

.buddy-entry__resource button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(233, 179, 95, 0.65);
  border-radius: 7px;
  background: rgba(233, 179, 95, 0.18);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.buddy-entry__resource button:disabled {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  cursor: default;
}

.touch-pad {
  position: absolute;
  right: 14px;
  bottom: 88px;
  z-index: var(--z-hud-raised);
  display: none;
  grid-template-columns: 46px 46px 46px 46px;
  grid-template-rows: 46px 46px;
  gap: 8px;
}

.touch-pad button {
  color: #dce8e2;
  background: var(--panel-strong);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.26);
  user-select: none;
  touch-action: none;
}

.touch-pad button[data-touch="up"] {
  grid-column: 2;
}

.touch-pad button[data-touch="left"] {
  grid-column: 1;
  grid-row: 2;
}

.touch-pad button[data-touch="down"] {
  grid-column: 2;
  grid-row: 2;
}

.touch-pad button[data-touch="right"] {
  grid-column: 3;
  grid-row: 2;
}

.touch-pad button[data-touch="action"] {
  grid-column: 4;
  grid-row: 2;
  color: #071014;
  background: var(--accent-2);
}

.auth-loading,
.auth-backdrop {
  position: fixed;
  top: var(--world-viewport-y);
  right: auto;
  bottom: auto;
  left: var(--world-viewport-x);
  z-index: var(--z-auth);
  display: grid;
  place-items: center;
  width: var(--world-viewport-w);
  height: var(--world-viewport-h);
  background: rgba(3, 9, 16, 0.78);
  backdrop-filter: blur(10px);
}

.auth-loading[hidden],
.auth-backdrop[hidden] {
  display: none;
}

.auth-loading {
  gap: 12px;
  color: #dce8e2;
  font-family: var(--font-label);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-page {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  overflow-y: auto;
  background: #141e52;
}

.login-page::before,
.login-page::after {
  position: fixed;
  inset: 0;
  content: "";
  pointer-events: none;
}

.login-page::before {
  background:
    linear-gradient(90deg, #151f56 0%, rgba(21, 31, 86, 0.98) 47%, rgba(21, 31, 86, 0.5) 66%, rgba(21, 31, 86, 0.08) 100%),
    url("/assets/critical/login/starborn-galaxy-cover.webp") right center / auto 100% no-repeat,
    #151f56;
}

.login-page::after {
  background-image:
    radial-gradient(circle at 6% 10%, rgba(0, 199, 255, 0.95) 0 4px, transparent 5px),
    radial-gradient(circle at 19% 16%, rgba(255, 255, 255, 0.6) 0 1px, transparent 2px),
    radial-gradient(circle at 38% 22%, rgba(255, 255, 255, 0.42) 0 1px, transparent 2px),
    radial-gradient(circle at 63% 8%, rgba(255, 255, 255, 0.55) 0 1px, transparent 2px),
    radial-gradient(circle at 70% 31%, rgba(0, 199, 255, 0.55) 0 2px, transparent 3px),
    radial-gradient(circle at 28% 76%, rgba(255, 255, 255, 0.48) 0 1px, transparent 2px),
    radial-gradient(circle at 54% 84%, rgba(233, 179, 95, 0.58) 0 1px, transparent 2px);
  opacity: 0.86;
}

.login-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  gap: 58px;
  align-items: center;
  width: min(1220px, 100%);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: 54px;
}

.login-copy {
  display: grid;
  align-content: center;
  gap: 20px;
  max-width: 720px;
}

.login-overline {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  margin: 0;
  color: #00c7ff;
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.login-overline::before {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #00c7ff;
  box-shadow: 0 0 18px rgba(0, 199, 255, 0.82);
  content: "";
  flex: 0 0 auto;
}

.login-title {
  margin: 0;
  color: #fff;
  font-family: var(--font-heading);
  font-size: 126px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 0.82;
  text-wrap: balance;
}

.login-title span {
  color: #00c7ff;
  text-shadow: 0 0 20px rgba(0, 199, 255, 0.74);
}

.login-lede {
  max-width: 700px;
  margin: 0;
  color: rgba(255, 255, 255, 0.95);
  font-family: var(--font-copy);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.36;
}

.login-lede em {
  color: #00c7ff;
  font-family: var(--font-copy);
  font-size: 1em;
  font-style: italic;
}

.login-tagline {
  margin: 42px 0 0;
  color: rgba(255, 255, 255, 0.9);
  font-family: var(--font-copy);
  font-size: 18px;
  font-style: italic;
  line-height: 1.3;
}

.login-panel {
  position: relative;
  z-index: 2;
  grid-column: 2;
  justify-self: end;
  display: grid;
  gap: 16px;
  width: min(430px, 100%);
  padding: 24px;
  border: 1px solid rgba(0, 199, 255, 0.36);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 34%),
    rgba(10, 16, 38, 0.78);
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 36px rgba(0, 199, 255, 0.12);
  backdrop-filter: blur(16px);
}

.login-panel::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  border-radius: 8px 0 0 8px;
  background: linear-gradient(180deg, #00c7ff, #ff69d2, #e9b35f);
  content: "";
}

.login-panel h2 {
  margin: 0;
  color: #fff;
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.02;
}

.auth-spinner {
  width: 52px;
  height: 52px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: auth-spin 0.9s linear infinite;
}

.auth-backdrop {
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.auth-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.auth-backdrop.is-closing {
  opacity: 0;
}

.auth-dialog {
  display: grid;
  gap: 18px;
  width: min(420px, calc(var(--world-viewport-w) - 28px));
  padding: 24px;
  border: 1px solid rgba(217, 251, 255, 0.2);
  border-radius: 8px;
  background: rgba(8, 16, 23, 0.94);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.48);
  transform: translateY(10px) scale(0.98);
  transition: transform 220ms ease;
}

.auth-backdrop.is-open .auth-dialog {
  transform: translateY(0) scale(1);
}

.auth-dialog__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #00c7ff;
  font-family: var(--font-stat);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.auth-dialog h1 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-heading);
  font-size: 34px;
  line-height: 1;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form[hidden] {
  display: none;
}

.auth-login-note {
  margin: 0;
  padding: 6px;
  color: rgba(255, 255, 255, 0.76);
  font: inherit;
  font-size: 13px;
}

.auth-field {
  display: grid;
  gap: 7px;
}

.auth-field[hidden] {
  display: none;
}

.auth-school-closed {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.auth-school-closed[hidden] {
  display: none;
}

.auth-school-closed p {
  margin: 0;
  overflow-wrap: anywhere;
}

.auth-school-closed .auth-school-change {
  margin-left: 0;
  justify-self: start;
  min-height: 44px;
}

.auth-school-change {
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.76);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

.auth-field p {
  margin: 0;
  color: #fff;
}

.auth-field span {
  color: rgba(255, 255, 255, 0.76);
  font-family: var(--font-stat);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.auth-field input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  outline: none;
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.auth-password-control {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-password-control input {
  padding-right: 48px;
}

.auth-password-toggle {
  position: absolute;
  right: 6px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}

.auth-password-toggle:hover,
.auth-password-toggle:focus-visible {
  border-color: rgba(0, 199, 255, 0.45);
  background: rgba(0, 199, 255, 0.11);
  color: var(--ink);
}

.auth-password-toggle__icon {
  position: relative;
  width: 21px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 999px / 680px;
}

.auth-password-toggle__icon::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
  transform: translate(-50%, -50%);
}

.auth-password-toggle__icon::after {
  position: absolute;
  top: 50%;
  left: -4px;
  display: none;
  width: 28px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
  transform: rotate(-38deg);
}

.auth-password-toggle.is-visible .auth-password-toggle__icon::after {
  display: block;
}

.auth-field input:focus {
  border-color: rgba(0, 199, 255, 0.78);
  box-shadow:
    0 0 0 3px rgba(0, 199, 255, 0.13),
    0 0 20px rgba(0, 199, 255, 0.08);
}

.auth-field input[aria-invalid="true"] {
  border-color: rgba(240, 124, 99, 0.9);
}

.auth-field small {
  min-height: 15px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.25;
  white-space: pre-line;
}

.auth-field small.auth-hint {
  color: rgba(255, 255, 255, 0.6);
}

.auth-field small.auth-hint.is-confirmed {
  color: #7ddf9a;
}

/* Grade select — styled to match auth-field inputs */
.auth-field select {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  outline: none;
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  font-family: var(--font-copy);
  font-size: 14px;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239faea7' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.auth-field select option {
  background: #0a1018;
  color: #fff;
}

.auth-field select:focus {
  border-color: rgba(0, 199, 255, 0.78);
  box-shadow:
    0 0 0 3px rgba(0, 199, 255, 0.13),
    0 0 20px rgba(0, 199, 255, 0.08);
}

/* Grade field inside signup confirm: no bottom margin gap */
.signup-confirm__grade-field {
  margin-bottom: 0;
}


.auth-submit {
  position: relative;
  min-height: 48px;
  margin-top: 2px;
  border: 1px solid rgba(0, 199, 255, 0.92);
  border-radius: 7px;
  background: linear-gradient(135deg, #00c7ff, #54b9ea 48%, #e9b35f 155%);
  color: #071014;
  font-family: var(--font-stat);
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 14px 30px rgba(0, 199, 255, 0.18);
}

.auth-submit.is-loading,
.signup-confirm__primary.is-loading {
  color: rgba(7, 16, 20, 0.58);
}

.signup-confirm__primary.is-loading {
  padding-right: 42px;
  text-align: left;
}

.auth-submit.is-loading::after,
.signup-confirm__primary.is-loading::after {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(7, 16, 20, 0.28);
  border-top-color: #071014;
  border-radius: 50%;
  content: "";
  transform: translateY(-50%);
  animation: auth-button-spin 0.8s linear infinite;
}

.auth-submit:disabled,
.auth-toggle:disabled,
.signup-confirm__primary:disabled,
.signup-confirm__secondary:disabled {
  opacity: 0.6;
  cursor: default;
}

.auth-toggle {
  min-height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-family: var(--font-label);
  font-size: 14px;
  font-weight: 800;
  text-align: left;
}

.toast-stack {
  position: fixed;
  left: calc(var(--world-viewport-x) + var(--world-viewport-w) / 2);
  bottom: calc(100vh - var(--world-viewport-y) - var(--world-viewport-h) + 18px);
  z-index: var(--z-toast);
  display: grid;
  gap: 8px;
  width: min(420px, calc(var(--world-viewport-w) - 28px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: rgba(7, 16, 26, 0.95);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
}

.toast--success {
  border-left-color: var(--accent);
}

.toast--error {
  border-left-color: var(--danger);
}

.toast--warning {
  border-left-color: var(--accent-2);
}

.toast--info {
  border-left-color: #83b7e8;
}

.signup-confirm {
  position: fixed;
  top: var(--world-viewport-y);
  right: auto;
  bottom: auto;
  left: var(--world-viewport-x);
  z-index: var(--z-auth);
  display: grid;
  place-items: center;
  width: var(--world-viewport-w);
  height: var(--world-viewport-h);
  min-height: var(--world-viewport-h);
  padding: 24px;
  overflow-y: auto;
  background: rgba(3, 9, 16, 0.74);
  backdrop-filter: blur(10px);
}

.signup-confirm[hidden] {
  display: none;
}

.signup-confirm__panel {
  display: grid;
  gap: 16px;
  width: min(430px, 100%);
  max-width: calc(var(--world-viewport-w) - 32px);
  padding: 24px;
  border: 1px solid rgba(0, 199, 255, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 38%),
    rgba(10, 16, 38, 0.97);
  box-shadow:
    0 26px 76px rgba(0, 0, 0, 0.48),
    0 0 32px rgba(0, 199, 255, 0.1);
}

.signup-confirm__panel h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.04;
  text-wrap: balance;
}

.signup-confirm__panel p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.signup-confirm__panel strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.signup-confirm__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 4px;
}

.signup-confirm__primary,
.signup-confirm__secondary {
  flex: 0 1 auto;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 7px;
  font-family: var(--font-stat);
  font-weight: 800;
  white-space: nowrap;
}

.signup-confirm__primary {
  position: relative;
  min-width: 160px;
  border: 1px solid rgba(0, 199, 255, 0.92);
  background: linear-gradient(135deg, #00c7ff, #54b9ea 48%, #e9b35f 155%);
  color: #071014;
}

.signup-confirm__secondary {
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
}

@keyframes auth-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes auth-button-spin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

@media (max-width: 1100px) {
  .login-page::before {
    background:
      linear-gradient(90deg, #151f56 0%, rgba(21, 31, 86, 0.97) 54%, rgba(21, 31, 86, 0.5) 78%, rgba(21, 31, 86, 0.08) 100%),
      url("/assets/critical/login/starborn-galaxy-cover.webp") right center / auto 100% no-repeat,
      #151f56;
  }

  .login-shell {
    grid-template-columns: minmax(0, 1fr) minmax(310px, 390px);
    gap: 34px;
    padding: 36px;
  }

  .login-title {
    font-size: 96px;
  }

  .login-lede {
    font-size: 23px;
  }

  .login-tagline {
    margin-top: 24px;
    font-size: 17px;
  }
}

@media (max-width: 820px) {
  :root {
    --hud-edge-inset: 8px;
  }

  .login-page::before {
    background:
      linear-gradient(180deg, rgba(21, 31, 86, 0.58) 0%, #151f56 39%, #111946 100%),
      url("/assets/critical/login/starborn-galaxy-cover.webp") center top / cover no-repeat,
      #151f56;
  }

  .login-shell {
    grid-template-columns: 1fr;
    align-content: center;
    align-content: safe center;
    justify-items: center;
    gap: 24px;
    width: min(680px, 100%);
    min-height: 100vh;
    min-height: 100svh;
    padding: 44px 28px 34px;
  }

  .login-copy {
    gap: 14px;
    max-width: 620px;
    text-align: center;
    justify-items: center;
  }

  .login-title {
    font-size: 82px;
    line-height: 0.88;
  }

  .login-lede {
    font-size: 21px;
    line-height: 1.35;
  }

  .login-tagline {
    margin-top: 10px;
    font-size: 16px;
  }

  .login-panel {
    grid-column: 1;
    justify-self: center;
    width: min(430px, 100%);
  }

  .hud-top {
    min-height: 0;
  }

  .mvp-hud {
    top: calc(var(--world-viewport-y) + calc(12 * var(--hud-ref-px)));
  }

  .hud-canvas-control--cards,
  .hud-canvas-control--buddies {
    --hud-trigger-mobile-landscape-offset-y: -12px;
  }

  .stat-panel {
    top: calc(var(--hud-edge-inset) + min(7.8010693vw, 13.8685676vh) + 12px);
    bottom: auto;
    z-index: var(--z-hud-raised);
    display: block;
    width: calc(var(--stat-panel-frame-w) * var(--stat-panel-scale));
    height: calc(var(--stat-panel-frame-h) * var(--stat-panel-scale));
  }

  .buddy-recharge-tray {
    --recharge-tray-left: calc(-6 * var(--recharge-tray-ref-px));
    --recharge-tray-bottom: 8px;
  }

  .stat-panel-menu {
    width: var(--stat-panel-frame-w);
    height: var(--stat-panel-frame-h);
    background: transparent url("/assets/critical/game-hud/recharge-tray-frame.png") center / 100% 100% no-repeat;
    transform: scale(var(--stat-panel-scale));
    transform-origin: top left;
  }

  .mini-map-wrap {
    display: block;
  }

  .dev-mod-panel {
    top: calc(var(--world-viewport-y) + calc(10 * var(--dev-mod-ref-px)));
    right: calc(100% - var(--world-viewport-x) - var(--world-viewport-w) + calc(336 * var(--dev-mod-ref-px)));
  }

  .touch-pad {
    display: none;
  }

  .buddy-book-button {
    bottom: 196px;
  }

  .buddy-book-panel {
    right: calc(100% - var(--world-viewport-x) - var(--world-viewport-w) + 14px);
    bottom: calc(100% - var(--world-viewport-y) - var(--world-viewport-h) + 14px);
    max-height: calc(var(--world-viewport-h) - 28px);
  }

}

@media (max-width: 780px) and (max-height: 520px) and (orientation: landscape) {
  .action-strip {
    --action-strip-left: max(
      calc(var(--world-viewport-x) + var(--action-strip-half-w) + 8px),
      min(
        calc(var(--world-viewport-x) + 394px),
        calc(var(--world-viewport-x) + var(--world-viewport-w) - var(--action-strip-half-w) - 8px)
      )
    );
  }
}

@media (max-width: 600px) and (max-height: 520px) and (orientation: landscape) {
  .action-strip {
    --action-strip-left: max(
      calc(var(--world-viewport-x) + var(--action-strip-half-w) + 8px),
      min(
        calc(var(--world-viewport-x) + var(--world-viewport-w) - 185px),
        calc(var(--world-viewport-x) + var(--world-viewport-w) - var(--action-strip-half-w) - 8px)
      )
    );
  }
}

@media (max-width: 560px) and (orientation: portrait) {
  .hud-settings-button,
  .hud-element-info-button,
  .hud-player-search-button {
    top: calc(var(--world-viewport-y) + calc(10 * var(--settings-panel-ref-px)) + calc(325 * var(--settings-panel-ref-px)) + calc(8 * var(--settings-ref-px)));
  }

  .hud-settings-button {
    right: calc(100% - var(--world-viewport-x) - var(--world-viewport-w) + calc(12 * var(--settings-panel-ref-px)) + var(--settings-button-w) + calc(8 * var(--settings-ref-px)));
  }

  .hud-element-info-button {
    right: calc(100% - var(--world-viewport-x) - var(--world-viewport-w) + calc(12 * var(--settings-panel-ref-px)));
  }

  .hud-fullscreen-button {
    top: auto;
    right: calc(100% - var(--world-viewport-x) - var(--world-viewport-w) + var(--fullscreen-edge-margin));
    bottom: calc(100% - var(--world-viewport-y) - var(--world-viewport-h) + var(--world-visual-bottom-inset, 0px) + var(--fullscreen-edge-margin));
  }

  .hud-player-search-button {
    top: calc(var(--world-viewport-y) + calc(10 * var(--settings-panel-ref-px)) + calc(325 * var(--settings-panel-ref-px)) + var(--settings-button-h) + calc(20 * var(--settings-ref-px)));
    right: calc(100% - var(--world-viewport-x) - var(--world-viewport-w) + calc(12 * var(--settings-panel-ref-px)));
  }
}

@media (max-width: 560px) {
  .hud-top {
    min-height: 0;
  }

  .player-chip button {
    min-height: 32px;
    padding: 0 8px;
  }

  .stat-panel {
    top: calc(var(--hud-edge-inset) + min(7.8010693vw, 13.8685676vh) + 8px);
    bottom: auto;
  }

  .buddy-book-button {
    right: 8px;
    bottom: 176px;
    width: 82px;
    height: 82px;
  }

  .buddy-book-button__icon {
    width: 66px;
    height: 66px;
  }

  .buddy-book-panel {
    right: calc(100% - var(--world-viewport-x) - var(--world-viewport-w) + 8px);
    bottom: calc(100% - var(--world-viewport-y) - var(--world-viewport-h) + 8px);
    width: calc(var(--world-viewport-w) - 16px);
    max-height: calc(var(--world-viewport-h) - 16px);
  }

  .buddy-book-list {
    padding: 10px;
  }

  .buddy-entry__resource {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .buddy-entry__resource button {
    grid-column: 1 / -1;
  }

  .auth-dialog {
    padding: 20px;
  }

  .auth-dialog h1 {
    font-size: 30px;
  }

  .login-page::before {
    background:
      linear-gradient(180deg, rgba(21, 31, 86, 0.48) 0%, #151f56 34%, #111946 100%),
      url("/assets/critical/login/starborn-galaxy-cover.webp") center top / auto 54vh no-repeat,
      #151f56;
  }

  .login-shell {
    align-content: center;
    align-content: safe center;
    align-items: center;
    gap: 18px;
    padding: 20px 16px;
  }

  .login-overline {
    font-size: 13px;
  }

  .login-title {
    font-size: 60px;
    line-height: 0.9;
  }

  .login-lede {
    font-size: 17px;
    max-width: 360px;
  }

  .login-tagline {
    margin-top: 4px;
    font-size: 15px;
  }

  .login-panel {
    width: 100%;
    padding: 18px;
  }

  .login-panel h2,
  .signup-confirm__panel h2 {
    font-size: 28px;
  }

  .signup-confirm {
    padding: 18px;
  }

  .signup-confirm__panel {
    width: min(430px, 100%);
    max-width: calc(var(--world-viewport-w) - 28px);
    padding: 20px;
    text-align: center;
    justify-items: center;
  }

  .signup-confirm__actions {
    display: flex;
    justify-content: center;
    width: 100%;
  }

}

@media (max-width: 420px) {
  .login-copy {
    gap: 9px;
  }

  .login-title {
    font-size: 54px;
  }

  .login-lede {
    font-size: 15px;
    line-height: 1.28;
  }

  .login-tagline {
    display: none;
  }

  .auth-dialog__brand,
  .auth-field span {
    font-size: 11px;
  }

  .auth-submit {
    font-size: 14px;
    min-height: 46px;
  }

  .signup-confirm__actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .signup-confirm__primary,
  .signup-confirm__secondary {
    width: 100%;
    min-width: 0;
    min-height: 44px;
  }

  .auth-form {
    gap: 12px;
  }

  .auth-field {
    gap: 6px;
  }

  .auth-field input {
    min-height: 44px;
  }
}

@media (max-width: 360px) {
  .login-shell {
    gap: 14px;
    padding: 16px 12px;
  }

  .login-title {
    font-size: 48px;
  }

  .login-panel {
    padding: 16px 14px;
  }

  .signup-confirm {
    padding: 12px;
  }

  .signup-confirm__panel {
    max-width: calc(var(--world-viewport-w) - 24px);
    padding: 16px 14px;
  }

  .signup-confirm__panel h2 {
    font-size: 25px;
  }
}

@media (max-width: 420px) and (max-height: 700px) {
  .login-page::before {
    background:
      linear-gradient(180deg, rgba(21, 31, 86, 0.4) 0%, #151f56 30%, #111946 100%),
      url("/assets/critical/login/starborn-galaxy-cover.webp") center top / auto 46vh no-repeat,
      #151f56;
  }

  .login-shell {
    align-content: start;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .login-lede {
    display: none;
  }

  .login-panel {
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .signup-confirm {
    align-items: start;
    padding-top: 14px;
    padding-bottom: 14px;
  }
}

@media (min-width: 821px) and (max-height: 720px) {
  .login-shell {
    padding-top: 28px;
    padding-bottom: 28px;
  }

  .login-title {
    font-size: 94px;
  }

  .login-lede {
    font-size: 22px;
  }

  .login-tagline {
    margin-top: 16px;
  }
}



/* ─── Landscape phone: compact HUD to maximise game view ─────────────────── */
@media (max-width: 980px) and (max-height: 520px) and (orientation: landscape) {
  :root {
    --hud-edge-inset: 4px;
  }

  .hud-top {
    min-height: 0;
  }

  .mvp-hud {
    top: calc(var(--world-viewport-y) + calc(12 * var(--hud-ref-px)));
  }

  .hud-canvas-control--cards,
  .hud-canvas-control--buddies {
    --hud-trigger-mobile-landscape-offset-y: -12px;
  }

  .stat-panel {
    top: calc(var(--hud-edge-inset) + min(7.8010693vw, 13.8685676vh) + 8px);
    bottom: auto;
    z-index: var(--z-hud-raised);
    display: block;
    width: calc(var(--stat-panel-frame-w) * var(--stat-panel-scale));
    height: calc(var(--stat-panel-frame-h) * var(--stat-panel-scale));
  }

  .buddy-recharge-tray {
    --recharge-tray-left: calc(-6 * var(--recharge-tray-ref-px));
    --recharge-tray-bottom: 6px;
  }

  .action-strip {
    --action-strip-bottom: calc(-1 * var(--action-strip-safe-bottom, 0px));
    --action-strip-active-y: var(--action-strip-slide-out-ratio);
  }

  .stat-panel-menu {
    width: var(--stat-panel-frame-w);
    height: var(--stat-panel-frame-h);
    background: transparent url("/assets/critical/game-hud/recharge-tray-frame.png") center / 100% 100% no-repeat;
    transform: scale(var(--stat-panel-scale));
    transform-origin: top left;
  }

  /* Buddy-book panel fills screen in landscape */
  .buddy-book-panel {
    right: calc(100% - var(--world-viewport-x) - var(--world-viewport-w) + 4px);
    bottom: calc(100% - var(--world-viewport-y) - var(--world-viewport-h) + 4px);
    max-height: calc(var(--world-viewport-h) - 8px);
  }
}

/* ─── Very small portrait phones (≤ 390px) ───────────────────────────────── */
@media (max-width: 390px) {
  .stat-panel {
    top: calc(var(--hud-edge-inset) + min(7.8010693vw, 13.8685676vh) + 8px);
    bottom: auto;
  }

}

.starborn-confirm-popup {
  --confirm-popup-ref-px: clamp(0.72px, var(--world-hud-panel-ref-px, var(--hud-ref-px)), 1px);
  --confirm-popup-edge-gap: calc(24 * var(--confirm-popup-ref-px));
  position: fixed;
  top: calc(var(--world-viewport-y) + calc(18 * var(--confirm-popup-ref-px)));
  left: calc(var(--world-viewport-x) + var(--world-viewport-w) / 2);
  z-index: 10001;
  width: min(calc(var(--world-viewport-w) - var(--confirm-popup-edge-gap)), calc(340 * var(--confirm-popup-ref-px)));
  min-height: calc(125 * var(--confirm-popup-ref-px));
  color: #fff8d9;
  opacity: 0;
  pointer-events: auto;
  text-align: center;
  transform: translateX(-50%) translateY(calc(-9 * var(--confirm-popup-ref-px))) scale(0.985);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.starborn-confirm-popup.is-open {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

.starborn-confirm-popup.is-closing {
  pointer-events: none;
}

.starborn-confirm-popup.is-disabled {
  filter: saturate(0.82);
}

.starborn-confirm-popup__frame {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  grid-template-rows: calc(41 * var(--confirm-popup-ref-px)) 1fr calc(33 * var(--confirm-popup-ref-px));
  pointer-events: none;
  filter: drop-shadow(0 calc(9 * var(--confirm-popup-ref-px)) calc(14 * var(--confirm-popup-ref-px)) rgba(0, 0, 0, 0.42));
}

.starborn-confirm-popup__frame-top,
.starborn-confirm-popup__frame-middle,
.starborn-confirm-popup__frame-bottom {
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.starborn-confirm-popup__frame-top {
  background-image: url("/assets/lazy/common/modals/modal-big-top.png");
}

.starborn-confirm-popup__frame-middle {
  background-image: url("/assets/lazy/common/modals/modal-big-middle.png");
}

.starborn-confirm-popup__frame-bottom {
  background-image: url("/assets/lazy/common/modals/modal-big-bottom.png");
}

.starborn-confirm-popup__content {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: calc(125 * var(--confirm-popup-ref-px));
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(16 * var(--confirm-popup-ref-px));
  padding:
    calc(26 * var(--confirm-popup-ref-px))
    calc(28 * var(--confirm-popup-ref-px))
    calc(23 * var(--confirm-popup-ref-px));
}

.starborn-confirm-popup__title {
  max-width: 100%;
  margin: 0;
  color: #ffdc72;
  font-family: "Lilita One", Rajdhani, Inter, system-ui, sans-serif;
  font-size: calc(17 * var(--confirm-popup-ref-px));
  font-weight: 400;
  line-height: 1.08;
  overflow-wrap: break-word;
  -webkit-text-stroke: calc(1 * var(--confirm-popup-ref-px)) #05070b;
  paint-order: stroke fill;
  text-shadow:
    0 calc(1 * var(--confirm-popup-ref-px)) 0 #05070b,
    calc(1 * var(--confirm-popup-ref-px)) 0 0 #05070b,
    0 calc(-1 * var(--confirm-popup-ref-px)) 0 #05070b,
    calc(-1 * var(--confirm-popup-ref-px)) 0 0 #05070b,
    0 calc(2 * var(--confirm-popup-ref-px)) 0 #09131d,
    0 0 calc(5 * var(--confirm-popup-ref-px)) rgba(0, 0, 0, 0.72);
  text-transform: none;
}

.starborn-confirm-popup__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: calc(14 * var(--confirm-popup-ref-px));
  width: 100%;
}

.starborn-confirm-popup__button {
  appearance: none;
  position: relative;
  display: block;
  width: calc(109.44 * var(--confirm-popup-ref-px));
  aspect-ratio: 184 / 85;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #ffffff;
  background: transparent;
  cursor: pointer;
  font-family: "Lilita One", Rajdhani, Inter, system-ui, sans-serif;
  font-size: calc(14 * var(--confirm-popup-ref-px));
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1;
  overflow: visible;
  text-align: center;
  text-transform: uppercase;
}

.starborn-confirm-popup__button:disabled {
  cursor: default;
}

.starborn-confirm-popup__button:focus-visible {
  outline: calc(2 * var(--confirm-popup-ref-px)) solid rgba(255, 245, 168, 0.95);
  outline-offset: calc(2 * var(--confirm-popup-ref-px));
}

.starborn-confirm-popup__button-label {
  position: absolute;
  top: 1.17647%;
  right: calc(6 * var(--confirm-popup-ref-px));
  left: calc(6 * var(--confirm-popup-ref-px));
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 84.70588%;
  min-width: 0;
  -webkit-text-stroke: calc(0.8 * var(--confirm-popup-ref-px)) #05070b;
  paint-order: stroke fill;
  pointer-events: none;
  text-shadow:
    0 calc(1 * var(--confirm-popup-ref-px)) 0 #05070b,
    calc(1 * var(--confirm-popup-ref-px)) 0 0 #05070b,
    0 calc(-1 * var(--confirm-popup-ref-px)) 0 #05070b,
    calc(-1 * var(--confirm-popup-ref-px)) 0 0 #05070b,
    0 calc(1 * var(--confirm-popup-ref-px)) 0 rgba(53, 7, 17, 0.82);
  white-space: nowrap;
}

/* ─── Player Exited Battle Notification (Gamified) ─────────────────────── */

/* Base card */
.player-exited-notification,
.boss-unlock-notification {
  position: fixed;
  top: calc(var(--world-viewport-y) + var(--world-viewport-h) / 2);
  left: calc(var(--world-viewport-x) + var(--world-viewport-w) / 2);
  transform: translate(-50%, -50%) scale(0.75);
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transition:
    opacity 0.28s ease,
    transform 0.38s cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* Card shape */
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 36px 22px 24px;
  border-radius: 18px;
  min-width: 340px;
  max-width: calc(var(--world-viewport-w) - 32px);

  /* Deep-space dark glass */
  background: linear-gradient(
    135deg,
    rgba(6, 14, 26, 0.97) 0%,
    rgba(30, 10, 10, 0.97) 100%
  );
  border: 2px solid rgba(255, 107, 53, 0.8);
  box-shadow:
    0 0 0 1px rgba(255, 80, 30, 0.18),
    0 0 40px rgba(255, 80, 30, 0.35),
    0 0 80px rgba(255, 40, 10, 0.18),
    0 12px 40px rgba(0, 0, 0, 0.9);
}

.player-exited-notification.show,
.boss-unlock-notification.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.player-exited-notification.hide,
.boss-unlock-notification.hide {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.85) translateY(-18px);
  transition-duration: 0.22s;
}

/* Boss unlock reuses the exit-banner shape with a verdant/gold palette. */
.boss-unlock-notification {
  background: linear-gradient(
    135deg,
    rgba(6, 20, 14, 0.97) 0%,
    rgba(28, 22, 6, 0.97) 100%
  );
  border-color: rgba(255, 196, 61, 0.8);
  box-shadow:
    0 0 0 1px rgba(120, 220, 140, 0.2),
    0 0 40px rgba(90, 210, 130, 0.35),
    0 0 80px rgba(255, 196, 61, 0.2),
    0 12px 40px rgba(0, 0, 0, 0.9);
}

/* Animated glow ring behind icon */
.pen-glow-ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 18% 50%, rgba(255, 80, 30, 0.12) 0%, transparent 60%);
  pointer-events: none;
  animation: pen-pulse 2.2s ease-in-out infinite;
}

@keyframes pen-pulse {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1;   }
}

/* Icon wrapper */
.pen-icon-wrap {
  position: relative;
  flex-shrink: 0;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: rgba(255, 80, 30, 0.12);
  border: 2px solid rgba(255, 107, 53, 0.55);
  display: flex; align-items: center; justify-content: center;
  animation: pen-icon-spin-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.pen-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 8px rgba(255, 80, 30, 0.9));
}

@keyframes pen-icon-spin-in {
  from { transform: rotate(-30deg) scale(0.4); opacity: 0; }
  to   { transform: rotate(0deg)  scale(1);   opacity: 1; }
}

/* Text content */
.pen-content {
  flex: 1;
  text-align: left;
}

.pen-title {
  font-family: "Rajdhani", sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #ff6b35;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(255, 107, 53, 0.7);
  line-height: 1.1;
  animation: pen-slide-in 0.35s 0.05s ease both;
}

.pen-sub {
  font-family: "Rajdhani", sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: rgba(255, 200, 180, 0.8);
  letter-spacing: 0.03em;
  margin-top: 3px;
  animation: pen-slide-in 0.35s 0.12s ease both;
}

@keyframes pen-slide-in {
  from { transform: translateX(-10px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

/* Decorative floating stars */
.pen-stars {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0.6;
}

.pen-star {
  font-size: 12px;
  color: #ff9966;
  animation: pen-star-twinkle 1.8s ease-in-out infinite;
  display: block;
}
.pen-star:nth-child(1) { animation-delay: 0s;    font-size: 9px;  }
.pen-star:nth-child(2) { animation-delay: 0.6s;  font-size: 12px; }
.pen-star:nth-child(3) { animation-delay: 1.2s;  font-size: 9px;  }

@keyframes pen-star-twinkle {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%       { opacity: 1;   transform: scale(1.2); }
}

/* Corner accent lines */
.player-exited-notification::before,
.player-exited-notification::after,
.boss-unlock-notification::before,
.boss-unlock-notification::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  border-color: rgba(255, 107, 53, 0.6);
  border-style: solid;
}
.boss-unlock-notification::before,
.boss-unlock-notification::after {
  border-color: rgba(255, 196, 61, 0.6);
}
.player-exited-notification::before,
.boss-unlock-notification::before {
  top: 8px; left: 8px;
  border-width: 2px 0 0 2px;
  border-radius: 3px 0 0 0;
}
.player-exited-notification::after,
.boss-unlock-notification::after {
  bottom: 8px; right: 8px;
  border-width: 0 2px 2px 0;
  border-radius: 0 0 3px 0;
}

/* Landscape/short viewport adjustments for math challenge panel */
@media (max-height: 500px) {
  .rescue-challenge-stage {
    min-height: 100px;
    height: 25%;
  }
  .math-challenge-panel.is-rescue .math-challenge-shell,
  .math-challenge-panel.is-chest .math-challenge-shell,
  .math-challenge-panel.is-recharge .math-challenge-shell {
    height: 75%;
  }
  .rescue-challenge-frame {
    width: min(20vh, 120px);
    height: min(20vh, 120px);
  }
  .chest-challenge-sprite {
    width: min(22vh, 140px);
    height: min(15vh, 100px);
    --chest-challenge-offset-x: 10px;
    --chest-challenge-offset-y: 20px;
  }
  .rescue-challenge-status {
    width: min(220px, calc(var(--world-viewport-w) - 78px));
    padding: 20px 24px 22px;
    gap: 4px 8px;
    min-width: 0;
    top: 6px;
    left: 10px;
  }
  .rescue-challenge-status strong {
    font-size: 0.88rem;
  }
  .rescue-challenge-status span {
    font-size: 0.82rem;
  }
  .rescue-challenge-status i {
    height: 20px;
  }
  .math-challenge-close {
    top: 6px;
    right: 6px;
    width: 44px;
    height: 44px;
  }
}

/* ── Math Gateway (native worksheet + R-0 rail, prototype v3) ───────────── */
.math-gateway-host {
  display: none;
}

.math-challenge-panel.is-gateway {
  top: var(--world-viewport-y);
  height: var(--world-viewport-h);
  border-top: 0;
  background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)),
    url("/assets/lazy/math-gateway/starfield.webp") center / cover no-repeat;
}

.math-challenge-panel.is-gateway .math-gateway-host {
  container-type: size;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* Developer-only adaptive inspection panel, enabled by
   NODE_ENV=development plus ?math-debug-panel=true. */
.math-learning-debug-panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  width: min(350px, calc(100% - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(130, 226, 255, 0.55);
  border-radius: 10px;
  background: rgba(8, 16, 31, 0.94);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  color: #e8f7ff;
  font: 12px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
  pointer-events: none;
}

.math-learning-debug-panel__title {
  margin-bottom: 8px;
  color: #82e2ff;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.math-learning-debug-panel dl {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 4px 8px;
  margin: 0;
}

.math-learning-debug-panel dt {
  color: #8faabd;
}

.math-learning-debug-panel dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: #fff;
}

/* Old challenge banner: only the stage shows, once re-homed into the rail's subject box (heal/chest). */
.math-challenge-panel.is-gateway > .rescue-challenge-stage,
.math-challenge-panel.is-gateway > .math-challenge-shell,
.math-challenge-panel.is-gateway .rescue-challenge-status,
.math-challenge-panel .mg-subject-slot .chest-challenge-sprite {
  display: none;
}

/* The math web app iframe, hosted in the gateway's worksheet panel. */
.math-challenge-panel.is-gateway .mg-sheet-frame > .math-challenge-shell {
  grid-column: 1 / -1;
  height: 100%;
  min-height: 0;
}

.math-challenge-panel.is-gateway .math-challenge-close {
  top: -20px;
  right: 20px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 2px solid #deded8;
  border-radius: 50%;
  color: #252525;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
  filter: none;
  font: 700 22px/1 system-ui, sans-serif;
}
.math-challenge-panel.is-gateway .math-challenge-close::after { content: "×"; }
.math-challenge-panel.is-gateway .math-challenge-close:hover,
.math-challenge-panel.is-gateway .math-challenge-close:focus-visible {
  border: 0;
  color: #fff;
  background: #e53935;
}
.math-challenge-panel.is-gateway .math-challenge-close:focus-visible {
  outline: 2px solid #e53935;
  outline-offset: 2px;
}

/* Starborn's heal/chest stage (VFX + creature frame), over the subject box art and in front of the chest. */
/* Out-specifies the panel's .is-chest/.is-recharge stage art. */
.math-challenge-panel .mg-subject-slot .rescue-challenge-stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  height: auto;
  min-height: 0;
  border: 0;
  background: transparent;
  pointer-events: none;
}

/* Creature placement from Figma Math Gateway_Heal: 208.65x175.85 at top 75 of the 309x271 box. */
.mg-subject-slot .rescue-challenge-stage .rescue-challenge-frame {
  --rescue-challenge-frame-offset-y: 0px;
  top: 60%;
  width: 67.5%;
  height: 64.9%;
}

.mg {
  --mg-ground: #0d0b1e; --mg-panel: #151233; --mg-panel-2: #1c1840; --mg-line: #2a2560;
  --mg-violet: #8d55f0; --mg-cyan: #4fc3f7; --mg-gold: #f4c267; --mg-gold-deep: #c98a1e;
  --mg-hp: #ef4b4b; --mg-mp: #9a5cf0; --mg-ok: #43d6a0; --mg-muted: #9fb0d6; --mg-dim: #6e7aa6;
  --mg-paper: #ffffff; --mg-paper-2: #f6f5f0; --mg-paper-3: #eef3fb; --mg-ink: #1b1b2f; --mg-ink-2: #4a4a66; --mg-ink-3: #66667f;
  --mg-rule: #e3e1d8; --mg-rule-2: #cfcdc4;
  --mg-blue: #2e7cf6; --mg-blue-bg: #eaf1fe; --mg-wgold: #e0a21a; --mg-red: #e24b4a; --mg-red-bg: #fdecec;
  --mg-green: #2e9e6b; --mg-green-bg: #e8f7ef; --mg-amber-bg: #fff4d6;
  --mg-display: "Lilita One", system-ui, sans-serif;
  --mg-body: "Inter", system-ui, sans-serif;
  /* 1 Figma px: the 1920x1080 frame fitted to the host (a size container), so the rail scales with the screen. */
  --u: min(100cqw / 1920, 100cqh / 1080);
  position: relative;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 18fr 82fr;
  /* The mission rail and worksheet keep the requested 18:82 split at every desktop size. */
  gap: calc(37 * var(--u));
  padding: calc(41 * var(--u)) calc(48 * var(--u)) calc(41 * var(--u)) calc(33 * var(--u));
  color: #fff;
  font-family: var(--mg-body);
  font-size: 16px;
  line-height: 1.5;
}
.mg *, .mg *::before, .mg *::after { box-sizing: border-box; }
.mg button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
.mg button:focus-visible, .mg select:focus-visible { outline: 3px solid var(--mg-blue); outline-offset: 2px; }
.mg button:disabled { cursor: default; }
.mg [hidden] { display: none !important; }

.mg-panel { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.mg-tab { position: absolute; top: 0; transform: translateY(-50%); z-index: 6; font-family: var(--mg-display); font-size: 15px; letter-spacing: .3px; padding: 5px 16px; border-radius: 999px; white-space: nowrap; }
.mg-panel-game .mg-tab { top: calc(54 * var(--u)); left: calc(31 * var(--u)); width: calc(309 * var(--u)); height: calc(50 * var(--u)); display: grid; place-items: center; padding: 0; border: calc(4 * var(--u)) solid #62e7fe; border-radius: calc(30 * var(--u)); background: linear-gradient(#2C4178, #133549); box-shadow: 0 0 calc(8 * var(--u)) #62e7fe, inset 0 0 calc(6 * var(--u)) rgba(98, 231, 254, .45); color: #fff; font-size: calc(28 * var(--u)); letter-spacing: 0; text-transform: uppercase; -webkit-text-stroke: calc(6 * var(--u)) #000; paint-order: stroke fill; }
.mg-panel-game .mg-tab { left: 50%; transform: translate(-50%, -50%); }
.mg-panel-sheet .mg-tab { background: var(--mg-paper); border: 1.5px solid var(--mg-rule-2); color: var(--mg-ink-2); font-family: var(--mg-body); font-weight: 800; font-size: 13px; }
.mg-panel-sheet .mg-tab-q { left: 34px; }
/* 1px right of the rail divider: frame right border (1.5px) + rail column, then the divider (1.5px) + 1px. */
.mg-panel-sheet .mg-tab-answer { left: calc(100% - 460 * var(--u) + 1px); right: auto; }

/* rail */
/* frame.png = top cap (77) + side slice (20) + bottom cap (77), 396 wide. border-image stretches only the side slice,
   so the caps never leave a seam. The art is outset (14u top, 19u sides, 17u bottom) to match Figma's gaps around the
   tab and below the chat (~25u to the bottom bar), making it 410u wide, so each cap is 410 * 77 / 396 = 79.72u tall. */
.mg-frame { position: relative; flex: 1; min-height: 0; min-width: 0; border: 0 solid transparent; border-image: url("/assets/lazy/math-gateway/frame.png") 77 0 77 0 fill / calc(79.72 * var(--u)) 0 / calc(14 * var(--u)) calc(19 * var(--u)) calc(17 * var(--u)) stretch; display: flex; flex-direction: column; gap: calc(10 * var(--u)); padding: calc(94 * var(--u)) calc(32 * var(--u)) calc(29 * var(--u)) calc(31 * var(--u)); }
.mg-subject { position: relative; border-radius: calc(14 * var(--u)); background: var(--mg-panel-2); border: 1px solid var(--mg-line); flex: none; height: calc(190 * var(--u)); display: grid; place-items: center; overflow: hidden; }
.mg-glow { position: absolute; inset: auto 0 calc(14 * var(--u)) 0; height: calc(46 * var(--u)); border-radius: 50%; background: var(--mg-cyan); filter: blur(calc(26 * var(--u))); opacity: .15; transition: opacity .5s, background .5s; pointer-events: none; }
.mg-subject.is-hurt .mg-glow { background: var(--mg-hp); opacity: .2; }
.mg-subject.is-ok .mg-glow { background: var(--mg-ok); opacity: .45; }
.mg-subject.is-done .mg-glow { background: var(--mg-gold); opacity: .6; }
.mg-subject-slot { position: relative; width: 100%; height: 100%; display: grid; place-items: center; transition: transform .5s cubic-bezier(.2,.9,.3,1.3); }
.mg-subject-slot > img { position: absolute; inset: 12%; width: 76%; height: 76%; object-fit: contain; }
.mg-subject.is-ok .mg-subject-slot { transform: translateY(calc(-8 * var(--u))) scale(1.06); }
.mg-subject.is-shake .mg-subject-slot { animation: mgShake .4s; }
.mg-subject.is-done .mg-subject-slot { animation: mgBounce 1.2s ease-in-out infinite; }
.mg-subject-tag { position: absolute; top: calc(10 * var(--u)); left: calc(12 * var(--u)); z-index: 4; font-size: calc(16 * var(--u)); color: var(--mg-muted); font-weight: 700; }
@keyframes mgShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes mgBounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
/* Subject box for every mode (Figma: Math Gateway_Heal / _Recharge, 309x271). Positions are % of the box. */
.mg-subject:not(.mg-subject-done) {
  height: calc(271 * var(--u)); border-radius: calc(20 * var(--u)); border: calc(3 * var(--u)) solid #2B3E75;
  background: linear-gradient(180deg, #161656, #0B0E37);
}
.mg-subject-tag { top: calc(10 * var(--u)); left: calc(20 * var(--u)); font-family: var(--mg-display); font-size: calc(24 * var(--u)); line-height: calc(37 * var(--u)); font-weight: 400; color: #fff; opacity: .7; -webkit-text-stroke: calc(4 * var(--u)) #000; paint-order: stroke fill; }
/* Creature (Figma: 208.65x175.85 at top 75 in the 309x271 box). */
.mg-subject-slot > svg, .mg-subject-slot > img.mg-creature { position: absolute; z-index: 1; inset: 27.7% auto auto 50%; width: 67.5%; height: 64.9%; object-fit: contain; transform: translateX(-50%); }
.mg-mode-heal .mg-subject-slot > svg, .mg-mode-heal .mg-subject-slot > img.mg-creature { top: 50%; transform: translate(-50%, -50%); }
/* Rings + sparkles (241x148 in the 309x271 frame), centred under the potion. */
.mg-subject-slot::before { content: ""; position: absolute; left: 50%; top: 39%; width: 78%; height: 54.6%; transform: translateX(-50%); background: url("/assets/lazy/math-gateway/mana-bg.png") center / contain no-repeat; }
/* Heal/unlock: rings under the creature (Figma Math Gateway_Heal: 208.65x120.56 at top 130 of the box). */
.mg:not(.mg-mode-recharge) .mg-subject-slot::before { top: 48%; width: 67.5%; height: 44.5%; }/* Unlock (Figma Math Gateway_Unlock): wider rings centred ~79% down; chest ~188u wide, base on the rings, lid opens upward. */
.mg-mode-unlock .mg-subject-slot::before { top: 34%; width: 88%; height: 61.6%; }
.mg-mode-unlock .mg-subject-slot > img.mg-creature { top: auto; bottom: 16%; width: 45%; height: auto; }
.mg-mode-recharge .mg-subject-slot > .mg-potion { position: absolute; z-index: 1; top: 25%; left: 50%; height: 62%; transform: translateX(-50%); }
.mg-potion { position: relative; height: 76%; aspect-ratio: 1; }
.mg-potion > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.mg-potion > .mg-potion-lid { inset: 3% auto auto 50%; width: 28%; height: auto; transform: translateX(-50%); display: none; }
.mg-potion.is-full > .mg-potion-lid { display: block; animation: mgLidDrop .5s cubic-bezier(.2,.9,.3,1.3) both; }
@keyframes mgLidDrop { from { opacity: 0; transform: translate(-50%, -80%); } to { opacity: 1; transform: translate(-50%, 0); } }
/* Figma Math Gateway_Heal: name 17u in from the box, meta 12u in from the right; 9u below the box, 10u above Healing. */
.mg-name { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 calc(8 * var(--u)); margin: calc(-3 * var(--u)) 0 calc(-2 * var(--u)); padding: 0 calc(12 * var(--u)) 0 calc(17 * var(--u)); flex: none; min-width: 0; }
.mg-name b, .mg-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mg-name b { font-family: var(--mg-display); font-size: calc(30 * var(--u)); line-height: calc(37 * var(--u)); font-weight: 400; color: #fff; -webkit-text-stroke: calc(6 * var(--u)) #000; paint-order: stroke fill; }
.mg-name span { font-size: calc(18 * var(--u)); line-height: calc(40 * var(--u)); color: #b9bdd6; font-weight: 500; }
.mg-name span em { font-style: normal; color: #ff4f6d; }
/* Figma: Healing box 309x115. */
.mg-mission { background: linear-gradient(180deg, #161656, #0B0E37); border: calc(3 * var(--u)) solid #2B3E75; border-radius: calc(20 * var(--u)); height: calc(115 * var(--u)); padding: calc(10 * var(--u)) calc(20 * var(--u)); display: flex; flex-direction: column; justify-content: center; gap: calc(6 * var(--u)); flex: none; }
.mg-mission-row { display: flex; justify-content: space-between; align-items: center; font-family: var(--mg-display); font-size: calc(24 * var(--u)); line-height: 1; font-weight: 400; color: #d0d2e0; -webkit-text-stroke: calc(4 * var(--u)) #000; paint-order: stroke fill; }
.mg-mission-row b { color: #fff; font-family: var(--mg-body); font-weight: 400; font-size: calc(20 * var(--u)); -webkit-text-stroke: 0; }
.mg-progress { display: flex; gap: calc(8 * var(--u)); align-items: center; min-height: calc(36 * var(--u)); }
.mg-pip { flex: 1; max-width: calc(50 * var(--u)); aspect-ratio: 1; display: grid; place-items: center; color: #3a3660; transition: color .4s, transform .4s; }
.mg-pip svg, .mg-pip img { width: 100%; height: 100%; object-fit: contain; }
.mg-mode-heal .mg-pip:not(.is-on) { opacity: .5; }
.mg-mode-unlock .mg-pip img { width: 55%; height: 55%; }
.mg-pip.is-fill { animation: mgHeartPop .6s cubic-bezier(.2,.9,.3,1.4); }
@keyframes mgHeartPop { 0% { transform: scale(.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
.mg-bar { position: relative; height: calc(20 * var(--u)); border-radius: calc(999 * var(--u)); background: #0b0a1a; border: 1px solid var(--mg-line); overflow: hidden; flex: 1; }
.mg-bar i { position: absolute; inset: 0; width: 0; background: var(--mg-mp); border-radius: calc(999 * var(--u)); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.mg-bar i::after { content: ""; position: absolute; top: calc(3 * var(--u)); left: calc(6 * var(--u)); right: calc(8 * var(--u)); height: calc(4 * var(--u)); border-radius: calc(999 * var(--u)); background: rgba(255,255,255,.35); }
.mg-barlabel { font-size: calc(13 * var(--u)); color: var(--mg-muted); font-weight: 700; min-width: calc(52 * var(--u)); text-align: right; }

/* Figma: R-0 chat 309x413, 20u below Healing; header 70u. */
.mg-chat { flex: 1; min-height: calc(150 * var(--u)); min-width: 0; display: flex; flex-direction: column; margin-top: calc(10 * var(--u)); background: #0B0E37; border: calc(3 * var(--u)) solid #2B3E75; border-radius: calc(20 * var(--u)); overflow: hidden; }
.mg-chathead { display: flex; align-items: center; gap: calc(8 * var(--u)); flex: none; height: calc(70 * var(--u)); padding: 0 calc(23 * var(--u)) 0 calc(19 * var(--u)); background: linear-gradient(180deg, #161656, #101247); border-bottom: calc(3 * var(--u)) solid #2B3E75; font-family: var(--mg-display); font-size: calc(24 * var(--u)); line-height: 1; font-weight: 400; color: #00DEFF; -webkit-text-stroke: calc(6 * var(--u)) #000; paint-order: stroke fill; }
.mg-chathead-face { width: calc(44.15 * var(--u)); height: calc(44.15 * var(--u)); flex: none; display: grid; place-items: center; }
.mg-chathead-face img { width: 100%; height: 100%; object-fit: contain; }
.mg-chathead-state { margin-left: auto; font-family: var(--mg-body); font-size: calc(16 * var(--u)); font-weight: 400; color: #fff; opacity: .7; -webkit-text-stroke: 0; }
.mg-log { flex: 1; min-height: 0; min-width: 0; overflow: auto; overflow-x: hidden; padding: calc(14 * var(--u)) calc(15 * var(--u)) calc(7 * var(--u)) calc(9 * var(--u)); display: flex; flex-direction: column; gap: calc(16 * var(--u)); }
.mg-log::-webkit-scrollbar { width: calc(5 * var(--u)); }
.mg-log::-webkit-scrollbar-thumb { background: var(--mg-line); border-radius: calc(3 * var(--u)); }
/* Figma: bubbles #20203F, 2u border, 15u radius with the speaker-side bottom corner square. */
.mg-msg { display: block; flex: none; width: fit-content; max-width: 90%; overflow-wrap: anywhere; padding: calc(10 * var(--u)) calc(12 * var(--u)); border-radius: calc(15 * var(--u)); font-size: calc(16 * var(--u)); line-height: 1.2; color: #fff; background: #20203F; border: calc(2 * var(--u)) solid #2B3E75; animation: mgPop .25s cubic-bezier(.2,.8,.2,1); }
@keyframes mgPop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.mg-msg small { display: block; font-size: calc(16 * var(--u)); font-weight: 400; margin-bottom: calc(4 * var(--u)); color: var(--mg-cyan); }
/* No per-message R-0 avatar: bubbles sit flush left (the chat header already names R-0). */
.mg-msg.is-r0 { position: relative; align-self: flex-start; max-width: min(100%, calc(245 * var(--u))); border-bottom-left-radius: 0; }
.mg-msg.is-r0.is-hint { border-color: var(--mg-gold); }
.mg-msg.is-r0.is-hint small { color: var(--mg-gold); }
.mg-msg.is-r0.is-good { border-color: var(--mg-ok); }
.mg-msg.is-r0.is-good small { color: var(--mg-ok); }
.mg-msg.is-r0.is-soft { border-color: #FB575E; }
.mg-msg.is-r0.is-answer { border-color: var(--mg-cyan); background: #12213a; }
.mg-msg.is-me { align-self: flex-end; border-bottom-right-radius: 0; font-size: calc(18 * var(--u)); min-height: calc(32.5 * var(--u)); padding: calc(3 * var(--u)) calc(12 * var(--u)); }
.mg-msg.is-me.is-wrong { border-color: #FB575E; }
.mg-msg.is-me.is-wrong::before { content: "×"; display: inline-block; margin-right: calc(4 * var(--u)); color: #FB575E; font-weight: 400; }
.mg-msg.is-me.is-right { border-color: var(--mg-ok); }
.mg-typing { align-self: flex-start; flex: none; display: flex; gap: calc(4 * var(--u)); padding: 0; }
.mg-typing i { width: calc(7.25 * var(--u)); height: calc(7.25 * var(--u)); border-radius: 50%; background: #61E6FE; box-shadow: 0 0 calc(6 * var(--u)) rgba(97, 230, 254, .7); animation: mgDot 1s infinite; }
.mg-typing i:nth-child(2) { animation-delay: .15s; }
.mg-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes mgDot { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* worksheet */
.mg-sheet-frame { position: relative; flex: 1; min-height: 0; min-width: 0; background: var(--mg-paper); border: 1.5px solid var(--mg-rule); border-radius: calc(40 * var(--u)); box-shadow: 0 calc(10 * var(--u)) calc(30 * var(--u)) rgba(0,0,0,.35); display: grid; grid-template-columns: 1fr calc(460 * var(--u)); color: var(--mg-ink); overflow: hidden; }
.mg-canvas { padding: 30px 34px 26px; gap: 16px; display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; }
.mg-dots { display: flex; gap: 6px; align-items: center; }
.mg-dots i { height: 8px; border-radius: 999px; background: var(--mg-rule); flex: 1; transition: background .4s, flex .4s; }
.mg-dots i.is-cur { background: var(--mg-blue); }
.mg-dots i.is-ok { background: var(--mg-green); }
.mg-dots i.is-miss { background: var(--mg-red); opacity: .5; }
.mg-dots i.is-pending { background: var(--mg-rule-2); }
.mg-skillrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mg-pills { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mg-pill { font-size: 13px; font-weight: 800; color: #1f63d6; background: var(--mg-blue-bg); padding: 5px 12px; border-radius: 999px; }
.mg .mg-speak { width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--mg-rule); background: var(--mg-paper); display: grid; place-items: center; color: var(--mg-ink-2); }
.mg .mg-speak:hover { background: var(--mg-paper-2); }
.mg-speak svg { width: 20px; height: 20px; }
.mg-q { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 16px; overflow: auto; overflow-x: hidden; padding-right: 4px; }
.mg-q::-webkit-scrollbar { width: 6px; }
.mg-q::-webkit-scrollbar-thumb { background: var(--mg-rule); border-radius: 3px; }
.mg-q.is-enter { animation: mgSlideIn .45s cubic-bezier(.2,.8,.2,1); }
.mg-q.is-leave { animation: mgSlideOut .3s ease-in forwards; }
@keyframes mgSlideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes mgSlideOut { to { opacity: 0; transform: translateX(-40px); } }
.mg-prompt { font-size: 25px; line-height: 1.35; font-weight: 800; margin: 0; color: var(--mg-ink); max-width: 48ch; font-family: var(--mg-body); }
.mg-sub { margin: 0 0 10px; color: var(--mg-ink-2); font-size: 16px; font-weight: 600; }
.mg-loading { display: grid; flex: 1; place-items: center; margin: 0; color: var(--mg-ink-2); font-size: 18px; font-weight: 700; }

/* question model: host region for contentBlocks / future QTI */
.mg-model { background: var(--mg-paper-3); border: 1.5px solid #dce6f5; border-radius: 16px; padding: 22px 28px; display: flex; align-items: center; justify-content: center; min-width: 0; overflow: hidden; flex: none; }
.mg-model figure { margin: 0; width: 100%; max-width: 620px; }
.mg-model svg { max-width: 100%; }
/* Math app model visuals (fraction bars, arrays, number lines, histograms, tapes), scoped copy of starborn-math-app style.css so server html contentBlocks render natively. */
.mg-model { --paper: #faf8f3; --surface: #ffffff; --surface-sunken: #f4f2ea; --ink: #2b2014; --ink-soft: #4c3d2c; --ink-mid: #6b5a45; --line-card: #eceadf; --tone-blue: #2f6f9e; --tone-blue-soft: #eaf2f8; --tone-teal: #12958a; --tone-teal-soft: #eaf6f4; --tone-plum: #7a4a8f; --tone-plum-soft: #f4eef7; --tone-amber: #a76a12; --tone-amber-soft: #fdf3e4; --tone-rose: #b0455f; --tone-rose-soft: #fdeef1; --radius-card: 16px; --radius-sm: 8px; }
.mg-model .math-model {
    --model-accent: var(--tone-blue);
    --model-soft: var(--tone-blue-soft);
    position: relative;
    box-sizing: border-box;
    width: 100%;
    min-height: 116px;
    margin: 0;
    padding: clamp(18px, 3vw, 28px);
    overflow: hidden;
    color: var(--ink);
    border: 1px solid var(--line-card);
    border-radius: var(--radius-card);
    background: var(--surface);
}

.mg-model .math-model-amber { --model-accent: var(--tone-amber); --model-soft: var(--tone-amber-soft); }
.mg-model .math-model-blue { --model-accent: var(--tone-blue); --model-soft: var(--tone-blue-soft); }
.mg-model .math-model-mint { --model-accent: var(--tone-teal); --model-soft: var(--tone-teal-soft); }
.mg-model .math-model-violet { --model-accent: var(--tone-plum); --model-soft: var(--tone-plum-soft); }
.mg-model .math-model-rose { --model-accent: var(--tone-rose); --model-soft: var(--tone-rose-soft); }

.mg-model .math-model-kicker {
    display: block;
    margin-bottom: 12px;
    color: color-mix(in srgb, var(--model-accent) 75%, var(--ink));
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.mg-model .math-expression,
.mg-model .math-scenario-value {
    display: block;
    color: var(--ink);
    font-size: clamp(28px, 5vw, 46px);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.mg-model .math-scenario-detail {
    display: block;
    margin-top: 8px;
    color: var(--ink-soft);
    font-size: 15px;
}

.mg-model .fraction-track {
    display: grid;
    width: min(100%, 520px);
    height: 52px;
    grid-template-columns: repeat(var(--fraction-parts), 1fr);
    overflow: hidden;
    border: 2px solid var(--model-accent);
    border-radius: 13px;
    background: var(--surface-sunken);
}

.mg-model .fraction-piece + .fraction-piece {
    border-left: 1px solid var(--model-accent);
}

.mg-model .fraction-piece.is-filled {
    border-left-color: var(--paper);
    background: var(--model-accent);
}

.mg-model .fraction-label,
.mg-model .array-label,
.mg-model .tape-total {
    display: block;
    margin-top: 10px;
    color: var(--ink);
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.mg-model .array-grid {
    display: grid;
    width: fit-content;
    max-width: 100%;
    grid-template-columns: repeat(var(--array-columns), 28px);
    gap: 7px;
}

.mg-model .array-dot {
    width: 28px;
    height: 28px;
    box-sizing: border-box;
    border: 2px solid var(--model-accent);
    border-radius: 9px;
    background: var(--surface-sunken);
}

.mg-model .array-dot.is-filled {
    border-color: var(--model-accent);
    background: var(--model-accent);
}

.mg-model .number-line-track {
    position: relative;
    display: flex;
    height: 72px;
    margin: 10px 20px 0;
    align-items: center;
    justify-content: space-between;
    border-top: 4px solid var(--ink-soft);
}

.mg-model .number-line-end {
    margin-top: 22px;
    color: var(--ink-mid);
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.mg-model .number-line-marker {
    position: absolute;
    top: -10px;
    left: var(--marker-position);
    display: grid;
    justify-items: center;
    transform: translateX(-50%);
}

.mg-model .number-line-marker i {
    width: 3px;
    height: 20px;
    border-radius: 999px;
    background: var(--model-accent);
}

.mg-model .number-line-marker b {
    margin-top: 7px;
    color: var(--ink);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.mg-model .number-line-marker.is-emphasized i {
    width: 12px;
    height: 12px;
    margin-top: 4px;
    border: 3px solid var(--model-accent);
    border-radius: 50%;
    background: var(--model-accent);
}

.mg-model .number-line-marker.is-open i {
    background: var(--surface);
    border-color: var(--model-accent);
    outline: 2px solid var(--model-accent);
    outline-offset: -1px;
}

.mg-model .number-line-ray {
    position: absolute;
    top: -6px;
    height: 8px;
    border-radius: 999px;
    background: var(--model-accent);
}

.mg-model .number-line-ray.is-right {
    right: -4px;
    left: var(--ray-position);
}

.mg-model .number-line-ray.is-left {
    right: calc(100% - var(--ray-position));
    left: -4px;
}

.mg-model .number-line-ray::after {
    position: absolute;
    top: 50%;
    content: "";
    transform: translateY(-50%);
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

.mg-model .number-line-ray.is-right::after {
    right: -8px;
    border-left: 10px solid var(--model-accent);
}

.mg-model .number-line-ray.is-left::after {
    left: -8px;
    border-right: 10px solid var(--model-accent);
}

.mg-model .histogram-chart {
    display: grid;
    width: min(100%, 560px);
    min-height: 190px;
    grid-template-columns: repeat(var(--histogram-columns), minmax(0, 1fr));
    align-items: end;
    padding: 16px 8px 0;
    border-bottom: 3px solid var(--ink-soft);
    border-left: 3px solid var(--ink-soft);
}

.mg-model .histogram-bin {
    display: grid;
    min-width: 0;
    height: 170px;
    grid-template-rows: 22px 118px 30px;
    align-items: end;
    text-align: center;
}

.mg-model .histogram-bin b {
    color: var(--ink);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.mg-model .histogram-bin i {
    width: 100%;
    height: calc(var(--bar-ratio) * 118px);
    min-height: 2px;
    align-self: end;
    border: 1px solid var(--model-accent);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    background: color-mix(in srgb, var(--model-accent) 22%, var(--paper));
}

.mg-model .histogram-bin.is-emphasized i {
    background: var(--model-accent);
}

.mg-model .histogram-bin small {
    display: grid;
    min-width: 0;
    min-height: 30px;
    place-items: center;
    padding: 4px;
    color: var(--ink-mid);
    font-size: 11px;
    font-style: normal;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

.mg-model .tape-parts,
.mg-model .comparison-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Scoped to .math-model so it outranks `.question-html-wrapper span { color: inherit }`,
   which otherwise forces the label to the model's ink colour on top of a solid fill. */
.mg-model .math-model .tape-part {
    min-width: 64px;
    padding: 14px 18px;
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--model-accent) 85%, var(--ink));
}

.mg-model .comparison-card {
    display: grid;
    min-width: 120px;
    padding: 16px;
    gap: 4px;
    color: var(--ink);
    border: 1px solid color-mix(in srgb, var(--model-accent) 70%, var(--paper));
    border-radius: var(--radius-card);
    background: var(--model-soft);
}

.mg-model .comparison-card small {
    color: color-mix(in srgb, var(--model-accent) 75%, var(--ink));
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mg-model .comparison-card strong {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.mg-table { border-collapse: collapse; font-size: 22px; font-weight: 800; min-width: 240px; background: var(--mg-paper); }
.mg-table th, .mg-table td { border: 2px solid var(--mg-rule-2); padding: 8px 28px; text-align: center; }
.mg-table th { background: var(--mg-blue-bg); color: var(--mg-blue); font-family: var(--mg-display); font-weight: 400; }
.mg-table td.is-blank { color: var(--mg-blue); font-family: var(--mg-display); }

/* answer region, shared marks */
.mg-answer { display: flex; flex-direction: column; width: 100%; }
.mg-mark { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%; display: none; place-items: center; color: #fff; }
.mg-mark svg { width: 18px; height: 18px; }
.is-ok > .mg-mark { display: grid; background: var(--mg-green); }
.is-bad > .mg-mark { display: grid; background: var(--mg-red); }

.mg-choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; width: 100%; }
.mg .mg-choice { position: relative; min-height: 68px; padding: 8px 48px; border-radius: 14px; background: var(--mg-paper); border: 2px solid var(--mg-rule-2); font-family: var(--mg-display); font-size: 28px; letter-spacing: .5px; color: var(--mg-ink); transition: border-color .15s, background .15s; }
.mg-choices.is-long .mg-choice { font-family: var(--mg-body); font-weight: 800; font-size: 19px; }
.mg .mg-choice:hover:not(:disabled) { border-color: var(--mg-blue); }
.mg .mg-choice[aria-pressed="true"] { border-color: var(--mg-blue); background: var(--mg-blue-bg); }
.mg .mg-choice.is-ok { border-color: var(--mg-green); background: var(--mg-green-bg); }
.mg .mg-choice.is-bad { border-color: var(--mg-red); background: var(--mg-red-bg); }

.mg-fill { display: flex; align-items: center; gap: 12px; width: 100%; }
.mg-affix { font-family: var(--mg-display); font-size: 30px; color: var(--mg-ink-2); }
.mg-field { flex: 1; min-width: 0; height: 68px; border-radius: 14px; background: var(--mg-paper); border: 2px solid var(--mg-rule-2); display: flex; align-items: center; padding: 0 22px; font-family: var(--mg-display); font-size: 34px; letter-spacing: 1px; color: var(--mg-ink); position: relative; transition: border-color .2s, box-shadow .2s, background .2s; }
.mg-field.is-active { border-color: var(--mg-blue); box-shadow: 0 0 0 4px rgba(46,124,246,.15); }
.mg-ph { position: absolute; left: 22px; color: var(--mg-ink-3); font-family: var(--mg-body); font-size: 17px; font-weight: 600; letter-spacing: 0; pointer-events: none; }
.mg-field:not(.is-empty) .mg-ph { display: none; }
.mg-field.is-active.is-empty::before { content: ""; width: 2px; height: 36px; background: var(--mg-blue); animation: mgCaret 1s steps(1) infinite; margin-right: 2px; }
@keyframes mgCaret { 50% { opacity: 0; } }
.mg-unit { margin-left: 8px; color: var(--mg-ink-2); font-family: var(--mg-body); font-size: 17px; font-weight: 600; }
.mg-field.is-empty .mg-unit { margin-left: auto; }
.mg-field .mg-mark { width: 36px; height: 36px; right: 16px; }
.mg-field .mg-mark svg { width: 22px; height: 22px; }
.mg-field.is-ok { border-color: var(--mg-green); background: var(--mg-green-bg); box-shadow: none; }
.mg-field.is-bad { border-color: var(--mg-red); background: var(--mg-red-bg); animation: mgShake .4s; box-shadow: none; }
/* time entry: an hours box and a minutes box with a colon between them */
.mg-te { display: flex; align-items: center; gap: 12px; position: relative; }
.mg-te-box { position: relative; width: 96px; min-height: 68px; border-radius: 14px; background: var(--mg-paper); border: 2px solid var(--mg-rule-2); display: flex; align-items: center; justify-content: center; font-family: var(--mg-display); font-size: 40px; letter-spacing: 1px; color: var(--mg-ink); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.mg-te-box:focus-visible { outline: 3px solid var(--mg-blue); outline-offset: 2px; }
.mg-te-box.is-active { border-color: var(--mg-blue); box-shadow: 0 0 0 4px rgba(46,124,246,.15); }
.mg-te-box .mg-ph { left: 0; right: 0; text-align: center; }
.mg-te-box:not(.is-empty) .mg-ph { display: none; }
.mg-te-box.is-active.is-empty::before { content: ""; width: 2px; height: 38px; background: var(--mg-blue); animation: mgCaret 1s steps(1) infinite; }
.mg-te-colon { font-family: var(--mg-display); font-size: 40px; color: var(--mg-ink); line-height: 1; }
.mg-te-mark { width: 36px; height: 36px; border-radius: 50%; display: none; place-items: center; color: #fff; margin-left: 4px; }
.mg-te-mark svg { width: 22px; height: 22px; }
.mg-te.is-ok .mg-te-box { border-color: var(--mg-green); background: var(--mg-green-bg); box-shadow: none; }
.mg-te.is-bad .mg-te-box { border-color: var(--mg-red); background: var(--mg-red-bg); animation: mgShake .4s; box-shadow: none; }
.mg-te.is-ok .mg-te-mark { display: grid; background: var(--mg-green); }
.mg-te.is-bad .mg-te-mark { display: grid; background: var(--mg-red); }
.mg-te-hint { margin: 12px 0 0; min-height: 24px; }
.mg-key.is-blank { visibility: hidden; }


.mg-order { display: flex; flex-direction: column; gap: 14px; }
.mg-slots { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.mg-slots li { display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 6px; border-radius: 14px; border: 2px dashed var(--mg-rule-2); background: var(--mg-paper-2); }
.mg-slot-n { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--mg-blue-bg); color: var(--mg-blue); font-family: var(--mg-display); font-size: 16px; }
.mg-slot-empty { flex: 1; }
.mg-pool { display: flex; flex-wrap: wrap; gap: 10px; }
.mg .mg-chip { min-height: 48px; padding: 6px 18px; border-radius: 12px; background: var(--mg-paper); border: 2px solid var(--mg-rule-2); border-bottom-width: 4px; font-family: var(--mg-body); font-weight: 800; font-size: 18px; color: var(--mg-ink); }
.mg .mg-chip:hover:not(:disabled) { border-color: var(--mg-blue); }
.mg .mg-chip.is-used { visibility: hidden; }
.mg .mg-chip.is-placed { flex: 1; min-width: 0; padding: 6px 10px; overflow-wrap: anywhere; border-color: var(--mg-blue); background: var(--mg-blue-bg); }
.mg-order.is-ok .mg-slots li { border-style: solid; border-color: var(--mg-green); background: var(--mg-green-bg); }
.mg-order.is-bad .mg-slots li { border-style: solid; border-color: var(--mg-red); background: var(--mg-red-bg); }

.mg-match { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 28px; }
.mg-match-col { display: flex; flex-direction: column; gap: 10px; }
.mg .mg-match-item { position: relative; min-height: 56px; padding: 8px 14px 8px 48px; text-align: left; border-radius: 14px; background: var(--mg-paper); border: 2px solid var(--mg-rule-2); font-weight: 800; font-size: 16px; color: var(--mg-ink); line-height: 1.3; }
.mg .mg-match-item:hover:not(:disabled) { border-color: var(--mg-blue); }
.mg .mg-match-item.is-active { border-color: var(--mg-blue); box-shadow: 0 0 0 4px rgba(46,124,246,.15); }
.mg-pair-badge { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-family: var(--mg-display); font-size: 14px; background: var(--pair); }
.mg .mg-match-item.is-paired { border-color: var(--pair); background: color-mix(in srgb, var(--pair) 10%, #fff); }
.mg-pair-0 { --pair: #2e7cf6; }
.mg-pair-1 { --pair: #7e57c2; }
.mg-pair-2 { --pair: #e0a21a; }
.mg-pair-3 { --pair: #2e9e6b; }
.mg-match.is-ok .mg-match-item { border-color: var(--mg-green); }
.mg-match.is-bad .mg-match-item.is-paired { border-color: var(--mg-red); }

.mg-gridwrap { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.mg-grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(64px, 110px)); gap: 6px; }
.mg .mg-cell { height: 72px; border-radius: 10px; background: var(--mg-paper); border: 2px solid var(--mg-rule-2); font-family: var(--mg-display); font-size: 24px; color: var(--mg-ink-2); transition: background .15s, border-color .15s; }
.mg .mg-cell:hover:not(:disabled) { border-color: var(--mg-blue); }
.mg .mg-cell.is-on { background: var(--mg-blue-bg); border-color: var(--mg-blue); color: var(--mg-blue); }
/* Label grids (not line plots) fill the answer area as even tiles, like the choice buttons. */
.mg-gridwrap:not(.is-plot) { align-items: stretch; width: 100%; }
.mg-gridwrap:not(.is-plot) .mg-grid { grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 12px; }
.mg-gridwrap:not(.is-plot) .mg-cell { height: auto; min-height: 68px; padding: 10px 14px; border-radius: 14px; font-size: 28px; line-height: 1.2; overflow-wrap: anywhere; }
.mg-gridwrap.is-long .mg-cell { font-family: var(--mg-body); font-weight: 800; font-size: 17px; min-height: 52px; padding: 8px 6px; overflow-wrap: normal; word-break: normal; }
.mg-gridwrap.is-plot .mg-cell { height: 56px; border-style: dashed; font-size: 30px; }
.mg-gridwrap.is-plot .mg-cell.is-on { border-style: solid; }
.mg-plot-axis { display: grid; grid-template-columns: repeat(var(--cols), minmax(64px, 110px)); gap: 6px; border-top: 4px solid var(--mg-ink); padding-top: 6px; font-weight: 800; font-size: 18px; text-align: center; }
.mg-gridwrap.is-ok .mg-cell.is-on { background: var(--mg-green-bg); border-color: var(--mg-green); color: var(--mg-green); }
.mg-gridwrap.is-bad .mg-cell.is-on { background: var(--mg-red-bg); border-color: var(--mg-red); color: var(--mg-red); }

.mg-sentence { margin: 0; font-size: 26px; font-weight: 700; line-height: 2.2; color: var(--mg-ink); }
.mg-select { font: inherit; font-family: var(--mg-display); font-size: .95em; color: var(--mg-blue); background: var(--mg-blue-bg); border: 2px solid var(--mg-blue); border-radius: 12px; padding: 2px 10px; margin: 0 4px; cursor: pointer; }
.mg-select.is-empty { color: var(--mg-ink-3); background: var(--mg-paper); border-color: var(--mg-rule-2); border-style: dashed; }
.mg-sentence.is-ok .mg-select { color: var(--mg-green); background: var(--mg-green-bg); border-color: var(--mg-green); }
.mg-sentence.is-bad .mg-select { color: var(--mg-red); background: var(--mg-red-bg); border-color: var(--mg-red); }

/* number line: one marker on a line of ticks */
.mg-numline { display: flex; flex-direction: column; gap: 10px; width: 100%; --nl-mark: var(--mg-blue); }
.mg-nl-track { position: relative; height: 104px; padding: 0 30px; border-radius: 14px; touch-action: none; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.mg-nl-track:focus-visible { outline: 3px solid var(--mg-blue); outline-offset: 2px; }
.mg-nl-track[aria-disabled="true"] { cursor: default; }
.mg-nl-scale { position: relative; height: 100%; }
.mg-nl-rail { position: absolute; left: -10px; right: -10px; top: 52px; height: 6px; margin-top: -3px; border-radius: 3px; background: var(--mg-ink); }
.mg-nl-tick { position: absolute; top: 40px; width: 2px; height: 24px; margin-left: -1px; border-radius: 1px; background: var(--mg-ink-3); }
.mg-nl-tick.is-major { top: 34px; width: 3px; height: 36px; margin-left: -1.5px; background: var(--mg-ink); }
.mg-numline.is-dense .mg-nl-tick:not(.is-major) { width: 1px; margin-left: -.5px; }
.mg-nl-lab { position: absolute; top: 76px; transform: translateX(-50%); font-family: var(--mg-body); font-weight: 800; font-size: 16px; line-height: 1.2; color: var(--mg-ink); white-space: nowrap; }
.mg-nl-mark { position: absolute; top: 2px; width: 28px; height: 28px; margin-left: -14px; border-radius: 50%; background: var(--nl-mark); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(27,27,47,.35); transition: left .12s ease-out; }
.mg-numline.is-dragging .mg-nl-mark { transition: none; }
@media (prefers-reduced-motion: reduce) { .mg-nl-mark { transition: none; } }
.mg-nl-mark::after { content: ""; position: absolute; left: 50%; top: 100%; width: 4px; height: 18px; margin: 3px 0 0 -2px; border-radius: 2px; background: var(--nl-mark); }
.mg-nl-mark.is-ghost { background: transparent; border: 3px dashed var(--mg-blue); box-shadow: none; opacity: .55; }
.mg-nl-mark.is-ghost::after { display: none; }
.mg-sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mg-nl-read { min-height: 1.3em; margin: 0; text-align: center; font-weight: 800; font-size: 17px; line-height: 1.3; color: var(--mg-ink); overflow-wrap: anywhere; }
.mg-nl-read svg { width: 18px; height: 18px; vertical-align: -3px; }
.mg-nl-unit { margin: 0; text-align: center; font-size: 14px; font-weight: 700; color: var(--mg-ink-2); }
.mg-numline.is-ok { --nl-mark: var(--mg-green); }
.mg-numline.is-ok .mg-nl-read { color: var(--mg-green); }
.mg-numline.is-bad { --nl-mark: var(--mg-red); }
.mg-numline.is-bad .mg-nl-read { color: var(--mg-red); }

/* draw on a grid: an SVG board in grid units; strokes are in screen pixels so they stay crisp at any size */
.mg-draw { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; --dg-color: var(--mg-blue); --dg-fill: rgba(46,124,246,.18); }
/* The grid never grows taller than this, so the whole grid, its readout and its unit note stay on one screen (no scrolling mid-drawing). */
.mg-draw { --dg-maxh: clamp(200px, calc(100vh - 400px), 460px); }
.mg-dg-board { width: 100%; display: flex; justify-content: center; padding: 6px 0; border-radius: 14px; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.mg-dg-board:focus-visible { outline: 3px solid var(--mg-blue); outline-offset: 2px; }
.mg-dg-board[aria-disabled="true"] { cursor: default; }
.mg-dg-svg { display: block; width: 100%; height: auto; overflow: visible; }
.mg-dg-lines { fill: none; stroke: var(--mg-ink-3); stroke-width: 1px; stroke-opacity: .55; vector-effect: non-scaling-stroke; }
.mg-dg-dots { fill: none; stroke: var(--mg-ink-3); stroke-width: 4px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.mg-dg-cell { fill: #dfe6f7; stroke: #8da0d6; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.mg-dg-shape rect { fill: var(--dg-fill); stroke: var(--dg-color); stroke-width: 3px; vector-effect: non-scaling-stroke; }
.mg-dg-shape line { stroke: var(--dg-color); stroke-width: 6px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.mg-dg-shape .mg-dg-end { fill: #fff; stroke: var(--dg-color); stroke-width: 3px; vector-effect: non-scaling-stroke; }
.mg-dg-shape.is-example rect, .mg-dg-shape.is-example line { stroke: var(--mg-green); stroke-dasharray: 8 6; stroke-linecap: butt; }
.mg-dg-shape.is-example rect { fill: var(--mg-green-bg); fill-opacity: .6; }
.mg-dg-shape.is-example .mg-dg-end { stroke: var(--mg-green); }
.mg-dg-cursor { display: none; fill: none; stroke: var(--mg-ink); stroke-width: 3px; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.mg-draw.is-keys .mg-dg-board:focus-visible .mg-dg-cursor { display: block; }
.mg-dg-read { margin: 0; display: flex; flex-direction: column; gap: 2px; text-align: center; font-weight: 800; font-size: 17px; line-height: 1.3; color: var(--mg-ink); overflow-wrap: anywhere; }
.mg-dg-read svg { width: 18px; height: 18px; vertical-align: -3px; }
.mg-dg-unit { margin: 0; text-align: center; font-size: 14px; font-weight: 700; color: var(--mg-ink-2); }
.mg-draw.is-ok { --dg-color: var(--mg-green); --dg-fill: rgba(46,158,107,.2); }
.mg-draw.is-ok .mg-dg-read > :first-child { color: var(--mg-green); }
.mg-draw.is-bad { --dg-color: var(--mg-red); --dg-fill: rgba(226,75,74,.16); }
.mg-draw.is-bad .mg-dg-read > :first-child { color: var(--mg-red); }
/* clock: an analogue face the child sets by dragging the hands (or arrow keys on a focused hand) */
.mg-clock { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; --ck-hand: #c2410c; --ck-sec: var(--mg-red); --ck-min: var(--mg-blue); }
.mg-ck-face { width: min(100%, 300px); aspect-ratio: 1; touch-action: none; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.mg-ck-face svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mg-ck-rim { fill: #fff; stroke: var(--mg-ink); stroke-width: 3; }
.mg-ck-tick { stroke: var(--mg-ink-3); stroke-width: 1; stroke-linecap: round; }
.mg-ck-tick.is-major { stroke: var(--mg-ink); stroke-width: 2.4; }
.mg-ck-num { font-family: var(--mg-body); font-weight: 800; font-size: 14px; fill: var(--mg-ink); pointer-events: none; }
.mg-ck-hand { outline: none; cursor: grab; }
.mg-ck-body { stroke: var(--ck-hand); stroke-width: 5; stroke-linecap: round; }
.mg-ck-hour .mg-ck-body { stroke-width: 9; }
.mg-ck-seconds .mg-ck-body { stroke: var(--ck-sec); stroke-width: 3; }
.mg-ck-minute .mg-ck-body { stroke: var(--ck-min); stroke-width: 3.5; }
.mg-ck-tip { fill: var(--ck-hand); stroke: #fff; stroke-width: 1.5; }
.mg-ck-seconds .mg-ck-tip { fill: var(--ck-sec); }
.mg-ck-minute .mg-ck-tip { fill: var(--ck-min); }
.mg-ck-halo { stroke: var(--mg-blue); stroke-width: 20; stroke-linecap: round; opacity: 0; }
.mg-clock.is-keyboard .mg-ck-hand:focus .mg-ck-halo { opacity: .22; }
.mg-ck-hand.is-ghost .mg-ck-body { stroke-dasharray: 5 4; opacity: .6; }
.mg-ck-hand.is-ghost .mg-ck-tip { opacity: .6; }
.mg-ck-cap { fill: var(--mg-ink); stroke: #fff; stroke-width: 1.5; pointer-events: none; }
.mg-clock.is-dragging .mg-ck-hand { cursor: grabbing; }
.mg-ck-read { margin: 0; text-align: center; font-weight: 800; font-size: 17px; line-height: 1.3; color: var(--mg-ink); overflow-wrap: anywhere; }
.mg-ck-say { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.mg-ck-read svg { width: 18px; height: 18px; vertical-align: -3px; }
.mg-clock.is-ok { --ck-hand: var(--mg-green); --ck-sec: var(--mg-green); --ck-min: var(--mg-green); }
.mg-clock.is-ok .mg-ck-read { color: var(--mg-green); }
.mg-clock.is-bad { --ck-hand: var(--mg-red); --ck-sec: var(--mg-red); --ck-min: var(--mg-red); }
.mg-clock.is-bad .mg-ck-read { color: var(--mg-red); }
.mg-clock.is-ok .mg-ck-hand, .mg-clock.is-bad .mg-ck-hand { cursor: default; }
@media (max-width: 360px) { .mg-ck-num { font-size: 15px; } }
/* drag to slots: pieces in a tray go into slots on a board. The ghost is a copy that follows the pointer. */
.mg-dragslots { position: relative; display: flex; flex-direction: column; gap: 14px; width: 100%; }
.mg-ds-board { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-auto-rows: minmax(76px, auto); gap: 8px; width: 100%; max-width: calc(var(--cols) * 104px + (var(--cols) - 1) * 8px); margin: 0 auto; }
.mg .mg-ds-slot { position: relative; min-width: 0; padding: 6px; border-radius: 14px; border: 2px dashed var(--mg-rule-2); background: var(--mg-paper-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font: inherit; color: var(--mg-ink); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: border-color .12s, background .12s; }
.mg .mg-ds-slot:focus-visible { outline: 3px solid var(--mg-blue); outline-offset: 2px; }
.mg .mg-ds-slot.is-target { border-style: solid; border-color: var(--mg-blue); }
.mg .mg-ds-slot.is-over { border-style: solid; border-color: var(--mg-blue); background: var(--mg-blue-bg); }
.mg .mg-ds-slot.is-filled { border-style: solid; background: var(--mg-paper); }
.mg-ds-slotlabel { max-width: 100%; font-family: var(--mg-body); font-weight: 800; font-size: 12px; line-height: 1.15; letter-spacing: .2px; color: var(--mg-ink-2); text-align: center; overflow-wrap: anywhere; }
.mg .mg-ds-piece { display: inline-flex; align-items: center; justify-content: center; max-width: 100%; min-height: 44px; padding: 6px 10px; border-radius: 12px; border: 2px solid var(--mg-blue); background: var(--mg-paper); box-shadow: 0 2px 0 rgba(27,27,47,.12); font-family: var(--mg-body); font-weight: 800; font-size: 16px; line-height: 1.15; text-align: center; color: var(--mg-ink); overflow-wrap: anywhere; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; cursor: grab; }
.mg-ds-pic { display: block; width: 64px; height: 64px; flex: none; }
.mg-ds-pic svg { display: block; width: 100%; height: 100%; }
.mg .mg-ds-piece.has-pic { flex-direction: column; gap: 4px; padding: 6px; }
.mg .mg-ds-slot .mg-ds-pic { width: 56px; height: 56px; }
.mg .mg-ds-slot .mg-ds-piece.has-pic .mg-ds-pic { width: 48px; height: 48px; }
.mg .mg-ds-piece.is-held { outline: 3px solid var(--mg-blue); outline-offset: 2px; background: var(--mg-blue-bg); }
.mg .mg-ds-piece.is-lifted { opacity: .35; border-style: dashed; }
.mg .mg-ds-piece.is-landing { opacity: 0; }
.mg .mg-ds-piece:focus-visible { outline: 3px solid var(--mg-blue); outline-offset: 2px; }
.mg .mg-ds-piece:disabled, .mg .mg-ds-slot:disabled { cursor: default; }
.mg .mg-ds-ghost { position: absolute; left: 0; top: 0; z-index: 30; margin: 0; pointer-events: none; cursor: grabbing; box-shadow: 0 10px 22px rgba(27,27,47,.3); }
.mg-dragslots.is-dragging, .mg-dragslots.is-dragging * { cursor: grabbing; }
.mg-ds-tray { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; min-height: 68px; padding: 10px; border-radius: 14px; border: 2px dashed var(--mg-rule-2); }
.mg-ds-tray.is-over { border-style: solid; border-color: var(--mg-blue); background: var(--mg-blue-bg); }
.mg-ds-trayempty { font-size: 15px; font-weight: 700; color: var(--mg-ink-3); }
.mg-ds-read { margin: 0; text-align: center; font-weight: 800; font-size: 17px; line-height: 1.3; color: var(--mg-ink); overflow-wrap: anywhere; }
.mg-ds-read svg { width: 18px; height: 18px; vertical-align: -3px; }
.mg-ds-live { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mg .mg-ds-slot .mg-mark { right: 6px; top: 6px; transform: none; width: 22px; height: 22px; }
.mg .mg-ds-slot .mg-mark svg { width: 14px; height: 14px; }
.mg-dragslots.is-ok .mg-ds-slot.is-filled { border-color: var(--mg-green); background: var(--mg-green-bg); }
.mg-dragslots.is-ok .mg-ds-read { color: var(--mg-green); }
.mg-dragslots.is-bad .mg-ds-slot { border-color: var(--mg-red); background: var(--mg-red-bg); }
.mg-dragslots.is-bad .mg-ds-read { color: var(--mg-red); }
@media (prefers-reduced-motion: reduce) { .mg .mg-ds-slot, .mg .mg-ds-ghost { transition: none !important; } }
@media (max-width: 520px) { .mg .mg-ds-piece { font-size: 15px; padding: 4px 8px; } .mg-ds-board { grid-auto-rows: minmax(64px, auto); gap: 6px; } }

/* coin builder: a pile to build in, a tray of coins and notes. No running total is ever drawn. */
.mg-coinbuilder { position: relative; display: flex; flex-direction: column; gap: 14px; width: 100%; }
.mg-cn-pile { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 12px 14px; min-height: 108px; padding: 14px 12px; border-radius: 16px; border: 2px dashed var(--mg-rule-2); background: var(--mg-paper-2); }
.mg-cn-pile.is-over { border-style: solid; border-color: var(--mg-blue); background: var(--mg-blue-bg); }
.mg-cn-tray { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; padding: 10px; border-radius: 14px; border: 2px dashed var(--mg-rule-2); }
.mg-cn-tray.is-over { border-style: solid; border-color: var(--mg-blue); background: var(--mg-blue-bg); }
.mg .mg-cn-item { display: flex; align-items: center; justify-content: center; width: var(--w); height: var(--h); min-width: 44px; min-height: 44px; border-radius: 12px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.mg .mg-cn-item:focus-visible, .mg .mg-cn-stack:focus-visible { outline: 3px solid var(--mg-blue); outline-offset: 3px; }
.mg .mg-cn-item[aria-disabled="true"] { cursor: default; }
.mg-cn-svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 2px 0 rgba(27,27,47,.18)); pointer-events: none; }
.mg .mg-cn-stack { position: relative; display: block; margin: 0; padding: 0; border: 0; background: transparent; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; border-radius: 12px; }
.mg .mg-cn-stack:disabled, .mg .mg-cn-stack.is-static { cursor: default; }
.mg-cn-art { position: relative; display: block; width: var(--w); height: calc(var(--h) + (var(--n) - 1) * 8px); }
.mg-cn-layer { position: absolute; left: 0; top: calc(var(--i) * 8px); width: var(--w); height: var(--h); }
.mg-cn-badge { position: absolute; right: -8px; top: -8px; min-width: 26px; padding: 2px 6px; border-radius: 999px; background: var(--mg-ink); color: #fff; font-family: var(--mg-body); font-weight: 800; font-size: 13px; line-height: 18px; text-align: center; pointer-events: none; }
.mg-cn-example { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 10px 14px; padding: 10px 12px; border-radius: 14px; border: 2px solid var(--mg-green); background: var(--mg-green-bg); }
.mg-cn-exlabel { flex: 0 0 100%; text-align: center; font-weight: 800; font-size: 14px; color: var(--mg-green); }
.mg-cn-read { margin: 0; min-height: 1.3em; text-align: center; font-weight: 800; font-size: 17px; line-height: 1.3; color: var(--mg-ink); overflow-wrap: anywhere; }
.mg-cn-read svg { width: 18px; height: 18px; vertical-align: -3px; }
.mg-cn-count { margin: 0; text-align: center; font-weight: 800; font-size: 15px; color: var(--mg-ink-2); }
.mg-cn-read span { display: block; }
.mg .mg-cn-ghost { position: absolute; left: 0; top: 0; z-index: 30; margin: 0; pointer-events: none; cursor: grabbing; }
.mg-coinbuilder.is-dragging, .mg-coinbuilder.is-dragging * { cursor: grabbing; }
.mg-coinbuilder.is-ok .mg-cn-pile { border-style: solid; border-color: var(--mg-green); background: var(--mg-green-bg); }
.mg-coinbuilder.is-ok .mg-cn-read { color: var(--mg-green); }
.mg-coinbuilder.is-bad .mg-cn-pile { border-style: solid; border-color: var(--mg-red); background: var(--mg-red-bg); }
.mg-coinbuilder.is-bad .mg-cn-read { color: var(--mg-red); }
.mg-coinbuilder.is-bad .mg-cn-read span { color: var(--mg-green); }
@media (prefers-reduced-motion: reduce) { .mg .mg-cn-ghost { transition: none !important; } }

/* complete overlay */
.mg-complete { position: absolute; inset: 0; background: rgba(255,255,255,.97); display: none; align-items: center; justify-content: center; flex-direction: column; gap: 14px; text-align: center; padding: 24px; color: var(--mg-ink); z-index: 5; }
.mg-complete.is-show { display: flex; animation: mgFadeIn .5s; }
@keyframes mgFadeIn { from { opacity: 0; } }
.mg-complete .mg-subject-done { width: 170px; height: 170px; border: 0; background: transparent; }
.mg-complete .mg-subject-done svg { width: 76%; height: auto; animation: mgBounce 1.2s ease-in-out infinite; }
/* Fill the box (a % height on a grid item has no definite row to resolve against, so pin it). */
.mg-complete .mg-subject-done > img { position: absolute; inset: 6%; width: 88%; height: 88%; object-fit: contain; animation: mgBounce 1.2s ease-in-out infinite; }
.mg-complete .mg-subject-done .mg-potion { animation: mgBounce 1.2s ease-in-out infinite; }
.mg-complete .mg-subject-done .mg-glow { background: var(--mg-gold); opacity: .6; }
.mg-complete h2 { font-family: var(--mg-display); font-size: 42px; margin: 0; font-weight: 400; color: var(--mg-ink); }
.mg-complete p { margin: 0; color: var(--mg-ink-2); max-width: 46ch; font-weight: 600; }
.mg-stats { display: flex; gap: 12px; margin-top: 6px; }
.mg-stat { background: var(--mg-paper-2); border: 1.5px solid var(--mg-rule); border-radius: 14px; padding: 12px 18px; min-width: 130px; font-family: var(--mg-display); font-size: 26px; color: var(--mg-ink); }
.mg-stat b { font-weight: 400; }
.mg-stat span { color: var(--mg-ink-3); font-family: var(--mg-body); font-size: 12px; font-weight: 700; display: block; }
.mg-stat.is-good { background: var(--mg-green-bg); border-color: #bfe6d0; }
.mg .mg-done-btn { min-width: 280px; }

/* input rail */
.mg-input { border-left: 1.5px solid var(--mg-rule); background: var(--mg-paper-2); display: flex; flex-direction: column; min-height: 0; min-width: 0; padding: 30px 20px 20px; gap: 14px; overflow-y: auto; overscroll-behavior: contain; }
.mg .mg-hintbtn { flex: none; height: 52px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 12px; border: 2px solid var(--mg-wgold); background: var(--mg-amber-bg); color: #7a5210; font-weight: 800; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.mg .mg-hintbtn:hover:not(:disabled) { background: #ffebb8; }
.mg .mg-hintbtn:disabled { opacity: .45; }
.mg-hintbtn svg { width: 20px; height: 20px; }
.mg .mg-hintbtn.is-final { border-color: var(--mg-blue); background: var(--mg-blue-bg); color: var(--mg-blue); }
.mg-ladder { display: flex; gap: 8px; justify-content: center; margin-top: -4px; }
.mg-ladder i { width: 7px; height: 7px; border-radius: 50%; background: var(--mg-rule-2); }
.mg-ladder i.is-used { background: var(--mg-wgold); }
.mg-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; transition: opacity .2s; }
.mg-keys.is-idle { opacity: .38; }
.mg .mg-key { height: clamp(48px, 7vh, 74px); border-radius: 14px; background: var(--mg-paper); border: 2px solid var(--mg-rule-2); border-bottom-width: 4px; font-family: var(--mg-display); font-size: 30px; color: var(--mg-ink); transition: transform .05s, border-color .1s; }
.mg .mg-key:hover:not(:disabled) { border-color: #b9b7ae; background: var(--mg-paper-2); }
.mg .mg-key:active:not(:disabled), .mg .mg-key.is-pressed { transform: translateY(2px); border-bottom-width: 2px; border-color: var(--mg-blue); }
.mg .mg-key.is-fn { font-size: 20px; color: var(--mg-blue); }
.mg-key svg { width: 24px; height: 24px; vertical-align: middle; }
.mg-keynote { font-size: 12px; color: var(--mg-ink-3); margin: -4px 0 0; text-align: center; font-weight: 600; min-height: 18px; }
.mg-spacer { flex: 1; min-height: 0; }
/* The explanation absorbs any overflow and scrolls inside itself, so the Continue row stays in view. */
.mg-actions { display: flex; flex-direction: column; gap: 10px; flex: 0 1 auto; min-height: 0; }
.mg .mg-cta { height: 60px; border-radius: 14px; font-family: var(--mg-display); font-size: 22px; letter-spacing: .5px; transition: transform .08s; border-bottom: 4px solid transparent; }
.mg .mg-cta-gold { background: var(--mg-gold); border-bottom-color: var(--mg-gold-deep); color: #3a2400; }
.mg .mg-cta-blue { background: #2468dc; border-bottom-color: #1a4fa8; color: #fff; }
.mg .mg-cta-ghost { height: 48px; font-size: 17px; border: 2px solid var(--mg-rule-2); color: var(--mg-ink-2); background: var(--mg-paper); }
.mg .mg-cta:active:not(:disabled) { transform: translateY(3px); border-bottom-width: 1px; }
.mg .mg-cta:disabled { background: var(--mg-rule); border-bottom-color: var(--mg-rule-2); color: var(--mg-ink-3); transform: none; }
.mg-sheet { border-radius: 14px; padding: 14px; display: none; flex-direction: column; gap: 10px; min-height: 0; animation: mgUp .3s cubic-bezier(.2,.8,.2,1); }
.mg-sheet.is-show { display: flex; }
@keyframes mgUp { from { opacity: 0; transform: translateY(16px); } }
.mg-sheet.is-good { background: var(--mg-green-bg); border: 2px solid var(--mg-green); }
.mg-sheet.is-soft { background: var(--mg-amber-bg); border: 2px solid var(--mg-wgold); }
.mg-sheet.is-reveal { background: var(--mg-blue-bg); border: 2px solid var(--mg-blue); }
.mg-sheet h3 { margin: 0; font-family: var(--mg-display); font-size: 22px; font-weight: 400; display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.mg-sheet h3 svg { width: 22px; height: 22px; flex: none; }
.mg-sheet.is-good h3 { color: #1f7a50; }
.mg-sheet.is-soft h3 { color: #7a5210; }
.mg-sheet.is-reveal h3 { color: var(--mg-blue); }
.mg-sheet p { margin: 0; font-size: 14px; color: var(--mg-ink-2); font-weight: 600; }
.mg .mg-why { font-size: 13px; color: var(--mg-blue); font-weight: 800; text-align: left; text-decoration: underline; text-underline-offset: 3px; align-self: flex-start; }
.mg-exp { display: none; font-size: 14px; color: var(--mg-ink); background: var(--mg-paper); border: 1px solid var(--mg-rule); border-radius: 10px; padding: 10px 12px; font-weight: 600; }
.mg-exp.is-show { display: block; flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.mg-sheet-row { display: flex; gap: 8px; flex: none; }
.mg-sheet-row .mg-cta { flex: 1; height: 52px; font-size: 19px; }

@media (prefers-reduced-motion: reduce) {
  .mg *, .mg *::before, .mg *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 1000px) {
  .mg { --u: 1px; grid-template-columns: 1fr; grid-template-rows: auto 1fr; gap: 26px; overflow: auto; }
  .mg-frame { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .mg-subject:not(.mg-subject-done) { width: 96px; height: 96px; }
  .mg-name { flex: 1; flex-direction: column; align-items: flex-start; }
  .mg-mission, .mg-chat { width: 100%; }
  .mg-chat { min-height: 120px; max-height: 160px; }
  .mg-canvas { min-height: 56vh; }
  .mg-sheet-frame { grid-template-columns: 1fr; }
  .mg-input { border-left: 0; border-top: 1.5px solid var(--mg-rule); }
  .mg-keys { grid-template-columns: repeat(6, 1fr); }
  .mg-spacer { display: none; }
  .mg-choices, .mg-match { grid-template-columns: 1fr; }
}

/* plot a point: a coordinate grid with one point; its coordinates are never shown as text while it is placed */
.mg-pp { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.mg-pp-board { width: 100%; display: flex; justify-content: center; padding: 6px 0; border-radius: 14px; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.mg-pp-board:focus-visible { outline: 3px solid var(--mg-blue); outline-offset: 2px; }
.mg-pp-board[aria-disabled="true"] { cursor: default; }
.mg-pp-svg { display: block; width: 100%; height: auto; overflow: visible; }
.mg-pp-lines { fill: none; stroke: var(--mg-ink-3); stroke-width: 1px; stroke-opacity: .5; vector-effect: non-scaling-stroke; }
.mg-pp-axes { fill: none; stroke: var(--mg-ink); stroke-width: 3px; stroke-linecap: square; vector-effect: non-scaling-stroke; }
.mg-pp-dots { fill: none; stroke: var(--mg-ink-3); stroke-width: 4px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.mg-pp-num { font-size: .5px; font-weight: 800; fill: var(--mg-ink-2); }
.mg-pp-pt circle { fill: var(--mg-blue); stroke: #fff; stroke-width: 3px; vector-effect: non-scaling-stroke; }
.mg-pp-pt path { fill: none; stroke: #fff; stroke-width: 3px; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; display: none; }
.mg-pp-pt.is-key circle { fill: none; stroke: var(--mg-green); stroke-width: 3px; stroke-dasharray: 5 4; }
.mg-pp.is-ok .mg-pp-pt.is-mine circle { fill: var(--mg-green); }
.mg-pp.is-ok .mg-pp-pt.is-mine .mg-pp-yes { display: block; }
.mg-pp.is-bad .mg-pp-pt.is-mine circle { fill: var(--mg-red); }
.mg-pp.is-bad .mg-pp-pt.is-mine .mg-pp-no { display: block; }
.mg-pp-cursor { display: none; fill: none; stroke: var(--mg-ink); stroke-width: 3px; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.mg-pp.is-keys .mg-pp-board:focus-visible .mg-pp-cursor { display: block; }
.mg-pp-read { margin: 0; min-height: 1.3em; display: flex; flex-direction: column; gap: 2px; text-align: center; font-weight: 800; font-size: 17px; line-height: 1.3; color: var(--mg-ink); overflow-wrap: anywhere; }
.mg-pp-read svg { width: 18px; height: 18px; vertical-align: -3px; }
.mg-pp.is-ok .mg-pp-read > :first-child { color: var(--mg-green); }
.mg-pp.is-bad .mg-pp-read > :first-child { color: var(--mg-red); }
@media (prefers-reduced-motion: reduce) { .mg-pp-pt { transition: none; } }

/* fraction boxes: a whole box (optional) and a numerator over a denominator. Boxes are at least 56 px tall with 32 px digits. */
.mg-fracbox { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; padding: 14px 0 6px; }
.mg-fb-row { display: flex; align-items: center; justify-content: center; gap: 18px; }
.mg-fb-frac { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.mg-fb-bar { display: block; width: 100%; min-width: 96px; height: 4px; border-radius: 2px; background: var(--mg-ink); }
.mg-fb-input { box-sizing: border-box; width: 96px; height: 60px; padding: 0 8px; border: 2.5px solid var(--mg-rule-2); border-radius: 14px; background: var(--mg-paper); color: var(--mg-ink); font: 800 32px/1 var(--mg-body); text-align: center; caret-color: var(--mg-blue); -webkit-appearance: none; appearance: none; }
.mg-fb-input:focus { outline: none; border-color: var(--mg-blue); box-shadow: 0 0 0 4px var(--mg-blue-bg); }
.mg-fb-input[data-fb="whole"] { height: 76px; }
.mg-fracbox.is-ok .mg-fb-input { border-color: var(--mg-green); background: var(--mg-green-bg); }
.mg-fracbox.is-bad .mg-fb-input { border-color: var(--mg-red); background: var(--mg-red-bg); }
.mg-fb-mark { display: grid; place-items: center; width: 34px; height: 34px; }
.mg-fb-mark svg { width: 28px; height: 28px; }
.mg-fracbox.is-ok .mg-fb-mark { color: var(--mg-green); }
.mg-fracbox.is-bad .mg-fb-mark { color: var(--mg-red); }
/* a fraction in the question stem, stacked like the answer boxes */
.mg-frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 .12em; line-height: 1.05; font-size: .86em; }
.mg-frac-n { padding: 0 .28em .08em; border-bottom: .09em solid currentColor; }
.mg-frac-d { padding: .08em .28em 0; }
.mg-fb-hint { margin: 0; color: var(--mg-ink-2); font-size: 15px; font-weight: 600; text-align: center; }
@media (max-width: 420px) { .mg-fb-input { width: 80px; } .mg-fb-row { gap: 12px; } }

/* graph builder: columns over a value axis. Text keeps its real size; a column is at least 44 px wide and the chart scrolls inside its own box. */
.mg-gb { --gb-h: clamp(200px, calc(100cqh - 560px), 220px); display: flex; flex-direction: column; gap: 6px; width: 100%; }
.mg-gb .s0 { --gb-c: var(--mg-blue); --gb-bg: #cfe0fd; }
.mg-gb .s1 { --gb-c: #c97a06; --gb-bg: repeating-linear-gradient(45deg, #fbd88a 0 4px, #fff0c9 4px 8px); }
.mg-gb .s2 { --gb-c: #7a4fd1; --gb-bg: radial-gradient(circle at 3px 3px, #b9a2ec 1.4px, #e8defb 1.5px) 0 0 / 7px 7px; }
.mg-gb-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 16px; }
.mg-gb-title { margin: 0; font-weight: 800; font-size: 14px; color: var(--mg-ink-2); }
.mg-gb-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-weight: 800; font-size: 14px; color: var(--mg-ink); }
.mg-gb-legend li { display: inline-flex; align-items: center; gap: 6px; }
.mg-gb-sw { width: 16px; height: 16px; border-radius: 4px; border: 3px solid var(--gb-c); background: var(--gb-bg); box-sizing: border-box; }
.mg-gb-line-kind .mg-gb-sw, .mg-gb-line .mg-gb-sw { border-radius: 50%; }
.mg-gb-scroll { overflow-x: auto; overflow-y: hidden; width: 100%; -webkit-overflow-scrolling: touch; }
.mg-gb-chart { display: grid; align-items: start; grid-template-columns: 40px minmax(0, 1fr); min-width: calc(43px + var(--gb-n) * var(--gb-s) * 44px); }
.mg-gb-yaxis { display: block; overflow: visible; height: var(--gb-h); margin-top: 10px; }
.mg-gb-tick { font-size: 12px; font-weight: 800; fill: var(--mg-ink-2); font-family: var(--mg-body); }
.mg-gb-main { min-width: 0; }
.mg-gb-plot { position: relative; margin-top: 10px; border-left: 3px solid var(--mg-ink); border-bottom: 3px solid var(--mg-ink); touch-action: pan-x; user-select: none; -webkit-user-select: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.mg-gb.is-dragging .mg-gb-plot { cursor: grabbing; }
.mg-gb-gl { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--mg-rule); pointer-events: none; }
.mg-gb-gl.is-major { border-top-color: var(--mg-rule-2); }
.mg-gb-cols { position: relative; display: grid; grid-template-columns: repeat(var(--gb-n), minmax(0, 1fr)); height: var(--gb-h); }
.mg-gb-cat { position: relative; display: flex; min-width: 0; }
.mg-gb-col { position: relative; flex: 1 1 0; min-width: 0; height: 100%; outline: none; }
.mg-gb.is-keys .mg-gb-col:focus-visible { outline: 3px solid var(--mg-blue); outline-offset: -3px; border-radius: 6px; }
.mg-gb-line .mg-gb-col { position: absolute; inset: 0; pointer-events: none; }
.mg-gb-fill, .mg-gb-key, .mg-gb-handle { position: absolute; pointer-events: none; }
.mg-gb-handle { display: none; }
.mg-gb-col:not(.is-set)::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: 3px; border-top: 3px dotted var(--mg-ink-3); pointer-events: none; }
.mg-gb-line .mg-gb-col::after { display: none; }
/* A pictograph column with nothing yet shows one faint icon at its foot (the icon the child will stack), not just a dotted line. */
.mg-gb-pictograph .mg-gb-col:not(.is-set)::after { left: 50%; right: auto; width: 30px; height: 30px; margin-left: -15px; bottom: 2px; border-top: 0; background: var(--gb-c); opacity: .22; border-radius: 50%; box-sizing: border-box; }
.mg-gb-pictograph[data-icon="star"] .mg-gb-col:not(.is-set)::after { border-radius: 0; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.mg-gb-pictograph[data-icon="square"] .mg-gb-col:not(.is-set)::after { border-radius: 4px; }
/* bars */
.mg-gb-bar .mg-gb-fill { left: 12%; right: 12%; bottom: 0; height: 0; background: var(--gb-bg); border: 3px solid var(--gb-c); border-bottom: 0; border-radius: 6px 6px 0 0; box-sizing: border-box; }
.mg-gb-bar .mg-gb-handle { left: 12%; right: 12%; height: 8px; background: var(--gb-c); border-radius: 4px; transform: translateY(50%); }
.mg-gb-bar .mg-gb-col.is-set .mg-gb-handle { display: block; }
.mg-gb-bar .mg-gb-key { left: 6%; right: 6%; bottom: 0; background: transparent; border: 3px dashed var(--mg-green); border-bottom: 0; border-radius: 6px 6px 0 0; box-sizing: border-box; }
.mg-gb-bar .mg-gb-key:not([style*="height"]) { display: none; }
/* stacked dots and icons */
.mg-gb-dot-plot .mg-gb-fill, .mg-gb-pictograph .mg-gb-fill { left: 0; right: 0; bottom: 0; height: 100%; display: flex; flex-direction: column-reverse; align-items: stretch; }
.mg-gb-dot-plot .mg-gb-key, .mg-gb-pictograph .mg-gb-key { left: 0; right: 0; bottom: 0; height: 100%; display: flex; flex-direction: column-reverse; }
.mg-gb-mark { flex: 0 0 var(--gb-unit); display: flex; align-items: center; justify-content: center; }
.mg-gb-mark::before { content: ""; display: block; height: min(80%, 28px); aspect-ratio: 1; background: var(--gb-c); border-radius: 50%; }
.mg-gb-mark.square::before { border-radius: 4px; }
.mg-gb-mark.star::before { border-radius: 0; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); height: min(92%, 32px); }
.mg-gb-mark.is-key::before { background: transparent; border: 2px dashed var(--mg-green); border-radius: 50%; clip-path: none; height: min(90%, 32px); box-sizing: border-box; }
.mg-gb-dot-plot .mg-gb-handle, .mg-gb-pictograph .mg-gb-handle { left: 50%; width: 34px; height: 34px; margin-left: -17px; border: 3px solid var(--gb-c); border-radius: 50%; opacity: .7; transform: translateY(50%); }
.mg-gb-dot-plot .mg-gb-col.is-dragging .mg-gb-handle, .mg-gb-pictograph .mg-gb-col.is-dragging .mg-gb-handle { display: block; }
/* line graph */
.mg-gb-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.mg-gb-pl.s0, .mg-gb-pl.s1, .mg-gb-pl.s2 { fill: none; stroke: var(--gb-c); stroke-width: 3px; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
polyline.mg-gb-pl.is-key { stroke: var(--mg-green); stroke-dasharray: 6 5; }
.mg-gb-line .mg-gb-handle { left: 50%; width: 16px; height: 16px; margin-left: -8px; background: var(--gb-c); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--gb-c); border-radius: 50%; transform: translateY(50%); }
.mg-gb-line .mg-gb-col.s1 .mg-gb-handle { border-radius: 3px; }
.mg-gb-line .mg-gb-col.s2 .mg-gb-handle { border-radius: 3px; transform: translateY(50%) rotate(45deg); }
.mg-gb-line .mg-gb-col.is-set .mg-gb-handle { display: block; }
.mg-gb-line .mg-gb-key { left: 50%; width: 24px; height: 24px; margin-left: -12px; border: 3px dashed var(--mg-green); border-radius: 50%; transform: translateY(50%); box-sizing: border-box; }
.mg-gb-line .mg-gb-key:not([style*="bottom"]) { display: none; }
/* labels, state, readout */
.mg-gb-xlabels { display: grid; grid-template-columns: repeat(var(--gb-n), minmax(0, 1fr)); padding-left: 3px; }
.mg-gb-xl { min-width: 0; padding: 6px 2px 0; text-align: center; font-weight: 800; font-size: 13px; line-height: 1.2; color: var(--mg-ink); overflow-wrap: anywhere; hyphens: auto; }
.mg-gb.is-dense .mg-gb-xl { font-size: 11px; padding: 6px 1px 0; }
.mg-gb.is-ok .mg-gb-fill { background: var(--mg-green-bg); border-color: var(--mg-green); }
.mg-gb.is-bad .mg-gb-fill { background: var(--mg-red-bg); border-color: var(--mg-red); }
.mg-gb.is-ok .mg-gb-mark:not(.is-key)::before { background: var(--mg-green); }
.mg-gb.is-bad .mg-gb-mark:not(.is-key)::before { background: var(--mg-red); }
.mg-gb-read { margin: 0; min-height: 1.3em; display: flex; flex-direction: column; gap: 2px; text-align: center; font-weight: 800; font-size: 17px; line-height: 1.3; color: var(--mg-ink); }
.mg-gb-read svg { width: 18px; height: 18px; vertical-align: -3px; }
.mg-gb.is-ok .mg-gb-read { color: var(--mg-green); }
.mg-gb.is-bad .mg-gb-read { color: var(--mg-red); }
.mg-gb.is-bad .mg-gb-read span + span { color: var(--mg-green); }
@media (prefers-reduced-motion: reduce) { .mg-gb * { transition: none !important; } }
.mg-q.is-graph .mg-model { padding: 6px 10px; }
.mg-q.is-graph .mg-table { font-size: 13px; min-width: 0; }
.mg-q.is-graph .mg-table th, .mg-q.is-graph .mg-table td { padding: 1px 10px; border-width: 1px; }
.mg-q.is-graph .mg-model { overflow-x: auto; }
.mg-q.is-graph { flex-direction: row; flex-wrap: wrap; align-items: flex-start; align-content: flex-start; gap: 8px 16px; }
.mg-q.is-graph .mg-prompt { flex: 1 0 100%; }
.mg-q.is-graph .mg-model { flex: 0 1 auto; max-width: 100%; }
.mg-q.is-graph .mg-answer { flex: 1 1 var(--gb-want, 440px); min-width: 0; }

.mg-q.is-graph .mg-table.is-flip { font-size: 12px; }
.mg-q.is-graph .mg-table.is-flip th, .mg-q.is-graph .mg-table.is-flip td { padding: 1px 4px; white-space: nowrap; }
.mg-q.is-graph .mg-table.is-flip tr:first-child th { background: var(--mg-blue-bg); }
.mg-q.is-graph .mg-table.is-flip th:first-child { text-align: left; }
/* the legend of a line graph picks the line being drawn: a radio group, each entry a 44 px hit area */
.mg-gb-legend.is-picker { gap: 4px 6px; }
.mg-gb-pick { min-height: 44px; padding: 0 12px; border: 2px solid transparent; border-radius: 12px; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.mg-gb-pick.is-active { font-weight: 900; border-color: var(--mg-ink); background: var(--mg-paper-2); }
.mg-gb-pick:focus-visible { outline: 3px solid var(--mg-blue); outline-offset: 1px; }
.mg-gb:not(.is-keys) .mg-gb-pick:focus-visible { outline: none; }
.mg-gb-line .mg-gb-col.is-active .mg-gb-handle { box-shadow: 0 0 0 2px var(--gb-c), 0 0 0 5px color-mix(in srgb, var(--gb-c) 35%, transparent); }

/* number grid: given cells locked, blank cells typed. The grid frame colours as a whole after grading; cells are never marked one by one. */
.mg-numgrid { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; padding: 14px 0 6px; }
.mg-ng-frame { display: grid; gap: 6px; padding: 8px; border: 3px solid var(--mg-rule-2); border-radius: 16px; background: var(--mg-paper-2); }
.mg-ng-row { display: grid; grid-template-columns: repeat(var(--ng-cols), var(--ng-size)); gap: 6px; }
.mg-ng-cell { box-sizing: border-box; width: var(--ng-size); height: var(--ng-size); display: grid; place-items: center; border: 2.5px solid var(--mg-rule-2); border-radius: 12px; background: var(--mg-paper); color: var(--mg-ink); font-family: var(--mg-display); font-size: 30px; line-height: 1; user-select: none; -webkit-user-select: none; cursor: pointer; }
.mg-ng-cell.is-given { background: var(--mg-paper-3); border-color: var(--mg-rule); color: var(--mg-ink-2); cursor: default; }
.mg-ng-cell:not(.is-given):focus { outline: none; border-color: var(--mg-blue); box-shadow: 0 0 0 4px var(--mg-blue-bg); }
.mg-numgrid.is-ok .mg-ng-frame { border-color: var(--mg-green); background: var(--mg-green-bg); }
.mg-numgrid.is-bad .mg-ng-frame { border-color: var(--mg-red); background: var(--mg-red-bg); }
.mg-ng-pair { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; }
.mg-ng-fig { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mg-ng-fig figcaption { font-weight: 800; font-size: 15px; color: var(--mg-ink-2); }
.mg-ng-frame.is-example { border-style: dashed; border-color: var(--mg-green); }
.mg-ng-hint { margin: 0; min-height: 1.3em; color: var(--mg-ink-2); font-size: 15px; font-weight: 600; text-align: center; }
.mg-ng-read { margin: 0; min-height: 1.3em; display: flex; justify-content: center; align-items: center; gap: 6px; font-weight: 800; font-size: 17px; }
.mg-ng-read svg { width: 18px; height: 18px; vertical-align: -3px; }
.mg-numgrid.is-ok .mg-ng-read { color: var(--mg-green); }
.mg-numgrid.is-bad .mg-ng-read, .mg-numgrid.is-revealed .mg-ng-read { color: var(--mg-red); }

/* piece board: shape pieces in a tray are placed on a lattice board to cover a region */
.mg-pb { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.mg-pb-board { display: block; width: min(100%, calc(var(--cols) * 44px)); aspect-ratio: var(--cols) / var(--rows); max-height: clamp(180px, calc(100cqh - 460px), 420px); touch-action: none; border-radius: 12px; background: var(--mg-paper-2); border: 1.5px solid var(--mg-rule-2); box-sizing: border-box; user-select: none; -webkit-user-select: none; }
.mg-pb-board:focus { outline: none; }
.mg-pb.is-keyboard .mg-pb-board:focus-visible { outline: 3px solid var(--mg-blue); outline-offset: 2px; }
.mg-pb-grid { fill: none; stroke: var(--mg-rule-2); stroke-width: .03; }
.mg-pb-target { fill: #e1eafb; stroke: #9fb5df; stroke-width: .05; }
.mg-pb-cell { stroke: #1b1b2f; stroke-width: .06; }
.mg-pb-letter { font: 800 .55px var(--mg-body); fill: #1b1b2f; pointer-events: none; }
.mg-pb-placed { cursor: grab; outline: none; }
.mg-pb-placed.is-lifted, .mg-pb-piece.is-lifted { opacity: .35; }
/* The turn badge: a small circular arrow that says a piece turns. A picture, not a control: the whole piece is the target. */
.mg-pb-turn { pointer-events: none; opacity: .55; }
.mg-pb-turn circle, .mg-pb-turn-tray circle { fill: #fff; fill-opacity: .92; stroke: #1b1b2f; stroke-opacity: .35; stroke-width: .08; }
.mg-pb-turn path, .mg-pb-turn-tray path { fill: none; stroke: #1b1b2f; stroke-width: .14; stroke-linecap: round; stroke-linejoin: round; }
.mg-pb-turn .mg-pb-head, .mg-pb-turn-tray .mg-pb-head { fill: #1b1b2f; stroke: none; }
.mg-pb-placed:hover .mg-pb-turn, .mg-pb-placed:focus-visible .mg-pb-turn { opacity: 1; }
.mg-pb-turn-tray { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; opacity: .6; pointer-events: none; }
.mg-pb-piece:hover .mg-pb-turn-tray, .mg-pb-piece:focus-visible .mg-pb-turn-tray { opacity: 1; }
/* A turn with no room: a short sideways shake (a brief outline flash when motion is reduced). It says nothing about the answer. */
.mg-pb-placed.is-shake { animation: mgPbShake .15s ease-in-out; }
@keyframes mgPbShake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-.07px); } 75% { transform: translateX(.07px); } }
.mg-pb-placed.is-flash .mg-pb-cell { stroke: var(--mg-blue); stroke-width: .16; }
/* A tap on a tray piece turns it in place over 120 ms; the slot grows to fit the turned shape. */
.mg-pb-piece.is-turned .mg-pb-art { animation: mgPbSpin .12s ease-out; }
@keyframes mgPbSpin { from { transform: rotate(-90deg); } to { transform: rotate(0); } }
@media (prefers-reduced-motion: reduce) { .mg-pb-placed.is-shake, .mg-pb-piece.is-turned .mg-pb-art { animation: none; } }
.mg-pb.is-keyboard .mg-pb-placed:focus-visible { outline: none; }
.mg-pb.is-keyboard .mg-pb-placed:focus-visible .mg-pb-cell { stroke: var(--mg-blue); stroke-width: .16; }
.mg-pb-hover rect { fill: none; stroke: var(--mg-blue); stroke-width: .1; stroke-dasharray: .2 .12; }
.mg-pb-example rect { fill: none; stroke: var(--mg-green); stroke-width: .11; stroke-dasharray: .22 .14; }
.mg-pb-tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; width: 100%; }
.mg-pb-piece { position: relative; min-width: 44px; min-height: 44px; padding: 10px; border: 1.5px solid var(--mg-rule-2); border-radius: 12px; background: #fff; touch-action: none; cursor: grab; display: inline-flex; align-items: center; justify-content: center; user-select: none; -webkit-user-select: none; }
.mg-pb-piece.is-held { border-color: var(--mg-blue); box-shadow: 0 0 0 3px rgba(46, 124, 246, .25); }
.mg-pb-piece.is-spent { opacity: .45; cursor: default; }
.mg-pb.is-keyboard .mg-pb-piece:focus-visible { outline: 3px solid var(--mg-blue); outline-offset: 2px; }
.mg-pb-piece:focus { outline: none; }
.mg-pb-art { display: block; }
.mg-pb-badge { position: absolute; top: -13px; right: -15px; min-width: 22px; height: 22px; padding: 0 5px; box-sizing: border-box; border-radius: 11px; background: var(--mg-ink); color: #fff; font: 800 12px/22px var(--mg-body); text-align: center; }
.mg-pb-ghost { position: absolute; left: 0; top: 0; z-index: 30; pointer-events: none; opacity: .92; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .3)); will-change: transform; }
.mg-pb.is-dragging, .mg-pb.is-dragging * { cursor: grabbing; }
.mg-pb-read { margin: 0; min-height: 1.3em; display: flex; flex-direction: column; gap: 2px; text-align: center; font-weight: 800; font-size: 17px; line-height: 1.3; color: var(--mg-ink-2); }
.mg-pb-read svg { width: 18px; height: 18px; vertical-align: -3px; }
.mg-pb.is-ok .mg-pb-read { color: var(--mg-green); }
.mg-pb.is-bad .mg-pb-read { color: var(--mg-red); }
.mg-pb.is-bad .mg-pb-read span + span { color: var(--mg-green); }
@media (prefers-reduced-motion: reduce) { .mg-pb-ghost { transition: none; } }

/* construction: a drawing canvas in centimetres with a pencil, a ruler, a protractor and a compass */
.mg-cs { --cs-h: clamp(200px, calc(100cqh - 440px), 340px); display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.mg-cs-canvas { position: relative; width: min(100%, calc(var(--cs-h) * var(--cs-ratio))); aspect-ratio: var(--cs-ratio); background: #fff; border: 2px solid var(--mg-rule-2); border-radius: 12px; overflow: hidden; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.mg-cs-canvas[aria-disabled="true"] { cursor: default; }
.mg-cs.is-keys .mg-cs-canvas:focus-visible { outline: 3px solid var(--mg-blue); outline-offset: 2px; }
.mg-cs-svg { display: block; width: 100%; height: 100%; }
.mg-cs-svg line, .mg-cs-svg path, .mg-cs-svg circle { vector-effect: non-scaling-stroke; }
.mg-cs-svg.is-example { height: auto; max-height: 210px; border: 2px dashed var(--mg-rule-2); border-radius: 10px; background: #fff; }
.mg-cs-dots { stroke: #c9c7bd; stroke-width: 3px; stroke-linecap: round; fill: none; }
.mg-cs-given { stroke: #6e6e86; stroke-width: 2.4px; stroke-linecap: round; fill: none; }
.mg-cs-gpt { fill: var(--mg-ink); }
.mg-cs-glabel { fill: var(--mg-ink); font-weight: 800; font-size: calc(var(--cs-fs, .4px) * 1.2); }
.mg-cs-obj line, .mg-cs-obj .mg-cs-round { stroke: var(--mg-ink); stroke-width: 2.4px; stroke-linecap: round; fill: none; }
.mg-cs-obj.is-sel line, .mg-cs-obj.is-sel .mg-cs-round { stroke: var(--mg-blue); stroke-width: 3.8px; }
.mg-cs-obj { transition: opacity .12s; }
.mg-cs-obj.is-leaving { opacity: 0; }
.mg-cs-handles { pointer-events: none; }
.mg-cs-handle { fill: #fff; stroke: var(--mg-blue); stroke-width: 2.6px; }
.mg-cs-del circle { fill: #fff; stroke: var(--mg-red); stroke-width: 2px; }
.mg-cs-del path { stroke: var(--mg-red); stroke-width: 2.4px; stroke-linecap: round; fill: none; }
@media (prefers-reduced-motion: reduce) { .mg-cs-obj { transition: none; } }
.mg-cs-obj.is-key line, .mg-cs-obj.is-key .mg-cs-round { stroke: var(--mg-green); stroke-dasharray: 7 5; }
.mg-cs-end { fill: #fff; stroke: var(--mg-ink); stroke-width: 1.4px; }
.mg-cs-obj.is-key .mg-cs-end { stroke: var(--mg-green); }
.mg-cs-pre { stroke: var(--mg-blue); stroke-width: 2.4px; stroke-linecap: round; fill: none; }
.mg-cs.is-ok .mg-cs-canvas { border-color: var(--mg-green); }
.mg-cs.is-bad .mg-cs-canvas { border-color: var(--mg-red); }
.mg-cs-inst { pointer-events: none; opacity: .62; }
.mg-cs-inst.is-active { opacity: .94; }
.mg-cs-body { fill: rgba(255, 214, 102, .5); stroke: #a6781b; stroke-width: 1.6px; }
.mg-cs-inst[data-cs-tool="protractor"] .mg-cs-body { fill: rgba(130, 190, 255, .38); stroke: #2f6fb7; }
.mg-cs-ticks { fill: none; stroke: var(--mg-ink); stroke-width: 1px; }
.mg-cs-edge { fill: none; stroke: var(--mg-ink); stroke-width: 1.6px; }
.mg-cs-num { fill: var(--mg-ink); font-weight: 700; font-size: var(--cs-fs, .4px); }
.mg-cs-num.is-inner { fill: #5a4fa3; }
.mg-cs-leg { fill: none; stroke: #4a4a66; stroke-width: 3.4px; stroke-linecap: round; }
.mg-cs-hinge { fill: #e0a21a; stroke: var(--mg-ink); stroke-width: 1.6px; }
.mg-cs-needle { fill: var(--mg-ink); }
.mg-cs-tip { fill: var(--mg-blue); stroke: #fff; stroke-width: 1.4px; }
.mg-cs-cursor { fill: none; stroke: var(--mg-blue); stroke-width: 2px; }
.mg-cs-tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.mg-cs-bar { display: flex; gap: 8px 16px; flex-wrap: wrap; justify-content: center; align-items: center; }
.mg .mg-cs-undo { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; min-height: 44px; padding: 0 14px; border-radius: 12px; border: 2px solid var(--mg-rule-2); background: #fff; color: var(--mg-ink); font: 800 15px/1 var(--mg-body); cursor: pointer; }
.mg .mg-cs-undo:disabled { cursor: default; opacity: .45; background: transparent; border-style: dashed; }
.mg .mg-cs.is-keys .mg-cs-undo:focus-visible { outline: 3px solid var(--mg-blue); outline-offset: 2px; }
.mg .mg-cs-pick { min-width: 44px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 2px solid var(--mg-rule-2); background: #fff; color: var(--mg-ink); font: 800 15px/1 var(--mg-body); cursor: pointer; }
.mg .mg-cs-pick[aria-checked="true"] { background: var(--mg-blue-bg); border-color: var(--mg-blue); color: var(--mg-blue); }
.mg .mg-cs-pick:disabled { cursor: default; opacity: .7; }
.mg .mg-cs.is-keys .mg-cs-pick:focus-visible { outline: 3px solid var(--mg-blue); outline-offset: 2px; }
.mg-cs-read { margin: 0; min-height: 1.3em; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; font-weight: 800; font-size: 17px; line-height: 1.3; color: var(--mg-ink-2); }
.mg-cs-read svg { width: 18px; height: 18px; vertical-align: -3px; }
.mg-cs.is-ok .mg-cs-read { color: var(--mg-green); }
.mg-cs.is-bad .mg-cs-read { color: var(--mg-red); }
.mg-cs.is-bad .mg-cs-read span + span { color: var(--mg-green); }
.mg-cs-example { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mg-cs-example[hidden] { display: none; }
.mg-cs-excap { margin: 0; font-weight: 800; font-size: 15px; color: var(--mg-green); }
@media (prefers-reduced-motion: reduce) { .mg-cs * { transition: none !important; } }

/* Settings > Less motion (src/shared/a11y-preferences.js sets the attribute). */
:root[data-reduce-motion="true"] *,
:root[data-reduce-motion="true"] *::before,
:root[data-reduce-motion="true"] *::after {
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 1ms !important;
  scroll-behavior: auto !important;
}
