/* MP-ART-02 — lobby presentation only.
   The title and footer stay outside .lobby-scroll. Seat state comes from
   existing UI attributes; this stylesheet does not decide room permissions. */
#lobby {
  --lobby-ink: #fff2d8;
  --lobby-muted: #b8ccd7;
  --lobby-gold: #ffd589;
  --lobby-mint: #94e2d3;
  --lobby-coral: #f0ac99;
  --lobby-line: #849faf45;
  top: calc(var(--safe-top, 0px) + 6px);
  left: calc(50% + (var(--safe-left, 0px) - var(--safe-right, 0px)) / 2);
  width: calc(100% - var(--safe-left, 0px) - var(--safe-right, 0px) - 12px);
  max-width: 460px;
  height: calc(100dvh - var(--safe-top, 0px) - 12px);
  max-height: calc(100dvh - var(--safe-top, 0px) - 12px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border: 1px solid #d4dfdf75;
  border-top: 3px solid var(--lobby-gold);
  border-radius: 18px;
  background: linear-gradient(155deg, #182f40 0%, #102637 45%, #0c1c2b 100%);
  color: var(--lobby-ink);
  box-shadow: 0 18px 44px #020b15a6, inset 0 1px #ffffff0d;
  font-family: "Sandline UI", "Noto Sans TC", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}

#lobby .sheet-top {
  flex: 0 0 auto;
  min-width: 0;
  gap: 10px;
  padding: 15px 16px 13px;
  border-bottom: 1px solid var(--lobby-line);
  background: linear-gradient(110deg, #29445363, #1022331a);
}
#lobby .sheet-top > div { min-width: 0; }
#lobby .sheet-top .eyebrow {
  color: var(--lobby-mint);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: .12em;
}
#lobby .sheet-top h2 {
  margin: 4px 0 0;
  color: var(--lobby-ink);
  font-size: 24px;
  font-weight: 760;
  letter-spacing: .025em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
#lobby .lobby-scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 16px;
  scrollbar-color: #6a8999 #102637;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
#lobby :where(p, label, select, summary) { font-weight: 600; }
#lobby .subtle {
  margin: 5px 0 12px;
  color: var(--lobby-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
#lobby :where(button, select, summary):focus-visible {
  outline: 3px solid var(--lobby-gold);
  outline-offset: 3px;
}
#lobby button { -webkit-tap-highlight-color: transparent; }
#lobby .icon,
#lobby .small {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #9ab8cba3;
  border-radius: 10px;
  background: #244458;
  color: var(--lobby-ink);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.3;
}

#lobby .room-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 11px 12px;
  border: 1px solid #d4ba7d80;
  border-radius: 12px;
  background: linear-gradient(110deg, #4c493a66, #173347);
  box-shadow: inset 3px 0 #f5ce86;
}
#lobby .room-line > span {
  min-width: 0;
  color: #e7d6b6;
  font-size: 12px;
  font-weight: 760;
  line-height: 1.25;
}
#lobby #room-id {
  display: block;
  margin: 3px 0 0;
  color: var(--lobby-ink);
  font-size: 36px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
  letter-spacing: .14em;
  line-height: 1.1;
  user-select: all;
}
#lobby #copy-room {
  padding: 10px 12px;
  border-color: #d3e9e2;
  background: linear-gradient(135deg, #f1f2da, #c5e7df);
  color: #153140;
  box-shadow: 0 3px 0 #102332;
}
#lobby .section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0 6px;
}
#lobby .section-title h3 {
  flex-shrink: 0;
  margin: 0;
  color: var(--lobby-ink);
  font-size: 16px;
  font-weight: 760;
  line-height: 1.35;
}
#lobby .section-title > span {
  min-width: 0;
  color: var(--lobby-mint);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

