/* Account screens use the same tabletop art as the loading sequence. */
#player-portal:is([data-phase="auth"], [data-phase="connecting"]) {
  --portal-ink: #402a1c;
  --portal-muted: #6e5140;
  --portal-accent: #4b572d;
  --portal-line: #c7a475;
  --portal-paper: #f9ebd1;
  --portal-field: #fff5df;
  --portal-inset: #ead7b5;
  display: flex;
  flex-direction: column;
  padding: 30px;
  color: var(--portal-ink);
  background:
    radial-gradient(ellipse at 50% 44%, #605b3eb0, #1d241cd9 85%),
    #242d22 url("/assets/resources/native/35/35dd48a6-6de7-40e9-83c5-a4c83d288a82.90029.jpg") center / 375px auto repeat;
}

#player-portal:is([data-phase="auth"], [data-phase="connecting"]) .player-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.11fr) minmax(0, 1fr);
  align-items: stretch;
  width: min(100%, 1050px);
  min-height: 618px;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #a98355;
  border-radius: 16px;
  background: linear-gradient(150deg, #fff0d3, #f2dab3 88%);
  box-shadow: 0 0 0 4px #1a2018a6, 0 24px 66px #0d130cb3;
  text-align: left;
}

#player-portal:is([data-phase="auth"], [data-phase="connecting"]) .player-stage::before,
#player-portal:is([data-phase="auth"], [data-phase="connecting"]) .player-stage::after {
  display: none;
}

.player-stage .player-brand {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  justify-content: stretch;
  align-items: stretch;
  isolation: isolate;
  overflow: hidden;
  margin: 0;
  padding: 47px 26px 64px;
  background:
    linear-gradient(180deg, #19291efa 0%, #1b2a1d80 23%, transparent 52%, #4a291a55 88%, #35241bef 100%),
    #715238 url("/native-ui/arena-scenes/map_40003-background.png") center 41% / cover no-repeat;
}

.player-brand::before {
  position: absolute;
  z-index: 0;
  inset: 11px;
  border: 1px solid #f7d78a4f;
  border-radius: 8px 4px 8px 4px;
  pointer-events: none;
  content: "";
}

.player-brand::after {
  display: none;
}

.player-brand-copy {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
  animation: tabletop-title-arrive .52s cubic-bezier(.2,.75,.25,1) both;
}

.player-brand .player-emblem {
  display: grid;
  width: 35px;
  height: 35px;
  margin: 0;
  border: 1px solid #f2ae63;
  border-radius: 6px 9px 6px 9px;
  background: #8b462c;
  box-shadow: 0 2px #402619;
  color: #ffe6b9;
  transform: rotate(-8deg);
}

.player-brand .player-brand-copy h1 {
  margin: 0;
  color: #ffdea0;
  font: 900 clamp(45px, 6vw, 76px)/1.04 "Songti SC", SimSun, "Microsoft YaHei", serif;
  letter-spacing: .035em;
  text-shadow: 0 3px #6d391c, 0 6px #3c261b, 0 9px 16px #120f0b;
  -webkit-text-stroke: .6px #ffe6ba;
}

.player-portal-art {
  position: relative;
  align-self: end;
  width: 100%;
  max-width: 465px;
  margin: 0 auto;
  animation: tabletop-art-arrive .62s .09s cubic-bezier(.2,.75,.25,1) both;
}

.player-brand .player-lineup {
  position: relative;
  inset: auto;
  width: 100%;
  transform: none;
}

.player-brand .player-lineup-hero {
  animation: tabletop-hero-arrive .48s .16s cubic-bezier(.2,.75,.25,1) both;
}

.player-brand .player-lineup-hero:nth-child(2) {
  animation-delay: .23s;
}

.player-brand .player-lineup-hero:nth-child(3) {
  animation-delay: .30s;
}

.player-brand .player-lineup .player-lineup-hero img {
  width: 108%;
}

.player-brand .player-lineup .player-lineup-hero:nth-child(2) img {
  width: 117%;
}

#player-portal:is([data-phase="auth"], [data-phase="connecting"]) .player-card {
  align-self: center;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 40px clamp(30px, 5.1vw, 63px);
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  animation: tabletop-form-arrive .42s cubic-bezier(.2,.75,.25,1) both;
}

