/* 选景和联机大厅是项目扩展。定稿切片使用同一张 1672 × 941 画布的坐标。 */
#sceneSelect[hidden] { display: none !important; }
#sceneSelect {
  container: menu-shell / size;
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  overflow: auto;
  background: #0c1914;
  color: #fff5dc;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}
.menu-home {
  position: relative;
  container-type: inline-size;
  width: min(100%, 177.68dvh);
  aspect-ratio: 1672 / 941;
  margin: auto;
  flex: none;
}
.menu-home { background: url(home-back.jpg) center / 100% 100%; }
.menu-nav img, #localPanel .scene-heading img, #localPanel .scene-cards img, .room-heading img {
  display: block;
  width: 100%;
  height: 100%;
}
#localPanel button, .menu-nav button {
  display: block;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.menu-nav button:hover, #localPanel button:hover, #lobbyRoom button:hover { filter: brightness(1.12); }
.menu-nav button:active, #localPanel button:active, #lobbyRoom button:active {
  filter: brightness(.96);
  transform: translateY(1px);
}
.menu-nav button:disabled, #localPanel button:disabled, #lobbyRoom button:disabled {
  filter: none;
  transform: none;
  cursor: default;
}
#sceneSelect :is(button,a):focus-visible, .ss-tier input:focus-visible + span {
  outline: 3px solid #ffe39a;
  outline-offset: -3px;
}
.menu-nav { position: absolute; inset: 0 auto 0 0; width: 21.17%; }
/* The shared artwork contains the highlight from the original menu mockup.
   Cover it behind the interactive rows, where the inactive tile is transparent. */