#lobby #roster {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid #8ea7b77a;
  border-radius: 14px;
  overflow: hidden;
  background-color: #102b3c;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 360'%3E%3Cg fill='none' stroke='%23d7e3df' stroke-opacity='.10' stroke-width='1'%3E%3Crect x='9' y='9' width='222' height='342' rx='2'/%3E%3Cpath d='M9 120h222M9 240h222M120 9v342'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 100% 100%;
}
#lobby .team {
  --team-accent: var(--lobby-mint);
  --team-fill: #173c48;
  --team-human: #214c58;
  padding: 10px;
  border: 0;
  border-radius: 0;
  background: #226c7910;
}
#lobby .team[data-team="1"] {
  --team-accent: var(--lobby-coral);
  --team-fill: #44313a;
  --team-human: #5e3a40;
  background: #ba685916;
}
#lobby .team > h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--team-accent);
  font-size: 14px;
  font-weight: 760;
  line-height: 1.3;
}
#lobby .team > h3 > span {
  color: var(--lobby-muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
#lobby .seat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
#lobby .seat {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  justify-items: center;
  gap: 3px;
  min-width: 0;
  min-height: 74px;
  padding: 6px;
  border: 1px solid #a3bdcc66;
  border-radius: 10px;
  background: var(--team-fill);
  color: var(--lobby-ink);
  box-shadow: inset 0 1px #ffffff0a;
  font-weight: 600;
  text-align: center;
}
#lobby .seat:disabled { opacity: 1; }
#lobby .seat .number {
  justify-self: start;
  width: auto;
  color: #bed1da;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}
#lobby .seat .name {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: inherit;
  font-size: 15px;
  font-weight: 760;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#lobby .seat .owner-mark {
  flex: 0 0 12px;
  order: -1;
  width: 12px;
  height: 12px;
  color: var(--lobby-gold);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  vertical-align: middle;
}
#lobby .seat .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  max-width: 100%;
  min-height: 17px;
  padding: 1px 5px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #c1d3dc;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: normal;
}
#lobby .seat[data-controller="ai"]::before {
  content: none;
}
#lobby .seat[data-selectable="true"] {
  border-style: dashed;
  background: #0e2938;
}
#lobby .seat[data-selectable="true"] .badge { color: var(--team-accent); }
#lobby .seat[data-occupied="true"][data-controller="human"] {
  border-color: #a9c4cf9c;
  background: var(--team-human);
}
#lobby .seat[data-ready="true"][data-controller="human"]:not([data-away="true"]):not([data-disconnected="true"]) .badge {
  border-color: #a6dac869;
  background: #9fe0cb;
  color: #103b3d;
  font-weight: 760;
}
#lobby .seat[data-ready="true"][data-controller="human"]:not([data-away="true"]):not([data-disconnected="true"]) .badge::before {
  content: "";
  flex-shrink: 0;
  width: 8px;
  height: 4px;
  margin-top: -3px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}
#lobby .team .seat.self {
  border: 2px solid var(--lobby-gold);
  background: linear-gradient(135deg, #5d553e, #2b4146);
  color: #fff1c8;
  box-shadow: inset 0 0 0 1px #ffd58924;
}
#lobby .seat.self::before { content: none; }
#lobby .seat.self .name::after {
  content: "你";
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--lobby-gold);
  color: #273742;
  font-size: 12px;
  font-weight: 760;
  line-height: 1.35;
}
#lobby .seat[data-away="true"] {
  border-style: dashed;
  border-color: #d6bd89;
}
#lobby .seat[data-away="true"] .badge { color: #f2d89e; }
#lobby .seat[data-disconnected="true"] {
  border-style: dashed;
  border-color: #b9a383;
  background: repeating-linear-gradient(135deg, #27343e, #27343e 9px, #2c3942 9px, #2c3942 10px);
}
#lobby .team .seat.self[data-disconnected="true"] {
  border-style: dashed;
  background: repeating-linear-gradient(135deg, #35403c, #35403c 9px, #3c463f 9px, #3c463f 10px);
}
#lobby .seat[data-disconnected="true"]::before {
  content: "離線";
  position: absolute;
  top: 5px;
  right: 5px;
  padding: 0 3px;
  border: 1px solid #b9a383;
  border-radius: 4px;
  color: #edcfac;
  font-size: 12px;
  font-weight: 760;
  line-height: 1.25;
}
#lobby .seat.self[data-disconnected="true"]::before { content: none; }
#lobby .seat[data-disconnected="true"] .badge {
  color: #eed5b8;
  background: #1c2938;
}
#lobby .net-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
  padding: 3px 12px;
  background: #0c1f2f;
  color: #d8dfd7;
  font-size: 12px;
  font-weight: 760;
  letter-spacing: .12em;
}
#lobby .net-line::before,
#lobby .net-line::after {
  height: 6px;
  border-top: 1px solid #dce4d5b3;
  border-bottom: 1px solid #839dac80;
}