@keyframes tabletop-title-arrive {
  from { opacity: 0; transform: translateY(-12px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes tabletop-art-arrive {
  from { opacity: .1; transform: translateY(27px) scale(.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes tabletop-form-arrive {
  from { opacity: .45; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes tabletop-hero-arrive {
  0% { opacity: 0; transform: translateY(18px) scale(.91); }
  70% { opacity: 1; transform: translateY(-4px) scale(1.025); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

#player-portal .player-card-heading {
  padding: 0;
  border: 0;
  background: transparent;
}

.player-card-heading::before,
.player-card-heading::after {
  display: none;
}

.player-card-heading .player-card-title {
  margin: 0 0 10px;
  color: var(--portal-ink);
  font: 900 clamp(30px, 3vw, 40px)/1.2 "Songti SC", SimSun, "Microsoft YaHei", serif;
  letter-spacing: .025em;
  text-shadow: none;
}

.player-card-heading #player-card-caption {
  margin: 0;
  color: var(--portal-muted);
  font-size: 14px;
  letter-spacing: 0;
  line-height: 1.6;
}

#player-portal .player-card-body {
  padding: 27px 0 0;
  background: transparent;
}

#player-portal .player-tabs {
  gap: 4px;
  margin: 0 0 23px;
  padding: 4px;
  border: 1px solid #ccac7e;
  border-radius: 7px;
  background: var(--portal-inset);
}

#player-portal.has-account .player-tabs {
  display: none;
}

#player-portal .player-tabs button {
  min-height: 41px;
  border-radius: 7px;
  color: var(--portal-muted);
  font-size: 14px;
  font-weight: 700;
}

#player-portal .player-tabs button:hover {
  color: var(--portal-ink);
}

#player-portal .player-tabs button[aria-selected="true"] {
  background: var(--portal-field);
  box-shadow: inset 0 0 0 1px #c89f64, 0 2px 4px #7047292c;
  color: #563619;
  text-shadow: none;
}

.player-card .player-field-label {
  margin: 0 0 7px;
  color: var(--portal-ink);
  font-size: 14px;
  font-weight: 700;
}

.player-card .player-input-row {
  min-height: 49px;
  margin: 0 0 16px;
  border: 1px solid var(--portal-line);
  border-radius: 7px;
  background: var(--portal-field);
  box-shadow: none;
}

.player-card .player-input-row:focus-within {
  border-color: var(--portal-accent);
  box-shadow: 0 0 0 3px #65582836;
}

#player-portal .player-input-row input {
  height: 48px;
  padding: 10px 13px;
  outline: 0;
  color: var(--portal-ink);
  font-size: 16px;
}

.player-card .player-input-row input::placeholder {
  color: #765b42;
  font-size: 14px;
}

.player-card .player-input-row input:-webkit-autofill {
  box-shadow: 0 0 0 100px #f3e2c3 inset;
}

#player-portal .player-password-toggle {
  --password-toggle-surface: var(--portal-field);
  display: grid;
  flex: 0 0 48px;
  place-items: center;
  min-width: 48px;
  height: 44px;
  padding: 0;
  border-color: var(--portal-line);
  border-radius: 0 7px 7px 0;
  background: var(--password-toggle-surface);
  color: #644326;
}

#player-portal .player-password-toggle:hover {
  --password-toggle-surface: #f1dfbd;
}

.player-password-eye {
  position: relative;
  width: 22px;
  height: 20px;
  background: radial-gradient(circle, currentColor 2px, transparent 2.5px);
}

.player-password-eye::before {
  position: absolute;
  inset: 2.5px auto auto 3.5px;
  width: 15px;
  height: 15px;
  box-sizing: border-box;
  border: 1.6px solid currentColor;
  border-radius: 18% 74%;
  content: "";
  transform: rotate(-45deg);
}

.player-password-toggle[aria-pressed="true"] .player-password-eye::after {
  position: absolute;
  top: 9px;
  left: 0;
  width: 22px;
  height: 1.6px;
  border-radius: 2px;
  background: currentColor;
  box-shadow: 0 1.5px var(--password-toggle-surface);
  content: "";
  transform: rotate(44deg);
}

