/* The game stays mounted, with no placeholder data exposed while connecting. */
body[data-connection-state="loading"] #game-shell {
  pointer-events: none;
}
body[data-connection-state="loading"]:not(
    [data-connection-presentation="silent"]
  )
  #game-shell {
  visibility: hidden;
}

.connection-screen[hidden],
.connection-screen [hidden] {
  display: none;
}

.connection-screen {
  position: fixed;
  inset: 0;
  z-index: 115;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: max(var(--ui-space-5), env(safe-area-inset-top, 0px))
    max(var(--ui-space-4), env(safe-area-inset-right, 0px))
    max(var(--ui-space-5), env(safe-area-inset-bottom, 0px))
    max(var(--ui-space-4), env(safe-area-inset-left, 0px));
  background: var(--ui-color-background);
  color: var(--ui-color-text);
  font-family: var(--ui-font-body);
}

.connection-screen__panel {
  box-sizing: border-box;
  flex: none;
  width: min(100%, 432px);
  margin: auto;
  padding: var(--ui-space-5);
  border: 1px solid var(--ui-color-border);
  border-top: 3px solid var(--ui-color-primary);
  border-radius: var(--ui-radius);
  background: var(--ui-color-surface-raised);
}

.connection-screen__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-2);
  margin-bottom: var(--ui-space-4);
}

.connection-screen__brand {
  color: var(--ui-color-on-primary);
  font: 400 24px/1 var(--ui-font-display);
  letter-spacing: 0.03em;
  white-space: pre;
}

.connection-screen__back.ui-button {
  flex: none;
  align-items: center;
  gap: var(--ui-space-1);
  min-height: 44px;
  padding-inline: var(--ui-space-2);
  font-size: 12px;
  font-weight: 600;
}

.connection-screen__back-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask: url("/_assets/b88d45443fa2dbfe501f/icons/arrow-right.svg") center / contain no-repeat;
  mask: url("/_assets/b88d45443fa2dbfe501f/icons/arrow-right.svg") center / contain no-repeat;
  transform: rotate(180deg);
}

.connection-screen__brand-accent {
  color: var(--ui-color-primary);
}

.connection-screen__identity {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: var(--ui-space-3);
  margin-bottom: var(--ui-space-5);
  overflow-wrap: anywhere;
}

.connection-screen__portrait {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  overflow: hidden;
  border: 1px solid var(--ui-color-border-subtle);
  border-radius: var(--ui-radius);
  background: var(--ui-color-background);
}

.connection-screen__portrait canvas {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
}

.connection-screen__trainer-info {
  display: grid;
  gap: var(--ui-space-1);
  min-width: 0;
}

.connection-screen__level {
  color: var(--ui-color-text-muted);
  font-size: 12px;
}

.connection-screen__wallet {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ui-space-3);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.connection-screen__balance {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-1);
}

.connection-screen__balance img,
.connection-screen__portrait img {
  object-fit: contain;
  image-rendering: pixelated;
}