#lobby .appearance-section { margin-top: 18px; }
#lobby #appearance-choices {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
  margin: 10px 0 8px;
}
#lobby .appearance-choice {
  position: relative;
  display: grid;
  align-content: end;
  justify-items: center;
  gap: 4px;
  min-width: 44px;
  min-height: 98px;
  padding: 4px 3px 7px;
  overflow: hidden;
  border: 1px solid #8ba8ba80;
  border-radius: 10px;
  background: radial-gradient(ellipse at 50% 45%, #3d627568, transparent 70%), #112b3d;
  color: #d6e4e9;
  box-shadow: inset 0 -2px #5f829b24;
  font-size: 12px;
  font-weight: 760;
  line-height: 1.3;
}
#lobby .appearance-choice img {
  display: block;
  width: 100%;
  height: 68px;
  object-fit: contain;
  pointer-events: none;
}
#lobby .appearance-choice[aria-pressed="true"] {
  border: 2px solid var(--lobby-gold);
  background: radial-gradient(ellipse at 50% 40%, #c9a95e59, transparent 75%), #39483f;
  color: #fff0c7;
  box-shadow: inset 0 -3px var(--lobby-gold);
}
#lobby .appearance-choice[aria-pressed="true"]::before {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 4px;
  border-left: 2px solid var(--lobby-gold);
  border-bottom: 2px solid var(--lobby-gold);
  transform: rotate(-45deg);
}
#lobby .appearance-choice:disabled { opacity: .72; }
#lobby .appearance-choice[aria-pressed="true"]:disabled { opacity: 1; }

#lobby .lobby-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 10px;
  margin-top: 14px;
}
#lobby .lobby-options label,
#lobby .test-panel label {
  min-width: 0;
  margin: 0;
  color: var(--lobby-ink);
  font-size: 13px;
  font-weight: 760;
}
#lobby select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  margin-top: 6px;
  padding: 10px 32px 10px 11px;
  border: 1px solid #a4bacbaa;
  border-radius: 10px;
  appearance: none;
  -webkit-appearance: none;
  background-color: #213c50;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 12'%3E%3Cpath d='m3 3 5 5 5-5' fill='none' stroke='%23f7e9cf' stroke-width='2.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 12px 10px;
  color: var(--lobby-ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}
#lobby select:disabled {
  opacity: 1;
  border-color: #738b9a80;
  background-color: #172e40;
  color: #b1c4cf;
  -webkit-text-fill-color: #b1c4cf;
}
#lobby #settings-hint { margin-top: 8px; }
#lobby #scenario-note:empty { display: none; }
#lobby .test-panel {
  margin: 15px 0 3px;
  padding: 0;
  border: 1px solid #7896a54d;
  border-radius: 10px;
  background: #0b203080;
  color: var(--lobby-muted);
  font-size: 13px;
  font-weight: 600;
}
#lobby .test-panel summary {
  min-height: 46px;
  padding: 12px;
  color: #cad9df;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.5;
  cursor: pointer;
}
#lobby .test-panel summary::marker { color: var(--lobby-gold); }
#lobby .test-panel[open] summary { border-bottom: 1px solid #7896a54d; }
#lobby .test-panel > label { margin: 12px; }
#lobby .test-panel p,
#lobby #test-metrics {
  display: block;
  margin: 10px 12px 12px;
  color: var(--lobby-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
#lobby #test-metrics { font-variant-numeric: tabular-nums; }

#lobby .lobby-footer {
  position: relative;
  bottom: auto;
  flex: 0 0 auto;
  z-index: 3;
  margin: 0;
  padding: 10px 14px max(8px, var(--safe-bottom, 0px));
  border-top: 1px solid #adbac166;
  background: linear-gradient(125deg, #1a3343, #112534 70%);
  box-shadow: 0 -8px 18px #07121d30;
}
#lobby #lobby-status {
  min-height: 19px;
  margin: 0 0 9px;
  color: #e7e7cc;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  overflow-wrap: anywhere;
}
#lobby .lobby-buttons { display: flex; gap: 8px; margin: 0; }
#lobby .lobby-buttons > button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 50px;
  padding: 12px 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: 16px;
  font-weight: 760;
  line-height: 1.3;
}
#lobby #start {
  border-color: #ffe4ae;
  background: linear-gradient(115deg, #f7c66e, #ffe3a5);
  color: #152e3c;
  box-shadow: 0 3px 0 #997640;
}
#lobby #ready {
  border-color: #bcefe2;
  background: linear-gradient(115deg, #7cd8c9, #b3e9d7);
  color: #12363e;
  box-shadow: 0 3px 0 #467f7d;
}
#lobby #ready[data-ready="true"] {
  border-color: #94ddcc;
  background: #234c51;
  color: #d5f4e9;
  box-shadow: inset 0 0 0 1px #7dd3bc33;
}
#lobby #start:disabled,
#lobby #ready:disabled {
  opacity: 1;
  border-color: #78909e;
  background: #354b5b;
  color: #c4d2db;
  box-shadow: none;
}
#lobby #leave-room {
  width: 100%;
  min-height: 44px;
  margin: 9px 0 0;
  padding: 10px;
  border: 1px solid #bc9b915e;
  border-radius: 9px;
  background: #503a3b33;
  color: #edc6b8;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.4;
}
#lobby[data-status="playing"] .lobby-buttons,
#lobby[data-status="countdown"] .lobby-buttons { display: none; }
#lobby :where(.seat, .appearance-choice, .small, .lobby-buttons > button, #leave-room):enabled:active {
  transform: translateY(1px);
  filter: brightness(1.08);
}