#player-portal .player-card .player-primary {
  min-height: 50px;
  margin: 20px 0 0;
  padding: 10px 14px;
  border-radius: 7px;
  border: 1px solid #465024;
  background: linear-gradient(#63733a, #455025);
  box-shadow: inset 0 1px #b0bd7185, 0 3px #a68a5b;
  color: #fff2ca;
  font-size: 16px !important;
  font-weight: 700 !important;
  letter-spacing: .06em;
  text-shadow: none;
}

.player-card .player-register-hint,
#player-portal #player-status {
  color: var(--portal-muted);
  font-size: 13px;
  line-height: 1.55;
}

#player-portal #player-status {
  min-height: 0;
  margin: 12px 0 0;
}

#player-portal #player-status:empty {
  margin: 0;
}

#player-portal #player-status.error {
  color: #a1382e;
}

#player-portal :is(.player-card, .player-server-sheet) :focus-visible {
  outline-color: #724c2b;
}

.player-card .player-account-line,
.player-card #player-character-form {
  border-color: var(--portal-line);
}

.player-card :is(.player-account-seal, .player-character-seal) {
  border-color: #b39b66;
  border-radius: 8px;
  background: #e8d6a9;
  color: var(--portal-accent);
  box-shadow: none;
  clip-path: none;
}

.player-card :is(.player-welcome-caption, .player-character-caption, .player-section-label small) {
  color: var(--portal-muted);
  font-size: 12px;
}

.player-card :is(#player-welcome, .player-character, #player-role-choice) {
  color: var(--portal-ink);
  font-size: 14px;
}

#player-portal .player-card :is(.player-switch, .player-character-wrap, #player-role-choice) {
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: #f4e1bf;
  color: var(--portal-ink);
}

#player-portal .player-card .player-switch {
  min-height: 40px;
  padding-inline: 10px;
  font-size: 12px !important;
}

.player-card .player-server-choice {
  border-color: #aa9760;
  border-radius: 8px;
  background: #eee2b9;
  box-shadow: none;
  color: var(--portal-ink);
}

.player-card .player-choice-arrow {
  color: var(--portal-accent);
}

#player-portal .player-server-sheet {
  width: min(470px, 100%);
  border-color: var(--portal-line);
  border-radius: 17px;
  background: var(--portal-paper);
}

.player-server-sheet > header {
  border: 0;
  background: #704831 url('/auth-assets/native/wood-top.png') center / 100% 100%;
}

.player-server-sheet > header h2 {
  color: #fff6e2;
  text-shadow: none;
}

.player-server-sheet > header > button {
  width: 40px;
  height: 40px;
  border-color: #fff6e270;
  background: #ffffff17;
  color: #fff6e2;
}

.player-server-sheet :is(.player-server-search, .player-realm) {
  border-color: var(--portal-line);
  border-radius: 8px;
  background: #f6e7c9;
  color: var(--portal-ink);
}

.player-server-sheet .player-realm.selected {
  border-color: #8b965e;
  background: #ecdfb2;
  box-shadow: none;
}

.player-server-sheet :is(.player-server-search input, .player-realm-role, .player-server-meta, .player-server-empty, footer) {
  color: var(--portal-muted);
}

.player-server-sheet .player-server-filters button {
  color: var(--portal-muted);
}

.player-server-sheet .player-server-filters button[aria-pressed="true"] {
  border-color: var(--portal-accent);
  color: var(--portal-accent);
}

.player-server-sheet > header > button:focus-visible {
  outline-color: #fff6e2 !important;
}

@media (max-width: 760px) {
  #player-portal:is([data-phase="auth"], [data-phase="connecting"]) {
    padding: 17px 15px;
  }

  #player-portal:is([data-phase="auth"], [data-phase="connecting"]) .player-stage {
    width: min(100%, 450px);
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    border-radius: 13px;
  }

  .player-stage .player-brand {
    min-height: 184px;
    padding: 16px 14px 16px;
    background-position: center 44%;
  }

  .player-brand::before {
    inset: 7px;
  }

  .player-brand-copy {
    grid-auto-flow: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
  }

  .player-brand .player-emblem {
    width: 25px;
    height: 25px;
    font-size: 16px;
  }

  .player-brand .player-brand-copy h1 {
    font-size: clamp(30px, 8.3vw, 39px);
    text-shadow: 0 2px #6d391c, 0 4px #3c261b, 0 6px 10px #120f0b;
  }

  .player-portal-art {
    width: min(78%, 270px);
    margin-top: 10px;
  }

  .player-brand .player-lineup .player-lineup-hero span {
    display: none;
  }

  #player-portal:is([data-phase="auth"], [data-phase="connecting"]) .player-card {
    padding: 23px 20px 26px;
  }

  #player-portal .player-card-body {
    padding-top: 20px;
  }
}