.connection-screen__eyebrow {
  color: var(--ui-color-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.connection-screen__trainer {
  font: 400 24px/1.1 var(--ui-font-display);
}

.connection-screen__title {
  margin: 0 0 var(--ui-space-2);
  font: 400 34px/1.05 var(--ui-font-display);
  overflow-wrap: anywhere;
}

.connection-screen__title:focus {
  outline: none;
}

.connection-screen__message {
  min-height: 42px;
  margin: 0;
  color: var(--ui-color-text-muted);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.connection-screen__activity {
  height: 6px;
  margin-block: var(--ui-space-5);
  overflow: hidden;
  background: var(--ui-color-background);
}

.connection-screen__activity-bar {
  display: block;
  width: 30%;
  height: 100%;
  background: var(--ui-color-primary);
  animation: connection-screen-activity 1.5s linear infinite;
}

@keyframes connection-screen-activity {
  from {
    transform: translateX(-110%);
  }
  to {
    transform: translateX(440%);
  }
}

.connection-screen__steps.ui-stepper {
  height: auto;
  margin: 0;
}

.connection-screen__steps .ui-stepper__step {
  background: transparent;
}

.connection-screen__step::before {
  content: "";
  display: block;
  height: 4px;
  background: var(--ui-color-border);
}

.connection-screen__step:is(
    [data-state="current"],
    [data-state="complete"]
  )::before {
  background: var(--ui-color-action);
}

.connection-screen__step-label {
  display: block;
  margin-top: var(--ui-space-2);
  color: var(--ui-color-text-muted);
  font-size: 12px;
  line-height: 1.25;
  text-align: left;
}

.connection-screen__step[data-state="current"] .connection-screen__step-label,
.connection-screen__step[data-state="complete"] .connection-screen__step-label {
  color: var(--ui-color-text);
}

.connection-screen__step[data-state="current"] .connection-screen__step-label {
  font-weight: 600;
}

.connection-screen__actions {
  display: grid;
  gap: var(--ui-space-2);
  margin-top: var(--ui-space-4);
}

.connection-screen__actions .ui-button {
  min-height: 44px;
  font-size: 13px;
  font-weight: 600;
}

.connection-screen__actions .ui-button--primary {
  border-color: var(--ui-color-action);
  background: var(--ui-color-action);
  color: var(--ui-color-on-primary);
}

.connection-screen__actions .ui-button--primary:hover:not(:disabled) {
  border-color: var(--ui-color-action-hover);
  background: var(--ui-color-action-hover);
  color: var(--ui-color-on-primary);
}

.connection-screen__actions .ui-button:focus-visible {
  outline: var(--ui-focus-width) solid var(--ui-color-focus);
  outline-offset: var(--ui-focus-offset);
}

.connection-screen__back.ui-button:focus-visible {
  outline: var(--ui-focus-width) solid var(--ui-color-focus);
  outline-offset: var(--ui-focus-offset);
}

.connection-screen[data-state="error"] .connection-screen__steps {
  margin-top: var(--ui-space-5);
}

@media (max-width: 400px) {
  .connection-screen__panel {
    padding: var(--ui-space-4);
  }
  .connection-screen__title {
    font-size: 30px;
  }
  .connection-screen__brand {
    font-size: 20px;
  }
  .connection-screen__step-label {
    font-size: 11px;
  }
}

.connection-diagnostic {
  display: grid;
  gap: var(--ui-space-2);
  margin-top: var(--ui-space-4);
  padding-top: var(--ui-space-3);
  border-top: 1px solid var(--ui-color-border-subtle);
  color: var(--ui-color-text-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.connection-diagnostic[hidden] {
  display: none;
}
.connection-diagnostic small {
  font-size: 11px;
}
.connection-diagnostic .ui-button {
  min-height: 44px;
  font-size: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .connection-screen__activity-bar {
    margin-inline: auto;
    opacity: 0.7;
    animation: none;
  }
}

/* Fullscreen presentation. Readiness and transport remain owned by the app. */
:root {
  --connection-scene-background:
    radial-gradient(
      ellipse at 50% 43%,
      transparent 22%,
      rgb(3 8 17 / 16%) 53%,
      rgb(3 8 17 / 80%) 100%
    ),
    linear-gradient(
      rgb(6 11 19 / 20%),
      rgb(6 11 19 / 6%) 58%,
      rgb(6 11 19 / 14%)
    ),
    url("/_assets/b88d45443fa2dbfe501f/images/connection-landscape.png") center / cover no-repeat;
}
.connection-screen {
  isolation: isolate;
  gap: 24px;
  padding: max(20px, env(safe-area-inset-top)) 28px 28px;
  background: transparent;
}
.connection-screen__landscape,
.connection-screen__veil {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: var(--connection-scene-background);
}
.connection-screen__landscape {
  z-index: -1;
}
.connection-screen__veil {
  z-index: 114;
  opacity: 0;
}
.connection-screen__veil[hidden] {
  display: none;
}
.connection-screen__header {
  flex: none;
  margin: 0;
  gap: 16px;
}
.connection-screen__brand {
  display: flex;
  align-items: center;
  font-size: 25px;
  text-shadow: 0 2px 0 var(--ui-color-background);
}
.connection-screen__logo {
  width: 56px;
  height: 56px;
  margin-right: 8px;
  image-rendering: pixelated;
  object-fit: contain;
}
.connection-screen__panel {
  width: min(100%, 720px);
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
}
.connection-screen__identity {
  width: max-content;
  max-width: 100%;
  margin: 0 auto 26px;
  grid-template-columns: 80px minmax(0, max-content);
  gap: 16px;
  text-align: left;
  text-shadow: 0 2px 0 var(--ui-color-background);
}
.connection-screen__portrait[data-ready="false"] {
  visibility: hidden;
}
.connection-screen__portrait {
  width: 80px;
  height: 80px;
  border: 0;
  background: transparent;
  overflow: visible;
}
.connection-screen__portrait canvas {
  width: 80px;
  height: 80px;
}
.connection-screen__eyebrow {
  display: none;
}
.connection-screen__trainer {
  font-size: 28px;
}
.connection-screen__level {
  font-size: 14px;
  color: var(--ui-color-text);
}
.connection-screen__status {
  display: grid;
  justify-items: center;
  grid-template-rows: minmax(62px, auto) minmax(66px, auto);
  align-items: center;
  text-shadow: 0 2px 0 rgb(6 11 19 / 80%);
}
.connection-screen__title {
  margin: 0;
  color: var(--ui-color-on-primary);
  font-size: 52px;
  line-height: 1.04;
  letter-spacing: 0.005em;
}
.connection-screen__message {
  width: min(100%, 480px);
  min-height: 0;
  margin: 14px 0 0;
  color: var(--ui-color-text);
  font-size: 16px;
  line-height: 1.5;
}
.connection-screen__activity {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.connection-screen__activity-bar {
  animation: none;
}
.connection-screen__steps.ui-stepper {
  position: fixed;
  inset: auto 0 0;
  width: 100%;
  height: 8px;
  gap: 4px;
  margin: 0;
}
.connection-screen__step {
  position: static;
  height: 8px;
}
.connection-screen__step::before {
  height: 8px;
}
.connection-screen__step[data-state="current"]::before {
  animation: connection-stage-breathe 1.45s ease-in-out infinite;
}
.connection-screen[data-state="error"] .connection-screen__step::before {
  animation: none;
}
.connection-screen__step-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.connection-screen__actions {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}
.connection-screen__actions .ui-button {
  width: auto;
  min-width: 156px;
}
.connection-diagnostic {
  width: min(100%, 432px);
  margin: 20px auto 0;
  padding: 14px;
  border: 1px solid var(--ui-color-border);
  border-radius: var(--ui-radius);
  background: color-mix(
    in srgb,
    var(--ui-color-surface-raised) 94%,
    transparent
  );
  text-align: left;
  gap: 8px;
}
.connection-diagnostic .ui-button {
  justify-self: start;
  min-width: 156px;
  border: 1px solid var(--ui-color-border);
  background: var(--ui-color-surface-control);
  color: var(--ui-color-text);
}
@keyframes connection-stage-breathe {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}
@media (max-width: 600px) {
  .connection-screen {
    padding: max(12px, env(safe-area-inset-top)) 20px 24px;
    gap: 24px;
  }
  .connection-screen__header {
    gap: 8px;
  }
  .connection-screen__brand {
    font-size: 0;
  }
  .connection-screen__logo {
    margin: 0;
  }
  .connection-screen__back.ui-button {
    font-size: 12px;
    padding-inline: 10px;
  }
  .connection-screen__identity {
    margin-bottom: 20px;
  }
  .connection-screen__title {
    font-size: 36px;
    line-height: 1.05;
  }
  .connection-screen__status {
    grid-template-rows: minmax(80px, auto) minmax(90px, auto);
  }
  .connection-screen__message {
    font-size: 14px;
    max-width: 310px;
    margin-top: 12px;
  }
  .connection-screen__landscape,
  .connection-screen__veil {
    background-position:
      center,
      center,
      57% center;
  }
}
@media (max-height: 540px) and (min-width: 601px) {
  .connection-screen {
    gap: 12px;
  }
  .connection-screen__identity {
    margin-bottom: 10px;
    grid-template-columns: 64px auto;
  }
  .connection-screen__portrait,
  .connection-screen__portrait canvas {
    width: 64px;
    height: 64px;
  }
  .connection-screen__title {
    font-size: 38px;
  }
  .connection-screen__status {
    grid-template-rows: 44px 52px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .connection-screen__step[data-state="current"]::before {
    animation: none;
  }
}