.menu-nav::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(100deg, #22382c, #172e24 48%, #233d31);
  mask-image: linear-gradient(transparent 14.6%, #000 18%, #000 67%, transparent 76%);
}

.menu-brand { position: absolute; top: 0; max-height: 14.56%; }
.menu-nav :is(button,a) { position: absolute; left: 2.82%; width: 95.2%; }
.menu-nav [data-solo] { top: 18.17%; height: 12.97%; }
.menu-nav [data-streamer] { top: 31.14%; height: 12%; }
.menu-nav [data-online] { top: 43.14%; height: 11.9%; }
.menu-nav [data-puzzles] { top: 55.04%; height: 11.8%; }
.menu-nav .menu-avatar {
  top: 80%;
  left: 4%;
  width: 92%;
  height: auto;
  min-height: 9.5%;
  display: flex;
  align-items: center;
  gap: 8%;
  padding: 4% 5%;
  color: #f4ead3;
  background: rgba(8, 20, 18, .55);
  border: 1px solid rgba(210, 178, 104, .22);
  border-radius: 8px;
  transition: filter .12s ease, border-color .12s ease, background-color .12s ease, transform .08s ease;
}
.menu-nav .menu-avatar img {
  width: 22%;
  aspect-ratio: 1;
  height: auto;
  border-radius: 3px;
  object-fit: cover;
  border: 1px solid rgba(243, 210, 122, .55);
}
.menu-nav .menu-avatar-text { display: grid; gap: .15em; text-align: left; min-width: 0; }
.menu-nav .menu-avatar-name {
  font-size: 1.7cqw;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-nav .menu-avatar small { font-size: 1.25cqw; color: #c9d4cc; }
.menu-nav .menu-avatar:hover { filter: brightness(1.12); border-color: rgba(232, 198, 112, .7); }
.menu-nav .menu-avatar:active { transform: translateY(1px); filter: brightness(.96); }
.scene-heading { position: absolute; inset: 0 0 auto 23.03%; height: 15.41%; margin: 0; }
.menu-difficulty, .streamer-note {
  position: absolute;
  inset: 15.41% 4% auto 23.03%;
  height: 6.17%;
  display: flex;
  align-items: center;
  gap: .5%;
}
.streamer-note { margin: 0; padding-left: 2%; font-size: 1.8cqw; }
.menu-difficulty .tier-caption {
  display: block;
  width: 18.7%;
  height: 100%;
  object-fit: contain;
  object-position: left center;
}
.ss-tier-list { display: flex; flex: 1; height: 100%; background: url(tier-bar.jpg) center / 100% 100%; }
.ss-tier { flex: 1; position: relative; display: grid; padding: .25cqw .1cqw; cursor: pointer; }
.ss-tier input { position: absolute; opacity: 0; }
.ss-tier span { display: grid; place-items: center; font-size: 1.55cqw; font-weight: bold; }
.ss-tier input:checked + span { color: #201a10; background: url(tier-active.jpg) center / 100% 100%; }
.scene-picker {
  position: absolute;
  inset: 24.34% 1.5% .85% 23.03%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(6px, .65cqw, 11px);
}
.scene-cards {
  display: grid;
  grid-template-columns: 611fr 639fr;
  grid-template-rows: minmax(0, 326fr) minmax(0, 321fr);
  gap: 1.5% 1%;
}
.scene-choice {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  border-radius: clamp(6px, .85cqw, 15px);
  cursor: pointer;
}
.scene-choice input { position: absolute; opacity: 0; }
.scene-choice img { border-radius: inherit; }
.scene-choice:hover img { filter: brightness(1.09); }
.scene-choice:has(input:checked)::after {
  content: "";
  position: absolute;
  inset: 0;
  border: clamp(2px, .24cqw, 4px) solid #ffe0a0;
  border-radius: inherit;
  box-shadow: 0 0 12px #ffc35780, inset 0 0 8px #ffc35759;
  pointer-events: none;
}
.scene-choice:has(input:focus-visible) { outline: 2px dashed #fff5dc; outline-offset: 2px; }
.scene-selected {
  position: absolute;
  top: clamp(7px, .8cqw, 14px);
  right: clamp(7px, .8cqw, 14px);
  display: none;
  padding: .25em .55em;
  border-radius: .4em;
  background: #f5cb76;
  color: #21180c;
  font-size: clamp(12px, 1.45cqw, 24px);
  font-weight: 700;
  line-height: 1.15;
}
.scene-choice input:checked ~ .scene-selected { display: block; }
.scene-actions { display: flex; justify-content: flex-end; }
#localPanel .scene-start {
  min-width: clamp(118px, 17cqw, 284px);
  min-height: clamp(32px, 3.15cqw, 54px);
  padding: 0 1em;
  border: 1px solid #ffe4a4;
  border-radius: clamp(6px, .75cqw, 13px);
  background: linear-gradient(#f4d48a, #cf9e48);
  color: #21180c;
  font: inherit;
  font-size: clamp(14px, 1.7cqw, 29px);
  font-weight: 700;
  line-height: 1.15;
}
#sceneSelect .scene-start:focus-visible { outline-offset: 2px; }
#sceneSelect [hidden],
#sceneSelect.loading :is(.menu-home,#lobby) { display: none; }
#sceneSelect.loading { z-index: 200; }
#sceneSelect .ss-loading { margin: auto; }
.content-panel { position: absolute; inset: 0 0 0 21.17%; background: #102019; overflow: auto; }
#puzzlePanel { position: absolute; inset: 0; }
#lobby { box-sizing: border-box; margin: auto; padding: 20px; }
#lobby:not([hidden]):has(#lobbyMain:not([hidden]) #lobbyRoom:not([hidden])) {
  display: block;
  padding: 0;
  position: relative; container-type: inline-size; width: 100%; height: 100%;
  background: url(room-corner.png) left top / 20.335% 12.752% no-repeat,
    url(room-back.jpg) center / 100% 100% no-repeat;
}
/* 房间内控件是绝对定位；让主层铺满，避免容器高度为 0 导致点击命中失败。 */
#lobby:not([hidden]):has(#lobbyMain:not([hidden]) #lobbyRoom:not([hidden])) > #lobbyMain,
#lobbyRoom:not([hidden]) {
  position: absolute;
  inset: 0;
}
#lobby:not([hidden]):has(#lobbyMain:not([hidden]) #lobbyRoom:not([hidden])) > :is(#lobbyStatus,#lobbyTitle) {
  position: absolute;
  left: 3.4%;
  top: 9%;
  margin: 0;
  color: #eee3ce;
  font-size: max(12px,1cqw);
}
#lobby:not([hidden]):has(#lobbyMain:not([hidden]) #lobbyRoom:not([hidden])) > #lobbyStatus {
  width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
}
#lobbyBanner:not([hidden]) { position: relative; z-index: 1; background: #321c17; padding: 6px; }
.room-heading { position: absolute; inset: 6.59% 26.85% auto 26.91%; height: 14.45%; margin: 0; }
.lobby-seat {
  position: absolute; top: 41.875%; width: 28.65%;
  aspect-ratio: 479 / 234;
  translate: 0 -50%;
  background-size: 100% 100%;
}
.lobby-seat[data-seat="0"] { left: 12.08%; background-image: url(seat-1.jpg); }
.lobby-seat[data-seat="1"] { left: 59.21%; background-image: url(seat-2.jpg); }
.lobby-seat-avatar {
  position: absolute; left: 6.4%; top: 51.3%; width: 34%;
  height: auto; aspect-ratio: 1; box-sizing: border-box;
  translate: 0 -50%;
  border-radius: 3px; object-fit: cover; border: 1px solid rgba(243, 210, 122, .45);
  background: #1a2a22;
}
.lobby-seat-avatar[hidden] { display: none; }
.lobby-seat-label, .lobby-seat-name, .lobby-seat-badge { position: absolute; left: 51%; }
.lobby-seat-label { top: 11%; font-size: 1.65cqw; }
.lobby-seat-name { top: 28%; font-size: 2.6cqw; font-weight: bold; line-height: 1.2;
  max-width: 44%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.is-empty .lobby-seat-name { top: 34%; font-size: 1.9cqw; }
.is-empty .lobby-seat-avatar { display: none; }
.lobby-seat-badge { top: 62%; height: 22%; width: 33%; background: url(unready.jpg) center / 100% 100%; color: transparent; }
.lobby-seat-badge.is-ready { width: 36%; background-image: url(ready.jpg); }
.is-empty .lobby-seat-badge { background: none; color: #c4c6b8; font-size: 1.6cqw; }
.lobby-vs { position: absolute; clip-path: inset(50%); }
#lobbyRoomMeta { position: absolute; inset: 79.4% 10% auto; font-size: 2cqw; text-align: center; }
#lobbyRoom button {
  position: absolute; box-sizing: border-box; border: 0; border-radius: 0; padding: 0;
  background-size: 100% 100%; background-color: transparent;
}
#lobbyRoom #lobbyReady {
  inset: 85.76% auto auto 36.24%; width: 27.51%; height: 9.57%;
  background-image: url(gold.jpg); font-size: 3.2cqw; color: #171407;
}
#lobbyRoom #lobbyLeave {
  inset: 2.87% 1.5% auto auto; width: 8.37%; height: 6.27%;
  background-image: url(leave.jpg); color: transparent;
}
@container menu-shell (max-aspect-ratio: 1/1) {
  .menu-nav::before { display: none; }
  .menu-home {
    width: 100%; aspect-ratio: auto; box-sizing: border-box;
  }
  .menu-home { padding: 12px; background: #10231b; }
  .menu-nav { position: static; width: auto; display: grid; grid-template-columns: repeat(2,1fr); gap: 4px; }
  .menu-nav .menu-brand { position: static; grid-column: 1/-1; width: 150px; height: auto; max-height: none; }
  .menu-nav :is(button,a) { position: static; width: 100%; height: auto; aspect-ratio: 3.1; }
  .scene-heading { position: static; height: auto; margin: 12px 0; }
  .menu-difficulty, .streamer-note { position: static; height: auto; display: block; }
  .menu-difficulty .tier-caption { width: 120px; height: auto; }
  .ss-tier-list { flex-wrap: wrap; background: #193127; }
  .ss-tier { min-width: 21%; height: 40px; }
  .ss-tier span, .streamer-note { font-size: 16px; }
  .scene-picker { position: static; grid-template-rows: auto auto; margin-top: 12px; gap: 8px; }
  .scene-cards { grid-template-rows: auto; gap: 8px; }
  .scene-choice { aspect-ratio: 1.9; }
  .scene-actions {
    position: sticky;
    bottom: -10px;
    padding: 6px 0 max(10px, env(safe-area-inset-bottom));
    background: #10231b;
  }
  #localPanel .scene-start { min-height: 44px; }
  #lobby:not([hidden]):has(#lobbyMain:not([hidden]) #lobbyRoom:not([hidden])) { min-height: 100%; height: auto; padding: 18px; background: #14241b; }
  #lobby:not([hidden]):has(#lobbyMain:not([hidden]) #lobbyRoom:not([hidden])) > #lobbyTitle { position: static; font-size: 16px; }
  .room-heading { position: static; height: auto; margin: 24px 0 16px; }
  .lobby-seats { display: grid; gap: 10px; }
  .lobby-seat { position: relative; inset: auto !important; width: 100%; translate: none; }
  .lobby-seat-label, .is-empty .lobby-seat-badge { font-size: 4.6cqw; }
  .lobby-seat-name { font-size: 9cqw; }
  .is-empty .lobby-seat-name { font-size: 6cqw; }
  #lobbyRoomMeta { position: static; padding: 18px 0 10px; font-size: 16px; }
  #lobbyRoom .lobby-actions { justify-content: center; }
  #lobbyRoom #lobbyReady { position: static; width: 57%; height: 46px; font-size: 24px; }
  #lobbyRoom #lobbyLeave { top: 9px; right: 12px; width: 95px; height: 38px; }
}

/* 联机选桌定稿切图。桌牌文字取自实时列表，桌号对应服务端的固定桌位。 */
#lobby:not([hidden]):has(#lobbyMain:not([hidden]) #lobbyBrowse:not([hidden])) {
  position: relative;
  display: block;
  padding: 0;
  width: 100%;
  height: 100%;
  container-type: inline-size;
}
#lobby:not([hidden]):has(#lobbyMain:not([hidden]) #lobbyBrowse:not([hidden])) > :is(#lobbyTitle,#lobbyStatus) {
  position: absolute;
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
}
#lobby:not([hidden]):has(#lobbyBrowse:not([hidden])) > #lobbyBanner:not([hidden]) {
  position: absolute;
  inset: 15% auto auto 50%;
  transform: translateX(-50%);
}
#lobbyBrowse {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(48px,104fr) 55fr minmax(0,684fr) 98fr;
  min-height: 0;
  color: #fff0c2;
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
}
#lobbyBrowse[hidden] { display: none; }
#lobbyBrowse button {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}
#lobbyBrowse button:hover { transform: none; }
#lobbyBrowse button:enabled:hover { filter: brightness(1.13); }
#lobbyBrowse button:disabled { cursor: wait; }
#lobbyBrowse img { display: block; width: 100%; height: 100%; }
/* The web lobby uses a single full-width surface for the title and its gold divider. */
.table-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(3px, .45cqw, 7px);
  padding: 3px 8px 6px;
  background: #102019 url(tables/toolbar.jpg) center / 100% 100%;
  color: #fff2d8;
  text-shadow: 0 1px 3px #08140f;
}
.table-title {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.3cqw, 20px);
  margin: 0;
  font-size: clamp(18px, 3.1cqw, 45px);
  line-height: 1.08;
}
.table-title::before, .table-title::after {
  content: "";
  width: clamp(18px, 5cqw, 80px);
  height: 1px;
  background: linear-gradient(90deg, transparent, #e2c78a);
}
.table-title::after { transform: scaleX(-1); }
.table-subtitle {
  margin: 0;
  font-size: clamp(11px, 1.55cqw, 22px);
  line-height: 1.2;
}

.table-tools, .table-dock, .table-zoom, #tableFind { display: flex; align-items: center; }
.table-tools, .table-dock { padding-inline: 2%; gap: 1.5%; background-size: 100% 100%; }
.table-tools { background-image: url(tables/toolbar.jpg); font-size: 1.65cqw; }
#tableRange { border-left: 1px solid #b9a179; padding-left: 2.4%; }
#tableFind { height: 100%; margin-left: auto; gap: .4cqw; }
#tableNumber {
  box-sizing: border-box; width: 16cqw; height: 90%; padding: 0 1em 0 20%;
  font: inherit; color: inherit; border: 0; background: url(tables/search.jpg) center / 100% 100%;
}
#tableNumber::placeholder { color: #d8cdb5; }
#tableFind button { width: 6cqw; height: 90%; }
.table-dock { background-image: url(tables/dock.jpg); }
#lobbyQuick { width: 16.2%; height: 78.6%; }
#lobbyRefresh { width: 11.5%; height: 78.6%; }
.table-zoom {
  height: 100%; gap: 1cqw; margin-left: auto;
  font-size: 1.65cqw; font-weight: 600; white-space: nowrap;
}
.table-zoom button { width: 3.5cqw; height: 56%; }
/* 轨道视觉仍是细条，控件本体加高保证拇指可拖（原先 height:7px 几乎点不中）。 */
#tableZoom {
  -webkit-appearance: none;
  appearance: none;
  width: 16cqw;
  height: 28px;
  margin: 0;
  background: transparent;
  accent-color: #d3ab58;
  cursor: pointer;
  touch-action: manipulation;
}
#tableZoom::-webkit-slider-runnable-track {
  height: 7px;
  border-radius: 4px;
  background: #9a8e66;
}
#tableZoom::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: max(22px, 2.4cqw);
  height: max(22px, 2.4cqw);
  margin-top: calc((7px - max(22px, 2.4cqw)) / 2);
  border: 0;
  border-radius: 50%;
  background: url(tables/slider-thumb.jpg) center / cover;
  box-shadow: 0 0 0 6px transparent; /* 扩大触控热区，不改变外观 */
}
#tableZoom::-moz-range-track {
  height: 7px;
  border: 0;
  border-radius: 4px;
  background: #9a8e66;
}
#tableZoom::-moz-range-thumb {
  width: max(22px, 2.4cqw);
  height: max(22px, 2.4cqw);
  border: 0;
  border-radius: 50%;
  background: url(tables/slider-thumb.jpg) center / cover;
}
#zoomValue { min-width: 3.6em; text-align: right; font-variant-numeric: tabular-nums; }
#lobbyBrowse .table-zoom button:disabled { cursor: default; opacity: .55; }
#lobbyRooms {
  display: grid;
  margin: 0;
  padding: 0 1.8%;
  list-style: none;
  grid-template-columns: repeat(var(--columns,4),minmax(0,1fr));
  grid-auto-rows: var(--row,33.333%);
  align-content: start;
  min-height: 0;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-color: #ba9659 #1c1a11;
  background: #482a16 url(tables/floor.jpg) center / 140px;
}
#lobbyRooms .table-choice {
  display: block; width: 100%; height: 100%; position: relative;
  background: url(tables/club-table.png) center / 100% 100%;
  font: 600 var(--label-size,18px)/1 "Songti SC","Noto Serif CJK SC",serif;
  color: #fff0c2;
}
#lobbyRooms .table-choice { container-type: inline-size; }
.table-seat {
  position: absolute;
  top: 86.35%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 14.5%;
  max-width: 52px;
  aspect-ratio: 1;
  box-sizing: border-box;
  border: 1px solid #d4ac61;
  border-radius: 50%;
  background: #192c23;
  color: #dcc292;
  overflow: hidden;
  box-shadow: 0 2px 5px #000b;
  pointer-events: none;
}
.table-seat[data-seat="0"] { right: 77.8%; }
.table-seat[data-seat="1"] { left: 79.8%; }
.table-seat[data-occupied="false"] {
  border-color: #a68c626e;
  background: #151d19;
  color: #d1c19b;
}
.table-seat[data-occupied="false"]::before { content: "?"; font-size: 8cqw; }
.table-seat[data-occupied="true"]:has(img[hidden])::before { content: "●"; }
.table-seat img { object-fit: cover; }
.table-choice-label {
  font-size: min(var(--label-size, 18px), 5.5cqw);
  /* Bounds of the nameplate in club-table.png, scaled with the card. */
  position: absolute; inset: 77% 22.4% 4.3% 24.4%;
  display: flex; align-items: center; justify-content: center;
  white-space: nowrap; text-align: center;
}
#lobbyRooms [data-status="1/2 加入"] button { color: #ffcf58; }
#lobbyRooms .table-choice:disabled { cursor: default; color: #b3cc9b; }
#lobbyRooms .located .table-choice { outline: 3px solid #ffe298; outline-offset: -4px; }
@container menu-shell (max-aspect-ratio: 1/1) {

  #lobbyBrowse { grid-template-rows: 66px 52px minmax(0,1fr) auto; }

  .table-tools { font-size: 14px; gap: 2%; }
  #tableFind { gap: 2px; }
  #tableNumber { width: 26cqw; height: 36px; padding-left: 6cqw; }
  #tableFind button { width: 12cqw; height: 36px; }
  .table-dock { justify-content: center; flex-wrap: wrap; padding: 5px 2% max(5px,env(safe-area-inset-bottom)); }
  #lobbyQuick { width: 145px; height: 42px; }
  #lobbyRefresh { width: 106px; height: 42px; }
  .table-zoom { height: auto; flex-basis: 100%; justify-content: center; margin: 4px 0; gap: 2%; font-size: 15px; }
  .table-zoom button { width: 40px; height: 40px; }
  #tableZoom { width: 32cqw; }
}

