.lounge-overlay {
  position: fixed;
  inset: 0;
  z-index: 180;
  overflow: auto;
  padding: 18px;
  background:
    radial-gradient(circle at 16% 10%, #b9ff4218 0, transparent 25%),
    radial-gradient(circle at 82% 75%, #50f7b21a 0, transparent 31%),
    #020705f7;
  backdrop-filter: blur(18px);
}

.lounge-overlay[hidden] { display: none; }

.lounge-shell {
  width: min(1240px, 100%);
  min-height: calc(100vh - 36px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #59d77a;
  border-radius: 26px;
  background: linear-gradient(145deg, #06120d, #0b2116 58%, #07110d);
  box-shadow: 0 32px 100px #000e, 0 0 65px #73ff3520;
}

.lounge-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 25px;
  align-items: end;
  padding: 28px 32px 24px;
  border-bottom: 1px solid #205a3a;
  background:
    linear-gradient(100deg, #07120eeb, #102d1cdb),
    radial-gradient(circle at 32% 30%, #b9ff421c, transparent 36%);
}

.lounge-head small,
.lounge-tables header small,
.lounge-create > small {
  color: var(--mint);
  font: 800 10px ui-monospace, monospace;
  letter-spacing: .15em;
}

.lounge-head h1 {
  margin: 7px 0 9px;
  font-size: clamp(34px, 4.7vw, 58px);
  line-height: .91;
}

.lounge-head h1 em { color: var(--lime); font-style: normal; }
.lounge-head p { max-width: 700px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }

.lounge-user {
  min-width: 275px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid #347753;
  border-radius: 17px;
  background: #06100cd9;
}

.lounge-user > span {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid var(--lime);
  border-radius: 17px;
  background: radial-gradient(circle, #dfff9d, #65de3b 38%, #0d351b 42% 68%, #020604 69%);
  color: #071008;
  font-size: 22px;
  font-weight: 950;
  box-shadow: 0 0 24px #9cff3540;
}

.lounge-user small,
.lounge-user strong,
.lounge-user b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lounge-user small { color: var(--mint); font: 800 10px ui-monospace, monospace; letter-spacing: .09em; }
.lounge-user strong { margin-top: 4px; font-size: 14px; }
.lounge-user b { margin-top: 4px; color: var(--lime); font: 750 10px ui-monospace, monospace; }

.lounge-leaderboard {
  padding: 16px 24px 18px;
  border-bottom: 1px solid #205a3a;
  background:
    linear-gradient(100deg, #040b08f2, #0a1c13ed),
    radial-gradient(circle at 16% 50%, #ffce4a15, transparent 28%);
}

.lounge-leaderboard-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
}

.lounge-leaderboard-head small {
  color: var(--gold);
  font: 850 10px ui-monospace, monospace;
  letter-spacing: .15em;
}

.lounge-leaderboard-head h2 {
  margin: 3px 0 1px;
  color: #fff5c4;
  font-size: 22px;
  line-height: 1;
  text-shadow: 0 0 20px #ffca4666;
}

.lounge-leaderboard-head p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.lounge-leaderboard-actions {
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px;
  align-items: stretch;
}

.lounge-leaderboard-actions .lounge-leaderboard-self { grid-row: span 2; }
.lounge-leaderboard-actions > button,
.lounge-leaderboard-actions > a {
  min-width: 148px;
  min-height: 30px;
  display: grid;
  place-items: center;
  padding: 2px 7px;
  border: 1px solid #496f32;
  border-radius: 999px;
  background: #07140f;
  color: var(--lime);
  font: 850 11px ui-monospace, monospace;
  text-decoration: none;
  cursor: pointer;
}

.lounge-leaderboard-actions > a { border-color: #26785b; color: var(--mint); }
.lounge-leaderboard-actions > button:hover:not(:disabled),
.lounge-leaderboard-actions > a:hover { border-color: currentColor; box-shadow: 0 0 16px #92ff4d22; }
.lounge-leaderboard-actions > button:disabled { opacity: .42; cursor: default; }

.lounge-leaderboard-self {
  min-width: 148px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 1px 9px;
  padding: 8px 11px;
  border: 1px solid #5b5b2e;
  border-radius: 12px;
  background: #16150670;
}

.lounge-leaderboard-self > span,
.lounge-leaderboard-self > small { color: var(--muted); font: 800 10px ui-monospace, monospace; letter-spacing: .06em; }
.lounge-leaderboard-self > strong { grid-row: span 2; color: var(--gold); font-size: 23px; line-height: 1; }
.lounge-leaderboard-self > small { color: #bed3c5; }

.lounge-leaderboard-list {
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
}

.lounge-rank {
  min-width: 0;
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  padding: 8px;
  overflow: hidden;
  border: 1px solid #254f38;
  border-radius: 12px;
  background: linear-gradient(145deg, #081610, #030906);
  box-shadow: inset 0 0 18px #50f7b208;
  cursor: pointer;
}

.lounge-rank:hover,
.lounge-rank:focus-visible,
.lounge-rank.selected { outline: none; border-color: var(--mint); background: linear-gradient(145deg, #0d2419, #041009); box-shadow: inset 0 0 22px #50f7b214, 0 0 18px #50f7b218; }

.lounge-rank:first-child {
  border-color: #b99a35;
  background: linear-gradient(145deg, #221c08, #080b06 70%);
  box-shadow: inset 0 0 24px #ffca4614, 0 0 20px #ffca4614;
}

.lounge-rank-number {
  position: absolute;
  right: 6px;
  top: 4px;
  color: #799080;
  font: 900 10px ui-monospace, monospace;
  letter-spacing: .08em;
}

.lounge-rank:first-child .lounge-rank-number { color: var(--gold); }

.lounge-rank-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid hsl(var(--rank-hue) 62% 56%);
  border-radius: 9px;
  background: hsl(var(--rank-hue) 54% 18%);
  color: hsl(var(--rank-hue) 88% 82%);
  font: 950 11px ui-monospace, monospace;
  box-shadow: 0 0 13px hsl(var(--rank-hue) 72% 52% / .22);
}

.lounge-rank-copy { min-width: 0; }
.lounge-rank-copy strong,
.lounge-rank-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lounge-rank-copy strong { padding-right: 14px; color: var(--text); font-size: 11px; }
.lounge-rank-copy small { margin-top: 2px; color: var(--muted); font: 750 10px ui-monospace, monospace; }
.lounge-rank-score { grid-column: 1 / -1; color: var(--lime); font: 950 12px ui-monospace, monospace; letter-spacing: .03em; }
.lounge-rank:first-child .lounge-rank-score { color: var(--gold); }
.lounge-rank-stats { grid-column: 1 / -1; display: flex; gap: 8px; color: #8ca696; font: 750 10px ui-monospace, monospace; }
.lounge-rank.mine { border-color: var(--mint); }

.lounge-leaderboard-empty {
  margin: 11px 0 0;
  padding: 12px;
  border: 1px dashed #345b43;
  border-radius: 11px;
  color: #91aa9a;
  font-size: 10px;
  text-align: center;
}

.lounge-leaderboard-empty[hidden] { display: none; }

.lounge-ping {
  position: fixed;
  z-index: 198;
  left: 50%;
  top: 18px;
  width: min(680px, calc(100vw - 28px));
  transform: translateX(-50%);
  padding: 13px 18px;
  border: 1px solid var(--mint);
  border-radius: 999px;
  background: #06150ff5;
  color: #eafff0;
  font-size: 14px;
  font-weight: 850;
  text-align: center;
  box-shadow: 0 0 36px #50f7b244, 0 16px 45px #000b;
  animation: lounge-ping-in .28s ease-out both;
}

.lounge-ping[data-state="start"] { border-color: var(--gold); color: #fff5c4; box-shadow: 0 0 40px #ffca4650, 0 16px 45px #000b; }
.lounge-ping[hidden] { display: none; }

@keyframes lounge-ping-in {
  from { opacity: 0; transform: translate(-50%, -14px) scale(.96); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.leaderboard-window {
  position: fixed;
  z-index: 196;
  left: 50%;
  top: 50%;
  width: min(980px, calc(100vw - 36px));
  height: min(680px, calc(100vh - 36px));
  min-width: min(560px, calc(100vw - 16px));
  min-height: min(360px, calc(100vh - 16px));
  transform: translate(-50%, -50%);
  overflow: hidden;
  resize: none;
  border: 1px solid var(--gold);
  border-radius: 20px;
  background: #040c08f7;
  box-shadow: 0 28px 90px #000f, 0 0 50px #ffca4625;
  backdrop-filter: blur(18px);
}

.leaderboard-window[hidden] { display: none; }
.leaderboard-window > header {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 10px 8px 16px;
  border-bottom: 1px solid #5e5325;
  background: linear-gradient(100deg, #171607, #08130d);
  cursor: move;
  touch-action: none;
  user-select: none;
}

.leaderboard-window > header small,
.leaderboard-window > header strong { display: block; }
.leaderboard-window > header small { color: var(--gold); font: 850 11px ui-monospace, monospace; letter-spacing: .08em; }
.leaderboard-window > header strong { margin-top: 2px; color: #fff5c4; font-size: 20px; }
.leaderboard-window > header nav { display: flex; gap: 6px; align-items: center; }
.leaderboard-window > header button,
.leaderboard-window > header a {
  min-width: 34px;
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 2px 7px;
  border: 1px solid #5e6d42;
  border-radius: 999px;
  background: #07140f;
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}
.leaderboard-window > header a { color: var(--mint); font: 850 11px ui-monospace, monospace; }

.leaderboard-window-body {
  height: calc(100% - 58px);
  display: grid;
  grid-template-columns: minmax(330px, 1.15fr) minmax(280px, .85fr);
  min-height: 0;
}

#loungeLeaderboardAll {
  min-height: 0;
  margin: 0;
  padding: 14px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 8px;
  list-style: none;
  border-right: 1px solid #23482f;
}

#loungeLeaderboardDetail { min-width: 0; padding: 22px; overflow: auto; }
#loungeLeaderboardDetail > header { display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 13px; align-items: center; }
.leaderboard-detail-avatar { width: 66px; height: 66px; display: grid; place-items: center; overflow: hidden; border: 1px solid hsl(var(--rank-hue) 72% 58%); border-radius: 19px; background: hsl(var(--rank-hue) 54% 18%); color: #fff; font: 950 20px ui-monospace, monospace; box-shadow: 0 0 24px hsl(var(--rank-hue) 72% 52% / .28); }
.leaderboard-detail-avatar img { width: 100%; height: 100%; object-fit: cover; }
#loungeLeaderboardDetail > header small { color: var(--gold); font: 850 11px ui-monospace, monospace; }
#loungeLeaderboardDetail h3 { margin: 4px 0 2px; overflow-wrap: anywhere; color: #fff; font-size: 24px; }
#loungeLeaderboardDetail p { margin: 0; overflow-wrap: anywhere; color: var(--muted); font-size: 11px; line-height: 1.45; }
#loungeLeaderboardDetail dl { margin: 20px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#loungeLeaderboardDetail dl div { padding: 10px; border: 1px solid #294b35; border-radius: 11px; background: #07140f; }
#loungeLeaderboardDetail dt { color: var(--muted); font: 800 11px ui-monospace, monospace; }
#loungeLeaderboardDetail dd { margin: 4px 0 0; color: var(--lime); font-size: 18px; font-weight: 900; }
#loungeLeaderboardDetail .leaderboard-score-rule { margin-top: 13px; padding: 10px; border: 1px solid #5e5325; border-radius: 11px; color: var(--gold); font: 800 11px/1.45 ui-monospace, monospace; }

.leaderboard-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 26px;
  height: 26px;
  border: 0;
  background: linear-gradient(135deg, transparent 50%, var(--gold) 51% 57%, transparent 58% 66%, var(--gold) 67% 73%, transparent 74%);
  cursor: nwse-resize;
  touch-action: none;
}

.leaderboard-window.minimized { height: 58px !important; min-height: 58px; }
.leaderboard-window.minimized .leaderboard-window-body,
.leaderboard-window.minimized .leaderboard-resize { display: none; }

.lounge-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 335px;
  min-height: 560px;
}

.lounge-tables { min-width: 0; padding: 25px 28px 30px; }
.lounge-tables > header { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.lounge-tables h2,
.lounge-create h2 { margin: 4px 0 0; font-size: 25px; }

.lounge-tables > header button,
.lounge-table-actions button {
  min-height: 35px;
  border: 1px solid #32734f;
  border-radius: 999px;
  background: #07140f;
  color: var(--text);
  padding: 0 7px;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
}

.lounge-tables > header button:hover,
.lounge-table-actions button:hover:not(:disabled) { border-color: var(--mint); color: var(--mint); }
.lounge-table-actions button.primary { border-color: var(--lime); background: var(--lime); color: #071008; }
.lounge-table-actions button.danger { border-color: #a7475b; color: #ff8ba0; }
.lounge-table-actions button.danger.armed { border-color: #ff647c; background: #521322; color: #fff; box-shadow: 0 0 18px #ff647c42; }
.lounge-table-actions button:disabled { opacity: .4; cursor: default; }

.lounge-table-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.lounge-table {
  position: relative;
  overflow: hidden;
  padding: 16px;
  border: 1px solid #285f42;
  border-radius: 18px;
  background: linear-gradient(145deg, #091b13, #050d09);
  box-shadow: inset 0 0 28px #50f7b208, 0 14px 30px #0005;
}

.lounge-table.mine { border-color: var(--lime); box-shadow: inset 0 0 28px #b9ff4210, 0 0 28px #b9ff4218; }
.lounge-table.playing { border-color: var(--gold); }
.lounge-table.waiting { background: linear-gradient(145deg, #0b2016, #050d09); }
.lounge-table::after { content: ""; position: absolute; width: 90px; height: 90px; right: -46px; top: -46px; border: 1px solid #69ef8c38; border-radius: 50%; }

.lounge-table-head { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.lounge-table-head small { color: var(--mint); font: 800 10px ui-monospace, monospace; letter-spacing: .08em; }
.lounge-table-head strong { display: block; margin-top: 4px; overflow-wrap: anywhere; font-size: 17px; }
.lounge-table-state { color: var(--gold); font: 850 10px ui-monospace, monospace; letter-spacing: .07em; }
.lounge-table.waiting .lounge-table-state { color: var(--lime); }

.lounge-table-config {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 12px;
}

.lounge-table-config span {
  padding: 4px 6px;
  border: 1px solid #1d4c34;
  border-radius: 999px;
  color: var(--muted);
  font: 750 10px ui-monospace, monospace;
}

.lounge-seats { display: grid; gap: 6px; margin-top: 13px; }
.lounge-seat {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 35px;
  padding: 5px 8px;
  border: 1px solid #173f2c;
  border-radius: 10px;
  background: #040b08;
  color: inherit;
  font: inherit;
  text-align: left;
}

.lounge-seat > i { width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid #3f845d; border-radius: 8px; color: var(--mint); font: 900 11px ui-monospace, monospace; font-style: normal; }
.lounge-seat > b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.lounge-seat > small { color: var(--muted); font: 750 10px ui-monospace, monospace; }
.lounge-seat.empty > b { color: #607a6a; }
.lounge-seat.mine { border-color: #7fe67b; }
.lounge-seat.computer > i { border-color: var(--gold); color: var(--gold); }
.lounge-seat.presence-online > small { color: var(--lime); }
.lounge-seat.presence-online > i { box-shadow: 0 0 13px #b9ff4238; }
.lounge-seat.presence-away { opacity: .68; }
.lounge-seat.presence-away > small { color: #dca76d; }
.lounge-seat.presence-open > small { color: var(--mint); }
.lounge-seat.is-game-link { cursor: pointer; transition: border-color .16s ease, background .16s ease, box-shadow .16s ease; }
.lounge-seat.is-game-link:hover,
.lounge-seat.is-game-link:focus-visible { outline: none; border-color: var(--mint); background: #082016; box-shadow: 0 0 18px #65ffad24; }
.lounge-seat.is-game-link > small { color: var(--mint); }

.lounge-table-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 13px; }
.lounge-table-hint { margin: 9px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }

.lounge-empty { min-height: 360px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); }
.lounge-empty[hidden] { display: none; }
.lounge-empty b { color: var(--text); font-size: 18px; }
.lounge-empty span { max-width: 430px; margin-top: 7px; font-size: 10px; line-height: 1.55; }

.lounge-create {
  padding: 26px 22px;
  border-left: 1px solid #205a3a;
  background: #050e0ae3;
}

.lounge-create label { display: block; margin-top: 12px; }
.lounge-create label > span { display: block; margin-bottom: 5px; color: var(--mint); font: 800 10px ui-monospace, monospace; letter-spacing: .08em; }
.lounge-create input,
.lounge-create select {
  width: 100%;
  height: 40px;
  border: 1px solid #245d3f;
  border-radius: 10px;
  outline: 0;
  background: #07140f;
  color: var(--text);
  padding: 0 10px;
  font-size: 10px;
}

.lounge-create input:focus,
.lounge-create select:focus { border-color: var(--mint); box-shadow: 0 0 0 3px #50f7b214; }
.lounge-config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 9px; }
.lounge-score-hint { margin: 10px 2px 0; min-height: 34px; color: #cae5d6; font-size: 11px; line-height: 1.45; }
.lounge-config-grid > [hidden] { display: none !important; }

.lounge-create > label select,
.lounge-create > label input { width: 100%; }

.lounge-42 { display: grid; grid-template-columns: 48px 1fr; gap: 10px; align-items: center; margin-top: 16px; padding: 10px; border: 1px solid #5c5529; border-radius: 12px; background: #1a180832; }
.lounge-42 span { color: var(--gold); font-size: 26px; font-weight: 950; }
.lounge-42 p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.lounge-create-button { width: 100%; min-height: 46px; margin-top: 15px; border: 1px solid var(--lime); border-radius: 999px; background: var(--lime); color: #071008; font-size: 11px; font-weight: 950; cursor: pointer; box-shadow: 0 0 28px #b9ff4228; }
.lounge-create-button:disabled { opacity: .42; cursor: wait; }
.lounge-note { margin: 12px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.5; }

@media (max-width: 900px) {
  .lounge-overlay { padding: 7px; }
  .lounge-shell { min-height: calc(100vh - 14px); border-radius: 18px; }
  .lounge-head { grid-template-columns: 1fr; align-items: start; padding: 22px 20px; }
  .lounge-user { min-width: 0; width: 100%; }
  .lounge-leaderboard { padding: 15px 18px 17px; }
  .lounge-body { grid-template-columns: 1fr; }
  .lounge-create { border-left: 0; border-top: 1px solid #205a3a; }
  .leaderboard-window-body { grid-template-columns: minmax(280px, 1fr) minmax(250px, .8fr); }
  #loungeLeaderboardAll { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .lounge-head h1 { font-size: 34px; }
  .lounge-leaderboard-head { grid-template-columns: 1fr; align-items: start; }
  .lounge-leaderboard-actions { width: 100%; grid-template-columns: 1fr 1fr; }
  .lounge-leaderboard-actions .lounge-leaderboard-self { grid-column: 1 / -1; grid-row: auto; }
  .lounge-leaderboard-self { width: 100%; }
  .lounge-leaderboard-list { grid-template-columns: repeat(5, minmax(155px, 1fr)); overflow-x: auto; padding-bottom: 6px; }
  .leaderboard-window { width: calc(100vw - 14px); height: calc(100vh - 14px); min-width: 0; min-height: 0; border-radius: 14px; }
  .leaderboard-window > header a { display: none; }
  .leaderboard-window-body { grid-template-columns: 1fr; grid-template-rows: minmax(180px, 46%) minmax(0, 1fr); }
  #loungeLeaderboardAll { grid-template-columns: repeat(2, minmax(145px, 1fr)); border-right: 0; border-bottom: 1px solid #23482f; }
  #loungeLeaderboardDetail { padding: 15px; }
  .lounge-tables { padding: 20px 14px; }
  .lounge-table-list { grid-template-columns: 1fr; }
  .lounge-create { padding: 22px 14px; }
}

/* Matrix profile pictures remain the primary identity; initials are fallback only. */
.lounge-user > span,
.lounge-rank-avatar,
.lounge-seat > i {
  overflow: hidden;
}

.lounge-user > span img,
.lounge-rank-avatar img,
.lounge-seat > i img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.lounge-user small,
.lounge-user b,
.lounge-leaderboard-head small,
.lounge-leaderboard-head p,
.lounge-leaderboard-self > span,
.lounge-leaderboard-self > small,
.lounge-rank-number,
.lounge-rank-copy strong,
.lounge-rank-copy small,
.lounge-rank-stats,
.lounge-seat > b,
.lounge-seat > small,
.lounge-table-hint,
.lounge-note {
  font-size: 11px;
}