@media (max-width: 350px), (max-width: 760px) and (max-height: 650px) {
  #player-portal:is([data-phase="auth"], [data-phase="connecting"]) {
    padding: 11px;
  }

  .player-stage .player-brand {
    min-height: 156px;
    padding-block: 12px;
  }

  .player-portal-art {
    width: min(74%, 220px);
    margin-top: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .player-brand-copy,
  .player-portal-art,
  .player-brand .player-lineup-hero,
  #player-portal:is([data-phase="auth"], [data-phase="connecting"]) .player-card {
    animation: none;
  }
}

/* Use the game's tabletop map and character art for this loading scene. */
#player-portal:is([data-phase="loading"], [data-phase="failed"]) {
  display: block;
  padding: 0;
  background: #262d24 url("/assets/resources/native/35/35dd48a6-6de7-40e9-83c5-a4c83d288a82.90029.jpg") center / 390px auto repeat;
}

#player-portal:is([data-phase="loading"], [data-phase="failed"]) .player-stage {
  display: block;
  width: min(100%, max(430px, 56dvh));
  min-height: 0;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: 0 0 80px #090d08b3;
}

#player-portal:is([data-phase="loading"], [data-phase="failed"]) .player-stage::before,
#player-portal:is([data-phase="loading"], [data-phase="failed"]) .player-stage::after,
#player-portal:is([data-phase="loading"], [data-phase="failed"]) .player-brand {
  display: none;
}

.player-loading {
  --loading-progress: 0%;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: max(540px, 100vh);
  min-height: max(540px, 100dvh);
  color: #fff0c7;
  text-align: left;
}

.player-loading::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, #19261ece 0%, #19261e44 22%, transparent 43%, transparent 65%, #2e261c55 78%, #211b17f0 100%),
    #423522 url("/native-ui/arena-scenes/map_40003-background.png") center / cover no-repeat;
  content: "";
}