/* 窄屏也沿用左侧选玩法、右侧操作的布局。 */
@container menu-shell (max-aspect-ratio: 1/1) {
  .menu-home {
    display: grid; grid-template-columns: clamp(68px,19vw,110px) minmax(0,1fr);
    height: 100dvh; padding: 0; margin: 0;
  }
  .menu-nav { display: flex; flex-direction: column; align-items: stretch; gap: 4px; background: #152b23; }
  .menu-nav .menu-brand { width: 100%; margin: 12px 0; }
  .menu-nav button { text-align: center; height: auto; aspect-ratio: auto; padding: 9px 2px; color: #f4ead3; position: static; }
  .menu-nav button img { width: 44px; height: 38px; margin: auto; object-fit: cover; object-position: 9% center; }
  .menu-nav button .mobile-label { display: block; margin-top: 4px; font-size: 13px; }
  .menu-nav button[aria-pressed="true"] { background: #504b32; }
  #localPanel { overflow-y: auto; padding: 10px; }
  .scene-cards { grid-template-columns: 1fr; }
  .content-panel { grid-column: 2; position: relative; inset: auto; }
  .table-tools { flex-wrap: wrap; justify-content: center; font-size: 13px; }
  #tableFind { justify-content: center; width: 100%; height: 32px; margin: 0; }
  #tableFind button, #tableNumber { height: 30px; }
  #tableNumber { width: 50cqw; padding-left: 10cqw; }
  #lobbyBrowse { grid-template-rows: 52px 56px minmax(0,1fr) auto; }
  #lobbyQuick { width: 45%; }
  #lobbyRefresh { width: 35%; }
  .table-zoom { gap: 1%; font-size: 12px; }
  .table-zoom button { width: 28px; height: 32px; }
  #tableZoom { width: 24cqw; }
}
.mobile-label { display: none; }

/* 球手档案 / 战绩 / 回放库 */
#profilePanel, #recordPanel, #replayPanel { position: absolute; inset: 0; }
#profilePanel, #recordPanel {
  background: linear-gradient(#09151166, #101a13aa), url(../previews/bar.jpg) center / cover;
  color: #27180d;
}
.roster-title {
  margin: 0;
  padding-top: 8%;
  color: #fff0d2;
  text-align: center;
  font: 700 clamp(24px, 3.3cqw, 54px)/1.2 "Songti SC", serif;
  text-shadow: 0 2px 5px #000;
}
.roster-book {
  position: absolute;
  inset: 22% 10% 16%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  padding: .75%;
  border: 2px solid #a4804a;
  border-radius: 16px 16px 21px 21px;
  background: linear-gradient(100deg, #2e1b12, #604225 49%, #2e1b12 51%, #49301b);
  box-shadow: 0 14px 22px #000b, inset 0 0 0 2px #3b2419;
}
.roster-page {
  min-height: 0;
  padding: 5%;
  border: 2px double #987143;
  background: linear-gradient(100deg, #c6955855, #ffebc67a 27%, #b4793655),
    #e5c596 url(profile/parchment.jpg) center / 100% 100% no-repeat;
  box-shadow: inset 0 0 16px #8a5b3f50;
}
.roster-left { border-radius: 12px 4px 5px 14px; }
.roster-right { border-radius: 4px 12px 14px 5px; }
.roster-page { min-width: 0; }
.roster-left { display: flex; flex-direction: column; align-items: center; gap: 2%; justify-content: center; }
.roster-hero {
  width: auto; height: 64%; max-width: 86%; aspect-ratio: 1; object-fit: cover;
  border-radius: 4px; border: 2px solid #9a7747;
  box-shadow: 0 8px 18px rgba(40, 24, 8, .28);
}
.record-book .roster-hero { height: 49%; }
.roster-nick, .roster-name { width: min(80%, 260px); margin: 0; font-weight: 700; }
.roster-name {
  padding: .25em .5em;
  text-align: center;
  background: linear-gradient(180deg, #e5c683, #b78b40);
  border: 1px solid #876437;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.roster-nick {
  display: grid; gap: 6px; font-size: clamp(12px, 1.4cqw, 16px); color: #4a3a22;
}
.roster-nick input {
  width: 100%; box-sizing: border-box; border: 0; border-radius: 6px;
  padding: .55em .7em; font: inherit; color: #1c160f;
  background: linear-gradient(180deg, #f0d392, #c9a24a);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 1px 2px rgba(0,0,0,.2);
}
.roster-nick input:focus-visible { outline: 2px solid #8a6a28; outline-offset: 2px; }
.roster-id, .roster-practice { margin: 0; color: #5a4a32; font-size: clamp(12px, 1.35cqw, 15px); }
.roster-stats {
  display: flex; justify-content: center; gap: 8%; margin: 2% 0 0; padding: 0; width: min(86%, 280px);
}
.roster-stats div { display: grid; gap: 4px; text-align: center; }
.roster-stats dt { margin: 0; color: #6a5a40; font-size: .9em; }
.roster-stats dd { margin: 0; font-size: 1.45em; font-weight: 700; color: #1c160f; }
.avatar-grid {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr)); gap: 2%;
  height: 100%;
}
.avatar-grid button {
  min-height: 0; position: relative; padding: 0; border-radius: 5px;
  border: 2px solid transparent; background: #2a2218; cursor: pointer;
  overflow: hidden; transition: border-color .12s ease, transform .08s ease, filter .12s ease, box-shadow .12s ease;
}
.avatar-grid button img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar-grid button:hover { filter: brightness(1.08); border-color: rgba(201, 162, 74, .55); }
.avatar-grid button:active { transform: translateY(1px) scale(.98); }
.avatar-grid button.is-selected,
.avatar-grid button[aria-pressed="true"] {
  border-color: #f0d392;
  box-shadow: 0 0 0 2px rgba(240, 211, 146, .45), 0 0 16px rgba(240, 211, 146, .35);
}
.roster-right h2 { margin: 0 0 4%; font-size: clamp(16px, 1.8cqw, 22px); color: #2a1e10; text-align: center; }
#recordList { list-style: none; margin: 0; padding: 0; overflow: auto; max-height: 100%; }
#recordList li:not(.record-empty) {
  display: grid; grid-template-columns: 5.5em 1fr auto; grid-template-rows: auto auto;
  gap: 2px 10px; padding: 3.2% 0; border-bottom: 1px solid rgba(90, 70, 40, .18);
  color: #2a1e10; font-size: clamp(12px, 1.35cqw, 15px);
}
.record-when { grid-column: 1; color: #6a5a40; }
.record-rival { grid-column: 2; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-stamp {
  grid-column: 3; grid-row: 1 / span 2; align-self: center;
  min-width: 2.4em; text-align: center; font-weight: 800; transform: rotate(-8deg);
  border: 2px solid currentColor; border-radius: 4px; padding: .15em .25em; opacity: .9;
}
.record-stamp.is-win { color: #b43a2e; }
.record-stamp.is-loss { color: #2f5f9a; }
.record-stamp.is-none { color: #6a6a6a; }
.record-reason { grid-column: 1 / 3; color: #6a5a40; font-size: .92em; }
.record-empty { padding: 12% 0; text-align: center; color: #6a5a40; }
.roster-actions {
  position: absolute; inset: calc(100% + 2cqw) 0 auto; display: flex; justify-content: center; gap: 5%;
}
.roster-actions button, .roster-link, #replayPanel .replay-state button {
  font: inherit; cursor: pointer; color: #1c160f; border: 1px solid #8a6a28;
  border-radius: 8px; padding: .55em 1.4em;
  background: linear-gradient(180deg, #f0d392, #c9a24a);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 2px 4px rgba(0,0,0,.22);
  transition: filter .12s ease, transform .08s ease;
}
.roster-actions button:hover, .roster-link:hover, #replayPanel .replay-state button:hover { filter: brightness(1.06); }
.roster-actions button:active, .roster-link:active, #replayPanel .replay-state button:active {
  transform: translateY(1px); filter: brightness(.95);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.25);
}
.roster-link {
  background: rgba(16, 32, 25, .55); color: #ffe3a5; border-color: rgba(210,178,104,.55);
}
.roster-nav {
  position: absolute; top: 3.5%; right: 4%; z-index: 2;
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px;
}
#profileStatus { position: absolute; inset: calc(100% + 6cqw) 0 auto; text-align: center; color: #ffe8b4; }

#replayPanel:not([hidden]) {
  display: flex; flex-direction: column; gap: 12px;
  padding: 6% 7%; color: #f4ead3;
  background: linear-gradient(90deg, #10251fea, #0b1817df), url(../previews/bar.jpg) center / cover;
}
#replayPanel .replay-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px;
  margin: 0; padding-bottom: 18px; border-bottom: 1px solid rgba(210, 178, 104, .55);
}
#replayPanel h1 { margin: 0; font: 700 clamp(22px, 3.4cqw, 44px)/1.2 "Songti SC", serif; font-weight: 700; color: #fff4dc; }
#replayList {
  list-style: none; margin: 0; padding: 0 2px 18px; overflow: auto; flex: 1;
  scrollbar-width: none;
}
#replayList::-webkit-scrollbar { display: none; }
#replayList li { margin: 0; }
.replay-row {
  display: grid; grid-template-columns: clamp(64px, 9cqw, 114px) minmax(0, 1fr) auto 18px;
  gap: 18px; align-items: center; padding: 16px 8px;
  color: inherit; text-decoration: none;
  border-bottom: 1px solid rgba(102, 123, 113, .45);
  border-radius: 8px; transition: background-color .12s ease, transform .08s ease;
}
.replay-row:hover { background: rgba(255, 227, 154, .06); }
.replay-row:active { transform: translateY(1px); background: rgba(255, 227, 154, .1); }
.replay-row.is-selected { outline: 1px solid rgba(210, 178, 104, .55); }
.replay-thumb {
  width: 100%; aspect-ratio: 114 / 68; object-fit: cover; border-radius: 2px;
  border: 1px solid rgba(210, 178, 104, .3);
}
.replay-main { display: grid; gap: 4px; min-width: 0; }
.replay-players { display: flex; align-items: center; gap: 6px; min-width: 0; color: #f4ead3; }
.replay-players img { width: 22px; height: 22px; border-radius: 4px; object-fit: cover; }
.replay-players span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.replay-players i { flex: none; color: #c9a24a; font-style: normal; }
.replay-main strong { font-size: 1.05em; }
.replay-main small, .replay-meta small { color: #b8c7bd; }
.replay-meta { display: flex; align-items: center; gap: 18px; text-align: right; color: #ffe3a5; }
.replay-meta small { min-width: 4em; }
.replay-chevron { color: #c9a24a; font-size: 1.4em; }
.replay-state {
  margin: 0; color: #e9dcc0; display: grid; gap: 5px; justify-items: start;
}
.replay-state p { margin: 0; }
.replay-state[data-state="empty"] [data-hint] { color: #9aab9f; }

@container menu-shell (max-aspect-ratio: 1/1) {
  .menu-nav .menu-avatar { position: static; width: 100%; height: auto; }
  .menu-nav .menu-avatar { margin-top: auto; flex-direction: column; gap: 4px; }
  .menu-nav .menu-avatar img { width: 36px; }
  .menu-nav .menu-avatar-text { width: 100%; text-align: center; }
  .menu-nav .menu-avatar-name { font-size: 13px; }
  .menu-nav .menu-avatar small { font-size: 11px; }
  .roster-nav { top: 58px; left: 10px; right: 10px; }
  .roster-link { padding-inline: .75em; }
  .roster-book {
    position: relative; inset: auto; margin: 60px 10px 10px; grid-template-columns: 1fr;
  }
  .roster-hero, .record-book .roster-hero { height: auto; width: min(60%, 150px); }
  .roster-actions { position: static; margin-top: 10px; }
  #profileStatus { position: static; text-align: center; }
  .avatar-grid { grid-template-rows: auto; }
  .avatar-grid button { aspect-ratio: 1; }
  .replay-meta { display: grid; gap: 2px; }
  .replay-row { grid-template-columns: 72px minmax(0, 1fr) auto; }
  .replay-chevron { display: none; }
}
