main.main:has(#route-public-match:not(.hidden)) {
  padding: 0;
  max-width: none;
  margin: 0;
  min-height: 100dvh;
  min-height: min(100dvh, 100svh);
}

body:has(#route-public-match:not(.hidden)) .navbar,
body:has(#route-public-match:not(.hidden)) .footer {
  display: none !important;
}

.route-section#route-public-match {
  min-height: 0 !important;
  height: 100dvh;
  max-height: 100dvh;
  height: min(100dvh, 100svh);
  max-height: min(100dvh, 100svh);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.public-layout {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-rows: minmax(0, 1fr) minmax(0, 2fr);
  grid-template-areas:
    "main online"
    "main chat";
  gap: 12px;
  align-items: stretch;
  height: 100%;
}

.public-layout__online {
  grid-area: online;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.public-layout__main {
  grid-area: main;
  padding: 6px;
  min-width: 0;
}

.public-layout__chat {
  grid-area: chat;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel {
  border: 1px solid #334561;
  border-radius: 10px;
  background: #151f31;
  padding: 10px;
  color: #e6eefc;
}

.panel h3 {
  margin: 0 0 10px;
  color: #f4f8ff;
}

.panel p,
.panel strong,
.panel code,
#online-users,
#public-chat {
  color: #dce7ff;
}

.panel code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
}

#online-users > div {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#online-users {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
}

#online-users > div:last-child {
  border-bottom: 0;
}

#public-chat {
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#public-chat #chat-list {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
}

#public-chat .public-chat-composer {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

#public-chat #chat-input {
  min-width: 0;
  flex: 1 1 auto;
  margin-bottom: 0;
  min-height: 2.25rem;
  box-sizing: border-box;
}

#public-chat #chat-send {
  flex: 0 0 auto;
  min-height: 2.25rem;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
}

.public-layout > aside.panel {
  min-height: 0;
  overflow: auto;
}

.public-layout > section.panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.board-shell {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f1b31;
  border: 0;
  border-radius: 6px;
  padding: 0;
  overflow: hidden;
}

#public-xiangqiboard {
  width: min(100%, calc(100dvh - 230px));
  aspect-ratio: 1 / 1;
  max-width: 100%;
}

/*
 * Phone/small-tablet landscape: 100dvh is the short side, so calc(100dvh - 230px) collapses and
 * the board is tiny. Use a smaller chrome reserve only here.
 * Wide PC viewports are still landscape but have a tall dvh — applying that rule there made the
 * square too large and broke the main column layout; keep the default #public-xiangqiboard rule.
 */
@media (orientation: landscape) and (max-width: 960px) {
  #public-xiangqiboard {
    width: min(100%, calc(100dvh - 120px));
    aspect-ratio: 1 / 1;
    max-width: 100%;
  }
}

#public-xiangqiboard .board-1ef78 {
  border-radius: 8px;
  overflow: hidden;
}

#public-xiangqiboard [data-square] {
  display: flex;
  align-items: center;
  justify-content: center;
}

#public-xiangqiboard .public-match-select-src {
  background-color: rgba(255, 204, 102, 0.35) !important;
}

#public-xiangqiboard .public-match-select-dest {
  background-color: rgba(90, 74, 58, 0.22) !important;
}

#public-xiangqiboard [data-square].public-match-last-src,
#public-xiangqiboard [data-square].public-match-last-dest {
  background-color: rgba(165, 90, 40, 0.45) !important;
  box-shadow: inset 0 0 0 2px rgba(255, 200, 120, 0.78);
}

.public-match-game-over {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
  font-size: clamp(2rem, 8vw, 4.8rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #ffd84d;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.55), 0 0 24px rgba(0, 0, 0, 0.45);
}

.public-match-game-over.hidden {
  display: none;
}

#move-timer {
  margin-top: 8px;
  color: #f0f5ff;
  font-weight: 600;
}

.public-match-players__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.95rem;
}

.public-match-players__row--top {
  margin-bottom: 8px;
}

.public-match-players__row--bottom {
  margin-top: 8px;
}

.public-match-players__row--you {
  outline: 1px solid rgba(120, 180, 255, 0.45);
  background: rgba(80, 140, 255, 0.12);
}

.public-match-players__side {
  flex: 0 0 3.5rem;
  font-weight: 700;
  color: #b8d4ff;
}

.public-match-players__name {
  color: #f0f5ff;
  font-weight: 600;
}

.public-match-players__avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  object-fit: contain;
  object-position: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
}

.public-match-players__clock {
  margin-left: auto;
  color: #c6dcff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
}

.public-match-players__row--turn {
  outline: 1px solid rgba(247, 199, 93, 0.55);
}

.public-match-status,
.public-match-result {
  margin-top: 8px;
  color: #dce7ff;
  min-height: 1.25rem;
}

.public-match-result {
  font-weight: 600;
}

.draw-offer-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.draw-offer-modal.hidden {
  display: none;
}

.draw-offer-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 22, 0.72);
}

.draw-offer-modal__box {
  position: relative;
  max-width: 400px;
  width: 100%;
  padding: 20px 22px;
  border-radius: 12px;
  border: 1px solid #334561;
  background: #151f31;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.draw-offer-modal__text {
  margin: 0 0 16px;
  color: #e6eefc;
  line-height: 1.45;
}

.draw-offer-modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.draw-offer-modal__actions button {
  min-width: 5rem;
  margin: 0;
}

.public-actions {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  width: 100%;
}

.public-actions button {
  margin: 0;
  white-space: nowrap;
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 960px) {
  .route-section#route-public-match {
    height: auto;
    max-height: none;
    overflow: visible;
    padding: 8px;
  }

  .public-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas:
      "main"
      "online"
      "chat";
    height: auto;
  }

  .public-layout > section.panel {
    min-height: auto;
    overflow: visible;
  }

  .public-layout > aside.panel {
    overflow: visible;
  }

  .board-shell {
    min-height: 260px;
  }
}