.loading-scene {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.loading-masthead {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 13px;
  padding: clamp(28px, 7vh, 64px) 14px 0;
  text-align: center;
}

.loading-seal {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid #f2ae63;
  border-radius: 6px 8px 6px 9px;
  background: #8e492d;
  box-shadow: 0 2px #402619;
  color: #ffe6b9;
  font: 700 22px SimSun, serif;
  transform: rotate(-8deg);
}

.loading-masthead h2 {
  margin: 0;
  color: #ffdea0;
  font: 900 clamp(42px, 11vw, 70px)/1.02 "Songti SC", SimSun, "Microsoft YaHei", serif;
  letter-spacing: .02em;
  text-shadow: 0 3px #6d391c, 0 6px #3c261b, 0 8px 14px #110f0b;
  -webkit-text-stroke: .6px #ffe6ba;
}

.player-lineup {
  position: absolute;
  top: 61%;
  left: 50%;
  display: grid;
  grid-template-columns: 1fr 1.28fr 1fr;
  align-items: end;
  width: 94%;
  margin: 0;
  padding: 0;
  list-style: none;
  transform: translate(-50%, -50%);
}

.player-lineup-hero {
  display: grid;
  justify-items: center;
  min-width: 0;
}

.player-lineup-hero img {
  position: relative;
  display: block;
  width: 115%;
  max-width: none;
  height: auto;
  filter: drop-shadow(1px 7px 6px #68351580);
  animation: loading-hero-idle 1.75s ease-in-out infinite;
}

.player-lineup-hero:first-child img {
  animation-delay: -.44s;
}

.player-lineup-hero:last-child img {
  animation-delay: -.93s;
}

.player-lineup-hero:nth-child(2) {
  position: relative;
  z-index: 1;
}

.player-lineup-hero:nth-child(2) img {
  width: 120%;
  filter: drop-shadow(0 8px 7px #68351599);
}

.player-lineup-hero span {
  z-index: 2;
  margin-top: -3px;
  padding: 3px 9px 4px;
  border: 1px solid #6f4327;
  border-radius: 4px 5px 4px 6px;
  background: linear-gradient(#784b31, #533220);
  box-shadow: 0 2px #914e2c55;
  color: #ffe0a4;
  font-size: clamp(11px, 3.1vw, 14px);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.loading-journey {
  position: relative;
  align-self: end;
  z-index: 1;
  margin: 0 auto;
  width: min(89%, 416px);
  padding: 4px 0 max(34px, env(safe-area-inset-bottom));
}

.loading-status {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px;
}

.loading-status #player-load-label {
  margin: 0;
  color: #fff0c7;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.55;
  text-shadow: 0 2px #271c14;
  overflow-wrap: anywhere;
}

#player-load-percent {
  flex: none;
  color: #ffde8f;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px #352419;
}

.loading-route {
  position: relative;
  margin-top: 9px;
}

.player-load-track {
  position: relative;
  height: 19px;
  overflow: hidden;
  border: 2px solid #694e33;
  border-radius: 10px;
  background: #352f22 url("/assets/resources/native/4e/4eced1a3-351f-4630-8fa8-6e35ebf523f5.d8e4f.png") center / 100% 100% no-repeat;
  box-shadow: 0 3px 6px #201610cc;
}

.player-load-track > span,
.player-load-track:not(.determinate)::after {
  display: block;
  height: 100%;
  border-radius: 8px;
  background: #a3b950 url("/assets/resources/native/28/28a25153-c760-4b0a-868c-535baf2da2c0.99974.png") center / 100% 100% no-repeat;
}

.player-load-track > span {
  width: 0;
  transition: width .25s ease-out;
}

.player-load-track:not(.determinate)::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: 24%;
  animation: loading-track-sweep 2s ease-in-out infinite alternate;
  content: "";
}

.loading-van {
  position: absolute;
  z-index: 1;
  bottom: calc(100% + 32px);
  left: clamp(30px, var(--loading-progress), calc(100% - 30px));
  display: block;
  width: 68px;
  height: auto;
  filter: drop-shadow(0 4px 3px #291b14ac);
  translate: -50% 0;
  transition: left .25s ease-out;
  animation: loading-van-idle .8s ease-in-out infinite;
}

.loading-route:has(.player-load-track:not(.determinate)) .loading-van {
  animation: loading-van-travel 2s ease-in-out infinite alternate, loading-van-idle .8s ease-in-out infinite;
}

#player-load-detail {
  min-height: 19px;
  margin: 6px 4px 0;
  color: #eed7af;
  font-size: 12px;
  line-height: 1.55;
  text-shadow: 0 1px #271c14;
}

#player-load-percent:empty {
  display: none;
}

#player-portal[data-phase="failed"] .player-lineup-hero img {
  animation: none;
}

#player-portal[data-phase="failed"] .loading-route,
#player-portal[data-phase="failed"] #player-load-percent {
  display: none;
}

#player-portal[data-phase="failed"] #player-load-label {
  color: #ffd0b7;
}

#player-portal #player-reload {
  min-height: 44px;
  margin: 10px 4px 0;
  padding: 8px 20px;
  border: 1px solid #9ea455;
  border-radius: 5px;
  background: #515e32 url("/auth-assets/native/button-green.png") center / 100% 100% no-repeat;
  color: #fff3cb;
  font-size: 14px;
  font-weight: 800;
  text-shadow: 0 1px #3c391e;
}

#player-portal #player-reload:hover {
  filter: brightness(1.15);
}

@keyframes loading-hero-idle {
  0%, 100% { transform: translateY(0) rotate(-.5deg); }
  50% { transform: translateY(-5px) rotate(.5deg); }
}

@keyframes loading-van-idle {
  0%, 100% { transform: translateY(0) rotate(-1.4deg); }
  50% { transform: translateY(-3px) rotate(1.4deg); }
}

@keyframes loading-van-travel {
  from { left: 30px; }
  to { left: calc(100% - 30px); }
}

@keyframes loading-track-sweep {
  to { transform: translateX(317%); }
}

@media (max-height: 650px) {
  .player-lineup {
    top: 60%;
    width: 82%;
  }

  .loading-journey {
    padding-bottom: max(19px, env(safe-area-inset-bottom));
  }

  .loading-van {
    width: 57px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .player-lineup-hero img,
  .loading-van,
  .loading-route:has(.player-load-track:not(.determinate)) .loading-van,
  .player-load-track:not(.determinate)::after {
    animation: none;
  }
}