@media (max-width: 350px) {
  #lobby .sheet-top { padding: 12px 13px 11px; }
  #lobby .sheet-top h2 { font-size: 22px; }
  #lobby .lobby-scroll { padding: 12px; }
  #lobby .room-line { padding: 10px; gap: 8px; }
  #lobby #room-id { font-size: 33px; }
  #lobby #copy-room { padding-inline: 9px; }
  #lobby .section-title { gap: 7px; }
  #lobby .section-title h3 { font-size: 15px; }
  #lobby .team { padding: 9px 8px; }
  #lobby .seat-grid { gap: 5px; }
  #lobby .seat { min-height: 74px; gap: 3px; padding: 6px; }
  #lobby .seat .name { font-size: 14px; }
  #lobby #appearance-choices { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  #lobby .appearance-choice { min-height: 108px; }
  #lobby .appearance-choice img { height: 77px; }
  #lobby .lobby-options { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 8px; }
  #lobby .lobby-footer { padding-inline: 12px; }
  #lobby .lobby-buttons > button { font-size: 15px; }
}

@media (max-height: 650px) {
  #lobby .sheet-top { padding: 7px 12px; }
  #lobby .sheet-top .eyebrow { display: none; }
  #lobby .sheet-top h2 { margin: 0; font-size: 21px; }
  #lobby .lobby-scroll { padding: 9px 12px 12px; }
  #lobby .room-line { gap: 7px; margin-bottom: 7px; padding: 0 8px; }
  #lobby .room-line > span { display: flex; align-items: center; gap: 7px; }
  #lobby #room-id { display: inline; margin: 0; font-size: 30px; letter-spacing: .11em; }
  #lobby #copy-room { min-height: 44px; border-radius: 8px; padding: 8px; }
  #lobby .section-title { margin: 5px 0 3px; }
  #lobby .section-title h3 { font-size: 15px; }
  #lobby #seat-hint { margin: 0 0 5px; font-size: 12px; line-height: 1.35; }
  #lobby .team { padding: 5px 8px; }
  #lobby .team > h3 { margin-bottom: 4px; font-size: 12px; line-height: 1.25; }
  #lobby .team > h3 > span { font-size: 11px; }
  #lobby .seat-grid { gap: 3px; }
  #lobby .seat { min-height: 62px; gap: 2px; padding: 5px 6px; }
  #lobby .seat .number { font-size: 11px; line-height: 1.1; }
  #lobby .seat .name { font-size: 14px; line-height: 1.15; }
  #lobby .seat .badge { min-height: 14px; padding: 1px 3px; font-size: 11px; line-height: 1.15; }
  #lobby .net-line { min-height: 20px; padding-block: 1px; font-size: 11px; }
  #lobby .appearance-section { margin-top: 12px; }
  #lobby .lobby-options { margin-top: 10px; }
  #lobby .lobby-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 84px;
    align-items: stretch;
    column-gap: 8px;
    padding-top: 8px;
  }
  #lobby #lobby-status { grid-column: 1 / -1; min-height: 17px; margin-bottom: 6px; font-size: 12px; }
  #lobby .lobby-buttons { grid-column: 1; grid-row: 2; }
  #lobby .lobby-buttons > button { min-height: 46px; padding-block: 10px; white-space: nowrap; }
  #lobby #leave-room { grid-column: 2; grid-row: 2; min-height: 46px; margin: 0; padding: 9px 5px; }
  #lobby[data-status="playing"] #leave-room,
  #lobby[data-status="countdown"] #leave-room { grid-column: 1 / -1; }
}
