.mobile-lobby {
  grid-template-columns: 1.03fr 1fr;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top top" "hero modes" "foot foot";
  gap: 10px 4.1vw;
  padding-inline: max(24px, env(safe-area-inset-left)) max(24px, env(safe-area-inset-right));
  color: #fff;
  isolation: isolate;
  background:
    linear-gradient(180deg, #23529d5e, #91baff39 31%, #90c9ff0d 63%, #3a60a84a),
    url("assets/lobby-stage.webp") center 65% / cover no-repeat,
    linear-gradient(142deg, #6ca1f5, #89bcfb 44%, #8daff4 70%, #b9e5ff);
}
.mobile-lobby::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: auto 0 0;
  height: 38%;
  background: repeating-radial-gradient(ellipse at center, #dcf2ff21 0 1px, transparent 2px 19px);
  border-top: 1px solid #d8f0ff30;
  border-radius: 50% 50% 0 0 / 38% 38% 0 0;
}
.mobile-lobby .lobby-top {
  grid-area: top;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  justify-items: start;
  padding: 0;
}
.player-profile {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 5px clamp(10px, 1.7vw, 25px) 5px 6px;
  border: 1px solid #d8f4ff;
  border-radius: 8px 14px 17px 8px;
  color: #fff;
  background: linear-gradient(120deg, #6790d7, #315ba2);
  box-shadow: 0 4px 0 #3175be65, inset 0 1px 4px #bae5ffb3;
  cursor: pointer;
  text-align: left;
}
.player-profile img { width: clamp(40px, 3.6vw, 64px); aspect-ratio: 1; object-fit: cover; object-position: center top; background: linear-gradient(#d9f6ff, #a2c3ff); border-radius: 7px; }
.player-profile span { display: grid; gap: 2px; }
.player-profile strong { font-size: clamp(13px, 1.05vw, 20px); line-height: 1.2; }
.player-profile small { font-size: clamp(10px, .85vw, 16px); font-weight: 800; color: #ffe2a1; }
.player-profile meter { display: block; width: clamp(44px, 4.7vw, 85px); height: 7px; }
.player-profile meter::-webkit-meter-bar { background: #28467b; border-color: #b7ddff65; }
.player-profile meter::-webkit-meter-optimum-value { background: linear-gradient(90deg, #ffc059, #fff2a8); }
.lobby-wordmark {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin: 0;
  padding-inline: .2em;
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  font-size: clamp(27px, 4vw, 74px);
  font-style: italic;
  font-weight: 950;
  line-height: 1.08;
  letter-spacing: -.035em;
  white-space: nowrap;
  color: #fff;
  -webkit-text-stroke: .088em #21437b;
  paint-order: stroke fill;
  text-shadow: .028em .07em #254b88, .048em .12em #123466, 0 0 .43em #a4edffae;
}
.lobby-wordmark small { font: italic 900 .27em/1.15 system-ui, sans-serif; letter-spacing: .16em; color: #e8fcff; -webkit-text-stroke-width: 0; text-shadow: 0 2px 2px #193f76; }
.lobby-status { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.lobby-status .online-pill { font-size: clamp(12px, 1vw, 17px); padding: 7px 13px; white-space: nowrap; }
.lobby-tool {
  width: clamp(40px, 3.1vw, 56px);
  height: clamp(40px, 3.1vw, 56px);
  border: 1px solid #e2f9ff;
  border-radius: 8px;
  background: linear-gradient(155deg, #73bdf2, #2966b8 53%, #194584);
  color: #effcff;
  box-shadow: 0 2px #23487d66;
  font-size: 19px;
  cursor: pointer;
}
.lobby-tool[aria-pressed="true"] span { opacity: .52; text-decoration: line-through; }
.showcase {
  grid-area: hero;
  position: relative;
  --pet-aura: #a5f8ff;
  min-width: 0;
  min-height: 0;
  isolation: isolate;
}
.showcase-orbit {
  position: absolute;
  inset: auto 9% 4% 8%;
  height: 20%;
  border-radius: 50%;
  background:
    radial-gradient(ellipse, #2a467d96 0 30%, transparent 53%),
    repeating-radial-gradient(ellipse, #eaffff6e 0 1px, transparent 2px 17px),
    linear-gradient(170deg, #aedcff99, #3572c8bf);
  border: 2px solid #d6f6ffda;
  box-shadow: 0 8px 0 #426fbea6, inset 0 0 15px #c9faffba, 0 0 24px #c8f5ff83;
}
.showcase-orbit::before, .showcase-orbit::after {
  content: "";
  position: absolute;
  inset: 14% 9%;
  border: 1px solid #d9fbffa3;
  border-radius: 50%;
}
.showcase-orbit::after {
  inset: -15% -4%;
  border-color: var(--pet-aura);
  box-shadow: 0 0 15px var(--pet-aura);
  opacity: .28;
}
.showcase[data-tier="1"] .showcase-orbit::after { opacity: .7; }
.showcase[data-tier="2"] .showcase-orbit::after { opacity: 1; box-shadow: 0 0 30px var(--pet-aura), inset 0 0 14px var(--pet-aura); }
.showcase[data-tier="2"] .showcase-pet img { filter: drop-shadow(0 8px 14px #1d529978) drop-shadow(0 0 10px var(--pet-aura)); }
.showcase-pet::before {
  content: "";
  position: absolute;
  left: 27%;
  right: 27%;
  bottom: -1%;
  height: 6%;
  border-radius: 50%;
  background: #1d3f826e;
  filter: blur(4px);
  z-index: -1;
}
.showcase-pet {
  position: absolute;
  inset: 0 9% 12% 8%;
  display: grid;
  place-items: end center;
  animation: podium-hover 3.8s ease-in-out infinite;
}
.showcase-pet img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(7px 10px 11px #122a5b83) drop-shadow(0 0 3px #cfedff);
}
.showcase-pet img { max-width: 89%; max-height: 99%; }
.showcase-pet [hidden] { display: none; }
.showcase-caption {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 13px;
  bottom: 3%;
  left: 2%;
  max-width: 95%;
  padding: 4px 7px 6px 13px;
  border: 1px solid #dff7ff;
  border-radius: 7px 14px 14px 7px;
  background: linear-gradient(116deg, #2f5194f2, #749ff4ee);
  box-shadow: 0 3px 0 #305faf80;
}
.showcase-caption p { margin: 0; font-weight: 800; font-size: clamp(8px, 1.4vw, 13px); color: #e0f7ff; }
.showcase-caption h2 { margin: 0; font-size: clamp(20px, 4.2vw, 54px); font-style: italic; line-height: 1.08; text-shadow: 0 2px #305891; }
.showcase-arrow, .sheet-close {
  border: 1px solid #fff;
  border-radius: 8px;
  width: 31px;
  height: 31px;
  background: #e7f6ff;
  color: #2864ab;
  font-weight: 900;
  font-size: 20px;
  cursor: pointer;
}
@keyframes podium-hover { 50% { transform: translateY(-5px); } }

.mode-cards {
  grid-area: modes;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 1.6vw, 18px);
  min-height: 0;
  align-self: stretch;
  padding: 5% 5% 6% 0;
  perspective: 850px;
}
.mode-card {
  --card-tilt: -8deg;
  --card-angle: -6deg;
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  border: 2px solid #e7f9ff;
  border-radius: 13px;
  padding: 0;
  isolation: isolate;
  overflow: clip;
  overflow-clip-margin: 10px;
  color: #1a5594;
  box-shadow: 5px 7px 0 #3155928c, 10px 16px 22px #23478277, inset 0 1px 0 #fff;
  transform: rotateY(var(--card-angle)) skewX(var(--card-tilt));
  cursor: pointer;
  transition: transform .18s, filter .18s;
}
.mode-card:hover { transform: translateY(-4px) rotateY(var(--card-angle)) skewX(var(--card-tilt)); filter: saturate(1.12); }
.mode-card:active { transform: translateY(3px) rotateY(var(--card-angle)) skewX(var(--card-tilt)); }
.mode-play { --card-tilt: -10deg; grid-area: 1 / 1; color: #b1245a; background: #f090ae; }
.mode-night { --card-tilt: -8deg; grid-area: 2 / 1; color: #263b75; background: #111633; }
.mode-night .mode-picture {
  background: radial-gradient(ellipse at 59% 39%, #3e3d77, transparent 64%), repeating-linear-gradient(137deg, #7fa2ff18 0 1px, transparent 2px 24px), #0c1531;
}
.night-card-eyes {
  position: absolute;
  inset: 13% 5% 24%;
  background: radial-gradient(ellipse 12% 14% at 41% 52%, #ffffef 34%, #8bffdf 53%, #43e9d362 70%, transparent 100%),
    radial-gradient(ellipse 12% 14% at 59% 52%, #ffffef 34%, #8bffdf 53%, #43e9d362 70%, transparent 100%);
}
.mode-roster { --card-angle: 7deg; grid-area: 1 / 2; background: #61ccfb; }
.mode-forms { --card-angle: 4deg; grid-area: 2 / 2; color: #9a581a; background: #fabb46; }
.mode-picture {
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  background:
    repeating-linear-gradient(145deg, #ffffff29 0 1px, transparent 2px 21px, #ffffff28 22px 25px, transparent 26px 54px),
    conic-gradient(from 91deg at 45% 34%, #fff8, transparent 28%, #315bb175 42%, #fff3 70%, #e7fdff73 86%);
}
.mode-play .mode-picture {
  background:
    repeating-linear-gradient(134deg, #fff2 0 1px, transparent 2px 48px),
    radial-gradient(ellipse at 25% 26%, #ffb092, transparent 74%),
    conic-gradient(from 91deg at 46% 35%, #fa7e987d, transparent 28%, #a8327970 61%, transparent 80%),
    linear-gradient(145deg, #f36b82, #df5c98 60%, #9f3d81);
}
.mode-gate {
  position: absolute;
  inset: 13% 20% 18% 25%;
  border: 3px solid #fff0bc;
  border-radius: 50% 50% 13% 13%;
  transform: rotate(-8deg);
  opacity: .72;
  box-shadow: 0 0 15px #ffd688, inset 0 0 24px #ffe5c098;
}
.mode-card .mode-pet {
  position: absolute;
  width: 92%;
  height: 83%;
  left: 5%;
  top: 0;
  object-fit: cover;
  object-position: center top;
  transform: skewX(calc(var(--card-tilt) * -1)) rotate(-2deg);
  filter: drop-shadow(6px 6px 5px #2266b473);
}
.mode-play .mode-pet { top: 0; height: 88%; width: 88%; left: 6%; object-position: center 25%; transform: skewX(10deg) rotate(-4deg); }
.mode-roster .mode-pet { object-position: center 27%; }
.mode-forms .mode-pet { object-position: center 7%; }
.mode-flag {
  position: absolute;
  z-index: 2;
  top: 5px;
  right: -2px;
  padding: 4px 8px 5px;
  border-radius: 8px 0 0 8px;
  background: #ffe382;
  color: #93432b;
  font-size: clamp(9px, 1.15vw, 12px);
  font-weight: 900;
}
.mode-label {
  position: relative;
  align-self: end;
  display: grid;
  gap: 2px;
  padding: 7px 4px;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(#fffdf2f7, #e8f7ff);
  text-align: center;
  line-height: 1;
}
.mode-label strong { font-size: clamp(17px, 3.2vw, 39px); font-weight: 950; font-style: italic; letter-spacing: -.035em; }
.mode-label small { font-size: clamp(8px, 1.35vw, 15px); font-weight: 850; font-style: italic; letter-spacing: .065em; }
.mode-label > * { transform: skewX(calc(var(--card-tilt) * -1)); }
.mode-card::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(128deg, #fff0 22%, #fff7 37%, #fff2 41%, #fff0 53%) 110% 0 / 245% 100%;
  opacity: .56;
  transition: background-position .5s;
}
.mode-card:hover::after, .mode-card:focus-visible::after { background-position: 12% 0; }
.showcase-orbit::after { animation: stage-light 3.2s ease-in-out infinite alternate; }
@keyframes stage-light { from { transform: scale(.99); } to { transform: scale(1.035); } }
.mode-play .mode-label strong, .mode-night .mode-label strong { font-size: clamp(17px, 3.2vw, 39px); }
.lobby-footer { grid-area: foot; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lobby-dispatch { font-size: clamp(10px, 1.4vw, 14px); padding: 6px 11px; border-radius: 6px 13px; background: #2858a898; color: #fff; font-weight: 700; }
.lobby-dispatch span { color: #caf7ff; margin-right: 4px; }
.lobby-dispatch b { font-size: .7em; margin: 0 4px; color: #ffe7a9; }
.ui-icon { --icon-x: 0%; --icon-y: 0%; display: inline-block; vertical-align: middle; width: 28px; height: 28px; flex-shrink: 0; background: url("assets/alliance-icons.webp") var(--icon-x) var(--icon-y) / 400% 300% no-repeat; }
.icon-shock { --icon-x: 33.333%; }
.icon-orbit { --icon-x: 66.667%; }
.icon-cat { --icon-x: 100%; }
.icon-rabbit { --icon-y: 50%; }
.icon-dog { --icon-x: 33.333%; --icon-y: 50%; }
.icon-star { --icon-x: 66.667%; --icon-y: 50%; }
.icon-sound { --icon-x: 100%; --icon-y: 50%; }
.icon-guide { --icon-y: 100%; }
.icon-medal { --icon-x: 33.333%; --icon-y: 100%; }
.icon-notice { --icon-x: 66.667%; --icon-y: 100%; }
.mobile-lobby .ui-icon { background-image: url("assets/lobby-icons-frost.webp"); background-size: 400% 200%; }
.mobile-lobby .icon-cat { --icon-x: 0%; --icon-y: 0%; }
.mobile-lobby .icon-star { --icon-x: 33.333%; --icon-y: 0%; }
.mobile-lobby .icon-leaderboard { --icon-x: 66.667%; --icon-y: 0%; }
.mobile-lobby .icon-medal { --icon-x: 100%; --icon-y: 0%; }
.mobile-lobby .icon-guide { --icon-x: 0%; --icon-y: 100%; }
.mobile-lobby .icon-notice { --icon-x: 33.333%; --icon-y: 100%; }
.mobile-lobby .icon-sound { --icon-x: 66.667%; --icon-y: 100%; }
.mobile-lobby .icon-swap { --icon-x: 100%; --icon-y: 100%; width: 81%; height: auto; aspect-ratio: 1; }
.mobile-lobby .showcase-arrow { display: grid; place-items: center; padding: 0; background: #2f60a8; }
.lobby-rail {
  position: absolute;
  z-index: 3;
  left: max(11px, env(safe-area-inset-left));
  top: max(60px, 20%);
  display: grid;
  gap: clamp(5px, 1.5vh, 16px);
  padding: 6px;
  border-radius: 16px;
  border-right: 1px solid #d9f5ff85;
  background: linear-gradient(105deg, #356cb34d, #a3c9ff55 82%, #e0f7ff25);
}
.lobby-rail button, .lobby-nav button {
  display: grid;
  justify-items: center;
  gap: 1px;
  color: #f4fbff;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  font-weight: 900;
  font-style: italic;
  text-shadow: 0 2px #234780, 0 0 8px #193e71;
  cursor: pointer;
  transition: background .18s, border-color .18s;
}
.lobby-rail button { min-width: clamp(36px, 4vw, 70px); padding: 2px 4px; font-size: clamp(10px, 1.1vw, 17px); }
.lobby-rail .ui-icon, .lobby-nav .ui-icon { width: clamp(27px, 3.4vw, 57px); height: clamp(27px, 3.4vw, 57px); }
.lobby-rail button:is(:hover,:focus-visible), .lobby-nav button:is(:hover,:focus-visible) { border-color: #cef5ffab; background: #b8e2ff32; }
.lobby-dispatch { display: flex; align-items: center; gap: 7px; min-width: 0; }
.lobby-dispatch strong { color: #a8ffff; flex-shrink: 0; }
.lobby-dispatch > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; }
.lobby-tool .ui-icon { width: 76%; height: auto; aspect-ratio: 1; }
#skill-bar .skill-icon { width: 47%; height: auto; aspect-ratio: 1; filter: drop-shadow(0 2px 4px #20396a5c); }
#skill-bar .skill-key { top: 7px; right: 10px; }
.mode-label strong { -webkit-text-stroke: 2px #ffffff; paint-order: stroke fill; filter: drop-shadow(1px 1px 0 #20366535); }
@media (max-width:700px), (orientation: portrait) { .lobby-rail { display: none; } }
@media (orientation: landscape) and (max-height:550px) {
  .lobby-nav .ui-icon { width: 20px; height: 20px; }
  .lobby-rail .ui-icon { width: 23px; height: 23px; }
  .lobby-dispatch .ui-icon { width: 21px; height: 21px; }
}
.lobby-nav {
  display: flex;
  gap: clamp(5px, 1.1vw, 20px);
  padding-inline: clamp(3px, .8vw, 12px);
  border-radius: 18px 12px 6px 6px;
  border-top: 1px solid #daf6ff6b;
  background: linear-gradient(#4485ca4d, #2b5ca080);
}
.lobby-nav button {
  min-width: clamp(44px, 4.5vw, 87px);
  min-height: 44px;
  padding: 2px clamp(5px, .9vw, 12px) 5px;
  font-size: clamp(11px, 1.2vw, 18px);
}
.lobby-nav button small { color: #e0f4ff; }
.lobby-records {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 0;
}
.lobby-records > div {
  display: grid;
  gap: 3px;
  padding: 12px 4px;
  text-align: center;
  background: #effaff;
  border: 1px solid #fff;
  border-radius: 8px;
  box-shadow: 0 3px #78b4dd;
}
.lobby-records strong { color: #23568f; font-size: 21px; }
.lobby-records span { color: #315981; font-size: 12px; }

.deferred-art { opacity: 0; transition: opacity .18s; }
.deferred-art.art-ready { opacity: 1; }
.showcase-pet:has(.deferred-art:not(.art-ready))::after,
.card-art:has(.deferred-art:not(.art-ready))::after,
.mode-card:has(.deferred-art:not(.art-ready)) .mode-picture::after,
.victory-stage:has(.deferred-art:not(.art-ready))::after {
  content: "";
  position: absolute;
  inset: 16% 25%;
  border-radius: 28% 32% 19% 19%;
  background: linear-gradient(115deg, #d0eaff50 25%, #edfbffae 48%, #d0eaff50 70%) 110% 0 / 235% 100%;
  animation: portrait-skeleton 1.45s ease-in-out infinite;
  pointer-events: none;
}
@keyframes portrait-skeleton { to { background-position: -55% 0; } }

.accessible-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
#screen-victory { background: #112d5ead; }
#screen-victory .victory-card {
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
  gap: 16px;
  text-align: left;
  width: min(100%, 740px);
  max-width: min(100%, 660px);
  max-height: 100%;
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(145deg, #edfaff 15%, #c3e9fd 68%, #a0d7fd);
  box-shadow: 0 5px 0 #578fc7, 0 14px 37px #0d2a5f93;
}
.victory-stage {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  min-height: 0;
  height: clamp(180px, 43vh, 302px);
  overflow: hidden;
  border-radius: 9px;
  background: radial-gradient(ellipse at 50% 70%, #d5faff 0 15%, #76beef 58%, #487dce);
}
.victory-stage::before {
  position: absolute;
  inset: auto 13% 13%;
  height: 18%;
  z-index: -1;
  border: 2px solid #ecfdff;
  border-radius: 50%;
  box-shadow: inset 0 0 18px #e1ffff, 0 0 22px #d4ffff;
  content: "";
}
.victory-medal { position: absolute; top: 9px; left: 11px; color: #fff0a5; text-shadow: 0 2px #986c2a; font-size: 24px; }
#victory-portrait {
  width: 86%;
  height: 100%;
  min-height: 0;
  padding: 8px 2px 1px;
  object-fit: contain;
  filter: drop-shadow(0 7px 7px #194b8a61);
}
#win-form { margin: 5px 0 9px; color: #183f77; font-size: 12px; font-weight: 850; }
.victory-story { align-self: center; min-width: 0; }
#screen-victory .game-title { color: #164279; line-height: 1.08; margin-bottom: 8px; }
#screen-victory .stats-row { margin: 8px 0; text-align: center; }
#screen-victory .stat-box { min-width: 0; padding: 6px 3px; border-radius: 7px; }
#screen-victory .stat-box .num { font-size: 19px; }
#screen-victory .stat-box .lbl { font-size: 10px; }
.victory-message {
  padding: 8px 10px;
  border-left: 3px solid #407ed0;
  border-radius: 4px;
  background: #f0fbffab;
  color: #204b84;
}
#victory-typed {
  min-height: 3.9em;
  margin: 0;
  white-space: pre-line;
  line-height: 1.3;
  font: 750 14px/1.3 system-ui, sans-serif;
}
#victory-typed.is-typing::after { content: "▏"; color: #c44783; animation: victory-caret .8s steps(1, end) infinite; }
@keyframes victory-caret { 50% { opacity: 0; } }
#screen-victory .result-actions { justify-content: flex-start; margin-top: 10px; }
@media (orientation: landscape) and (max-height: 360px) {
  #screen-victory .victory-card { padding: 11px; gap: 10px; }
  #screen-victory .result-actions { margin-top: 7px; }
}
@media (orientation: portrait) {
  #screen-victory .victory-card { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .victory-stage { height: clamp(128px, 29vh, 205px); }
  #screen-victory .result-actions { justify-content: center; }
}

.lobby-sheet {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 10px;
  background: #284d8c67;
  backdrop-filter: blur(5px);
}
.lobby-sheet[hidden] { display: none; }
.lobby-sheet .lobby-deck { color: #214778; padding: clamp(9px, 2vh, 20px); width: min(96%, 660px); gap: 7px; box-shadow: 0 7px 0 #455fa9, 10px 17px 29px #17356d91, inset 0 1px 0 #fff; }
.sheet-top { display: flex; justify-content: space-between; align-items: center; }
.sheet-top h2 { margin: 0; font-size: clamp(21px, 4vh, 34px); font-style: italic; font-weight: 950; }
.sheet-close { flex: 0 0 31px; }
.lobby-sheet .cat-roster { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 11px; padding-inline: 4px; }
.lobby-sheet .cat-card { transform: skewX(-5deg); background: linear-gradient(160deg, #559be2, #234d98); }
.lobby-sheet .cat-card[aria-pressed="true"] { transform: skewX(-5deg) translateY(-2px); }
.lobby-sheet .card-art img, .cat-podium img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(2px 3px 2px #315c955e); }
.lobby-sheet .card-art img { position: relative; transform: skewX(5deg); padding: 2px 4px; }
.lobby-sheet .cat-card-caption strong { transform: skewX(5deg); }
.lobby-sheet .form-card { transform: skewX(-4deg); box-shadow: 3px 4px 0 #5594d6; }
.lobby-sheet .form-art canvas { transform: skewX(4deg); }
.lobby-sheet .deck-footer { justify-content: flex-end; }
.lobby-sheet .deck-note { margin: 1px 0; }

.lobby-ranking-preview {
  position: absolute;
  right: 1%;
  bottom: 6%;
  z-index: 2;
  display: grid;
  gap: 7px;
  width: clamp(155px, 13.5vw, 235px);
  padding: 8px 10px 12px;
  border: 1px solid #b7ecff;
  border-radius: 13px 18px 13px 13px;
  color: #f4fcff;
  background: linear-gradient(147deg, #3f7ccbe8, #213d80f2 75%);
  box-shadow: 0 4px #143366b5, 0 0 18px #b8f4ff68, inset 0 1px #ddf7ff92;
  text-align: left;
  cursor: pointer;
}
.lobby-ranking-preview:hover { box-shadow: 0 4px #143366b5, 0 0 24px #b8f4ffb8, inset 0 1px #ddf7ff92; }
.ranking-preview-heading { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 7px; padding-bottom: 5px; border-bottom: 1px solid #a5dcff62; }
.ranking-preview-heading .ui-icon { width: 22px; height: 22px; }
.ranking-preview-heading strong { font-style: italic; font-size: clamp(15px, 1.22vw, 23px); }
.ranking-preview-heading > span { font-size: 23px; line-height: 1; }
#ranking-preview-results { display: grid; gap: 3px; font-size: clamp(11px, 1vw, 15px); color: #e7f6ff; }
.ranking-preview-row { display: grid; grid-template-columns: 27px 1fr auto; gap: 6px; align-items: center; font-variant-numeric: tabular-nums; }
.ranking-preview-row strong { color: #fff2a6; }

.lobby[data-panel="leaderboard"] .lobby-sheet { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.lobby[data-panel="leaderboard"] .lobby-deck {
  place-self: center;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(100%, 760px);
  height: min(calc(100dvh - 20px), 655px);
  color: #f4fbff;
  background: radial-gradient(ellipse at 28% 0%, #3866a7, transparent 64%), linear-gradient(149deg, #253f7c, #152b57);
  box-shadow: 0 5px #142e66, 0 15px 34px #0a1e4d9f, inset 0 1px #c9edff90;
}
.lobby[data-panel="leaderboard"] .sheet-top h2 { text-shadow: 0 3px #20396d; }
.lobby[data-panel="leaderboard"] .deck-footer { display: none; }
html:has(.lobby[data-panel="leaderboard"]),
body:has(.lobby[data-panel="leaderboard"]),
#game-wrapper:has(.lobby[data-panel="leaderboard"]) { touch-action: pan-y; }
#leaderboard:not([hidden]) { display: grid; height: 100%; grid-template-rows: auto minmax(0, 1fr) auto; gap: 6px; }
.ranking-summary { display: flex; justify-content: space-between; gap: 8px; color: #c7e4ff; font-size: 12px; }
.ranking-scroll {
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-color: #79adf1 #173468;
  border: 1px solid #a6d5ff59;
  border-radius: 10px;
  background: #142b56;
}
.ranking-table { width: 100%; border-spacing: 0; text-align: left; font-size: clamp(11px, 2.9vw, 14px); font-variant-numeric: tabular-nums; }
.ranking-table th { position: sticky; top: 0; z-index: 1; padding: 8px 5px; color: #cfe7ff; background: #213c71; white-space: nowrap; }
.ranking-table td { padding: 4px 5px; border-top: 1px solid #b3d5ff20; white-space: nowrap; }
.ranking-table :is(th, td):first-child { padding-left: clamp(5px, 1.3vw, 15px); width: 13%; }
.ranking-table td:nth-child(3) { color: #ffe59b; font-weight: 800; }
.ranking-table tr.ranking-featured { background: linear-gradient(90deg, #739cdb3b, #304d8824); }
.ranking-table tbody tr:nth-child(n+7):nth-child(odd) { background: #c6e4ff09; }
.ranking-empty { margin: 18px 10px; text-align: center; color: #c7e4ff; font-size: 13px; }
.ranking-pages { display: flex; align-items: center; justify-content: center; gap: 12px; color: #d6ebff; font-size: 12px; }
.ranking-pages button:disabled { opacity: .45; cursor: default; }
.ranking-medal {
  display: inline-grid;
  place-items: center;
  position: relative;
  isolation: isolate;
  width: 37px;
  height: 37px;
  color: #e3efff;
  font-size: 13px;
  font-weight: 900;
}
.ranking-medal[data-place] {
  color: #241e47;
  font-size: 17px;
  text-shadow: 0 1px #ffffffb0;
  filter: drop-shadow(0 0 5px var(--glow));
}
.ranking-medal::before, .ranking-medal[data-place]::after { position: absolute; z-index: -1; content: ""; }
.ranking-medal[data-place]::before {
  inset: 2px;
  background: linear-gradient(142deg, #fff 4%, var(--light) 33%, var(--metal) 64%, var(--light) 90%);
  clip-path: var(--crest);
}
.ranking-medal[data-place]::after {
  inset: 8px;
  border: 1px solid #fff9dfce;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 23%, #fff9, transparent 75%);
}
.ranking-medal[data-place="1"] { --light: #fff7a8; --metal: #eba12c; --glow: #ffbd3c; --crest: polygon(50% 0, 64% 25%, 97% 11%, 83% 70%, 67% 94%, 33% 94%, 17% 70%, 3% 11%, 36% 25%); }
.ranking-medal[data-place="2"] { --light: #ecfdff; --metal: #7aabd4; --glow: #b9edff; --crest: polygon(50% 0, 80% 20%, 100% 50%, 80% 80%, 50% 100%, 20% 80%, 0 50%, 20% 20%); }
.ranking-medal[data-place="3"] { --light: #ffd4a3; --metal: #dc7c56; --glow: #ff9675; --crest: polygon(26% 7%, 74% 7%, 100% 31%, 82% 82%, 50% 100%, 18% 82%, 0 31%); }
.ranking-medal[data-place="4"] { --light: #f3d7ff; --metal: #ac7af0; --glow: #bc93ff; --crest: polygon(50% 0, 67% 20%, 95% 23%, 87% 49%, 97% 75%, 68% 79%, 50% 100%, 32% 79%, 3% 75%, 13% 49%, 5% 23%, 33% 20%); }
.ranking-medal[data-place="5"] { --light: #bdffee; --metal: #60c7a5; --glow: #7bffd5; --crest: polygon(50% 1%, 99% 30%, 81% 82%, 50% 99%, 19% 82%, 1% 30%); }
.ranking-medal[data-place="6"] { --light: #ffcbea; --metal: #e77bab; --glow: #ff9bcf; --crest: polygon(50% 0, 66% 14%, 86% 14%, 86% 34%, 100% 50%, 86% 66%, 86% 86%, 66% 86%, 50% 100%, 34% 86%, 14% 86%, 14% 66%, 0 50%, 14% 34%, 14% 14%, 34% 14%); }
.ranking-preview-row .ranking-medal { width: 26px; height: 26px; font-size: 12px; }
.ranking-preview-row .ranking-medal::after { inset: 6px; }
@media (max-width: 1050px), (max-height: 590px), (orientation: portrait) { .lobby-ranking-preview { display: none; } }

#skill-signature { --skill-color: #ffbf7d; }
#skill-signature.ready { background: radial-gradient(circle at 50% 27%, #fffbdd, #ffc673 51%, #da6797); color: #473465; }
#skill-signature .skill-name { white-space: nowrap; }
@media (pointer: coarse) { .skill-key { display: none; } }
@media (orientation: landscape) and (max-height: 550px) {
  .mobile-lobby { gap: 5px 4vw; }
  .player-profile { padding: 2px 12px 2px 3px; }
  .player-profile img { width: 37px; }
  .mode-cards { padding-block: 3%; }
  .mode-label { padding-block: 6px; }
  .lobby-sheet .card-art { height: clamp(25px, 10vh, 52px); }
  #cat-desc { font-size: 10px; }
  #skill-bar { gap: 6px; }
  .skill-btn { width: clamp(43px, 14vh, 64px); height: clamp(43px, 14vh, 64px); }
  .lobby-wordmark { font-size: clamp(24px, 5.4vw, 43px); }
}
@media (orientation: portrait) {
  .mobile-lobby {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(105px, 1.03fr) minmax(102px, .9fr) auto;
    grid-template-areas: "top" "hero" "modes" "foot";
    padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
    gap: 7px;
  }
  .showcase-orbit { left: 13%; right: 13%; }
  .showcase-caption { left: 4%; }
  .showcase-pet img { max-height: 100%; max-width: 90%; }
  .mode-cards { padding: 12px 5% 5px; gap: 8px; }
  .mode-play { --card-tilt: -7deg; }
  .mobile-lobby .lobby-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); row-gap: 6px; }
  .lobby-wordmark { grid-column: 1 / -1; grid-row: 2; justify-self: center; font-size: clamp(28px, 8vw, 46px); }
  .lobby-status { grid-column: 2; grid-row: 1; }
  .lobby-footer { flex-direction: column; align-items: stretch; gap: 5px; }
  .lobby-dispatch { padding: 3px 8px; }
  .lobby-dispatch .ui-icon { width: 17px; height: 17px; }
  .lobby-nav { flex: 1; justify-content: space-around; }
  .lobby-nav button { flex: 1; min-width: 0; padding-inline: 3px; }
  #skill-bar { gap: 5px; }
  .skill-btn { width: clamp(41px, 13vw, 56px); height: clamp(41px, 13vw, 56px); }
  #joystick-zone { width: clamp(75px, 24vw, 101px); height: clamp(75px, 24vw, 101px); }
}
@media (max-width: 360px) {
  .lobby-status .online-pill { padding: 5px 8px; }
}

#hud.night-controls { align-items: flex-end; }
.night-controls .hud-top { justify-content: flex-end; }
.night-controls :is(.hud-sub, .hud-top > :not(.hud-group:last-child), .hud-group:last-child .pill, .touch-hint) { display: none; }
#night-hud {
  position: absolute;
  z-index: 13;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 28px);
  padding: 6px 16px 8px;
  border: 1px solid #8adcf3a1;
  border-radius: 11px;
  background: #071b36eb;
  box-shadow: 0 0 23px #328bcc41;
  color: #e2f9ff;
  text-align: center;
  pointer-events: none;
  font-size: clamp(11px, 1.55vw, 15px);
}
#night-timer { display: block; color: #8effe9; font-size: clamp(19px, 3.8vh, 30px); }
#night-hud.night-warning { border-color: #ffca8d; box-shadow: 0 0 30px #f6a05475; }
.night-warning #night-timer, .night-warning #night-hint { color: #ffdfb5; }
@media (orientation: portrait) {
  #night-hud { top: calc(max(12px, env(safe-area-inset-top)) + 39px); }
}
