[hidden] { display: none !important; }
.service-button, .dialog-close {
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  background: var(--surface-deep);
  color: var(--text);
  padding: .48rem .65rem;
  min-height: 38px;
  font-size: .82rem;
  white-space: nowrap;
}
.service-button:hover, .dialog-close:hover { border-color: var(--accent); color: var(--accent); }
#accountButton { max-width: 10rem; overflow: hidden; text-overflow: ellipsis; }

.service-dialog {
  width: min(92vw,480px);
  max-height: calc(100svh - 24px);
  margin: auto;
  overflow: auto;
  padding: clamp(14px,4vw,23px);
  border: 1px solid var(--outline);
  border-radius: max(10px,var(--radius));
  background: linear-gradient(150deg,var(--surface),var(--surface-deep));
  color: var(--text);
  box-shadow: 0 20px 85px #000b;
}
.service-dialog::backdrop { background: #05030abf; backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.dialog-head h2 { margin: 0; font-size: 21px; }
.dialog-close { min-width: 34px; min-height: 34px; padding: 1px 7px; font-size: 22px; line-height: 1; }
.service-dialog form, .room-roster { display: grid; gap: 11px; }
.service-dialog label { display: grid; gap: 5px; color: var(--text); font-size: 13px; }
.service-dialog input:not([type="radio"]), .service-dialog select {
  width: 100%;
  min-width: 0;
  min-height: 39px;
  padding: 6px 9px;
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  background: var(--well);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.service-dialog input:not([type="radio"]):focus-visible, .service-dialog select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.service-dialog .primary { min-height: 42px; width: auto; padding-inline: 18px; }
.form-message { margin: 2px 0 6px; color: var(--accent); font-size: 13px; line-height: 1.6; }
.form-message:empty { display: none; }
.room-code { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 0 7px; }
.room-code strong { color: var(--accent); font: 800 clamp(21px,5vw,33px) var(--mono); letter-spacing: .10em; user-select: all; }
.room-code span, .room-roster { font-size: 13px; }
.invite-url { margin-bottom: 6px; }
.room-roster { margin: 13px 0; }
.room-player { display: flex; justify-content: space-between; gap: 10px; padding: 10px; border: 1px solid var(--outline); border-radius: var(--radius); background: var(--well); }
.room-player b { min-width: 0; overflow-wrap: anywhere; }
.room-player span { color: var(--muted); white-space: nowrap; }
.room-player .ready { color: var(--accent); }
.rankings { width: min(94vw,820px); }
.service-dialog .ranking-filters {
  grid-template-columns: minmax(0,2fr) minmax(0,3fr);
  gap: 12px;
  margin-bottom: 16px;
}
.ranking-options { display: grid; gap: 6px; }
.ranking-scopes { grid-template-columns: repeat(2,minmax(0,1fr)); }
.ranking-modes { grid-template-columns: repeat(3,minmax(0,1fr)); }
.ranking-filters .lobby-option { justify-content: center; gap: 5px; min-height: 42px; padding: 5px 4px; font-weight: 700; white-space: nowrap; }
.ranking-filters .lobby-option > .icon { flex: none; width: 14px; height: 14px; padding: 3px; }
.ranking-filters .lobby-option::after { display: none; }
.ranking-scroll { overflow: auto; border: 1px solid var(--outline); border-radius: var(--radius); background: var(--well); }
.rankings table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rankings th, .rankings td { border-bottom: 1px solid var(--outline); padding: 9px 8px; text-align: left; }
.rankings th { color: var(--muted); background: var(--surface); white-space: nowrap; }
.rankings tbody tr:last-child td { border-bottom: 0; }
.rankings td:nth-child(2) { min-width: 65px; max-width: 145px; overflow-wrap: anywhere; }
.rankings td:last-child, .rankings td:nth-child(6) { white-space: nowrap; }
.rankings td:not(:nth-child(2)) { font-variant-numeric: tabular-nums; }
.current-rank { margin-top: 9px; padding-top: 7px; border-top: 1px solid var(--outline); }
.current-rank strong { color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 620px) {
  .service-dialog .ranking-filters { grid-template-columns: minmax(0,1fr); }
  .rankings th, .rankings td { padding-inline: 5px; }
}
@media (max-width: 360px) {
  .ranking-filters .lobby-option > .icon { display: none; }
}
.connection-notice {
  position: fixed;
  z-index: 5;
  right: 12px;
  bottom: max(10px,env(safe-area-inset-bottom));
  max-width: min(84vw,360px);
  padding: 8px 11px;
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  background: var(--well);
  color: var(--accent);
  font-size: 13px;
  pointer-events: none;
}

.peer-shell { min-width: 0; }
.peer-shell .well-head > span:first-child { min-width: 0; }
#peerName { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.in-room .peer-shell .well-head { min-height: 32px; }
.versus .next-panel { align-self: start; }
.versus .game-options { display: contents; }
.versus .skin-panel .theme-list {
  grid-template-columns: repeat(3, minmax(max-content, 1fr));
  gap: 5px;
}
.versus .skin-panel .theme {
  flex-direction: row;
  justify-content: center;
  gap: 4px;
  padding-inline: 4px;
  white-space: nowrap;
}
.versus .skin-panel .theme-sample { width: 16px; height: 19px; }
@media (min-width: 691px) {
  .versus .layout {
    --board-width: clamp(173px,min(30vw,calc((100svh - 176px)/2)),385px);
    grid-template-columns: minmax(132px,225px) var(--board-width) minmax(132px,152px) calc(var(--board-width) * .62);
    column-gap: clamp(13px,2vw,28px);
  }
  .versus .game-shell { grid-area: 1 / 2; }
  .versus .next-panel { grid-area: 1 / 3; margin-top: 36px; }
  .versus .peer-shell { grid-area: 1 / 4; }
  .versus .skin-panel { grid-area: 2 / 2 / 3 / -1; }
  .versus .skin-panel .theme .check { flex: 0 0 12px; width: 12px; }
  .versus .preview-slot:first-child .preview-grid span { width: clamp(16px,2vw,22px); height: clamp(16px,2vw,22px); }
}
@media (max-width: 690px) {
  .bar { gap: 5px; padding-inline: 7px; }
  .bar-actions { gap: 3px; }
  .bar-actions .service-button { min-height: 34px; padding-inline: 5px; font-size: 11px; }
  .bar-actions .icon-button { min-width: 30px; padding-inline: 4px; }
  #accountButton { max-width: 54px; }
  .in-room #leaderboardButton, .in-room #restartButton { display: none; }
  .versus .layout {
    --board-width: 100%;
    grid-template-columns: minmax(0,1.65fr) minmax(0,1fr);
    grid-template-rows: auto auto 1fr;
    column-gap: 14px;
  }
  .versus .score-panel { grid-area: 1 / 1 / 2 / -1; }
  .versus .game-shell { grid-area: 2 / 1 / 4 / 2; }
  .versus .next-panel { grid-area: 2 / 2; margin-top: 26px; }
  .versus .next-window { grid-template-columns: minmax(0,1fr); }
  .versus .preview-slot { min-height: 30px; }
  .versus .preview-slot:first-child { min-height: 40px; }
  .versus .peer-shell { grid-area: 3 / 2; }
  .in-room.versus .peer-shell .well-head { min-height: 24px; }
  .versus .well-head, .versus .well-foot { white-space: nowrap; font-size: 9px; letter-spacing: 0; }
  .versus .well-head span, .versus .well-foot span:last-child { gap: 3px; }
}
