.players-row {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.waiting-player {
  position: relative;
}

.waiting-player.ready {
  border-color: rgba(37, 75, 59, .82);
  box-shadow: 0 7px 22px rgba(37, 75, 59, .12), inset 0 0 0 1px rgba(183, 138, 66, .16);
}

.waiting-player.ready::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: -3px;
  right: -3px;
  width: 62px;
  height: 31px;
  border-top: 2px solid rgba(37, 75, 59, .86);
  border-right: 2px solid rgba(37, 75, 59, .86);
  border-radius: 0 16px 0 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, rgba(37, 75, 59, .8) 0 38%, transparent 44%) 28px -3px / 11px 7px no-repeat,
    radial-gradient(ellipse at center, rgba(37, 75, 59, .68) 0 38%, transparent 44%) 46px 7px / 8px 12px no-repeat;
}

.waiting-player.ready::after {
  content: "❀";
  position: absolute;
  z-index: 3;
  top: -11px;
  right: 49px;
  color: var(--red);
  font-size: 16px;
  line-height: 1;
  text-shadow: 0 1px 5px rgba(155, 47, 43, .18);
  pointer-events: none;
}

.waiting-player.ready-just-now::before {
  animation: ready-vine-grow .72s cubic-bezier(.2, .72, .25, 1) both;
}

.waiting-player.ready-just-now::after {
  animation: ready-flower-bloom .38s .55s ease-out both;
}

@keyframes ready-vine-grow {
  from { width: 0; height: 0; opacity: .25; }
  55% { width: 62px; height: 0; opacity: 1; }
  to { width: 62px; height: 31px; opacity: 1; }
}

@keyframes ready-flower-bloom {
  from { opacity: 0; transform: scale(.2) rotate(-20deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

.waiting-player.away {
  opacity: .58;
  border-style: dashed;
}

.waiting-player-name {
  display: block;
  width: fit-content;
  margin: 0 auto;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: 700;
  font-size: inherit;
  color: var(--ink);
  background: transparent;
}

.waiting-player-name.remindable {
  color: var(--green);
  cursor: pointer;
  text-decoration: underline dotted rgba(37, 75, 59, .5);
  text-underline-offset: 4px;
}

.waiting-player-name.remindable:hover {
  color: var(--red);
}

.reminder-pulse {
  animation: reminder-pulse .75s ease-in-out 2;
}

@keyframes reminder-pulse {
  50% { box-shadow: 0 0 0 7px rgba(155, 47, 43, .14); transform: translateY(-2px); }
}

.remove-bot {
  position: absolute;
  right: 7px;
  top: 5px;
  border: 0;
  background: transparent;
  color: var(--red);
  font-size: 20px;
  cursor: pointer;
}

.bot-difficulty-editor {
  display: block;
  width: min(150px, 100%);
  margin: 10px auto 0;
  padding: 7px 30px 7px 10px;
  border: 1px solid rgba(37, 75, 59, .32);
  border-radius: 999px;
  background-color: rgba(255, 250, 240, .85);
  color: var(--green);
  font-size: 12px;
  text-align: center;
  cursor: pointer;
}

.bot-difficulty-editor:disabled {
  cursor: wait;
  opacity: .65;
}

.room-settings-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin: 24px auto 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .28);
  text-align: left;
}

.room-settings-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.room-settings-form select,
.room-settings-form button {
  min-height: 44px;
}

.transfer-host-button {
  margin-top: 10px;
  border: 0;
  padding: 3px 7px;
  border-radius: 7px;
  color: var(--green);
  background: rgba(37, 75, 59, .09);
  font-size: 12px;
  cursor: pointer;
}

.score-player .transfer-host-button {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: 4px;
}

.waiting-actions select {
  width: auto;
  min-width: 145px;
}

.ready-button {
  min-width: 150px;
}

.score-board {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.score-player.eliminated {
  opacity: .48;
}

.score-player {
  position: relative;
  isolation: isolate;
  transition: transform .22s ease, box-shadow .22s ease;
}

.score-player > :not(.turn-progress-frame) {
  position: relative;
  z-index: 1;
}

.score-player.active {
  z-index: 2;
  transform: scale(1.025);
  border-color: rgba(37, 75, 59, .28);
  box-shadow: 0 11px 30px rgba(37, 75, 59, .17);
}

.turn-progress-frame {
  position: absolute;
  z-index: 3;
  inset: -1px;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  overflow: visible;
  pointer-events: none;
}

.turn-progress-line {
  fill: none;
  stroke: var(--green);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 100 100;
  stroke-dashoffset: 0;
  vector-effect: non-scaling-stroke;
  transition: stroke-dasharray .12s linear, stroke .2s ease;
}

.turn-progress-frame.urgent .turn-progress-line {
  stroke: var(--red);
}

.score-player.bot-controlled:not(.eliminated) {
  border-style: dashed;
}

body.match-focus .site-header {
  display: none;
}

body.match-focus .room-topbar {
  justify-content: space-between;
  padding: 12px 0 0;
}

body.match-focus .game-layout {
  padding-top: 8px;
}

.answer-form {
  max-width: 900px;
}

.answer-form textarea {
  width: 100%;
  border: 1px solid rgba(69, 59, 44, .22);
  background: rgba(255, 255, 255, .62);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
}

.answer-form textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(37, 75, 59, .1);
}

.admin-tabs {
  grid-template-columns: repeat(4, 1fr);
  max-width: 720px;
}

.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.keyword-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .4);
}

.keyword-chip button {
  border: 0;
  background: transparent;
  color: var(--red);
  cursor: pointer;
}

.user-menu-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255, 250, 240, .72);
  color: var(--green);
  cursor: pointer;
}

.user-menu-button::after {
  content: " · 用户信息";
  color: var(--muted);
  font-size: 12px;
}

.profile-view {
  padding-bottom: 60px;
}

.profile-card {
  max-width: 720px;
}

.profile-form {
  grid-template-columns: 1fr 1fr;
  align-items: end;
}

.profile-form .profile-actions,
.profile-form .form-feedback {
  grid-column: 1 / -1;
}

.profile-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.lobby-heading-actions {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 10px;
}

.lobby-quick-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.history-dialog {
  width: min(1040px, calc(100% - 28px));
  max-height: min(86vh, calc(100dvh - 28px));
  padding: 0;
  overflow: hidden;
}

.history-dialog[open] {
  display: flex;
  flex-direction: column;
}

.history-dialog > .section-heading {
  flex: 0 0 auto;
  padding: 28px 56px 18px 30px;
  border-bottom: 1px solid var(--line);
}

.history-dialog-scroll {
  min-height: 0;
  margin: 0 8px 10px 0;
  padding: 0 14px 20px 30px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(37, 75, 59, .55) rgba(61, 51, 36, .08);
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.history-dialog-scroll::-webkit-scrollbar {
  width: 10px;
}

.history-dialog-scroll::-webkit-scrollbar-track {
  margin-block: 8px;
  border-radius: 999px;
  background: rgba(61, 51, 36, .08);
}

.history-dialog-scroll::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(37, 75, 59, .55);
  background-clip: padding-box;
}

.match-share-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 18px 0 4px;
}

.match-share-actions .secondary-button {
  padding: 10px 16px;
}

.match-share-feedback {
  color: var(--muted);
  font-size: 13px;
}

input:disabled {
  color: var(--muted);
  background: rgba(70, 65, 55, .07);
  cursor: not-allowed;
}

.timer-wrap span {
  min-width: 48px;
  text-align: right;
}

@media (prefers-reduced-motion: reduce) {
  .waiting-player.ready-just-now::before,
  .waiting-player.ready-just-now::after,
  .reminder-pulse {
    animation: none;
  }

  .score-player,
  .turn-progress-line {
    transition: none;
  }
}

@media (max-width: 800px) {
  .room-settings-form {
    grid-template-columns: 1fr;
  }

  .waiting-actions select,
  .waiting-actions button {
    width: 100%;
  }

  .profile-form {
    grid-template-columns: 1fr;
  }

  .lobby-heading-actions {
    align-items: flex-start;
  }

  .lobby-quick-actions {
    justify-content: flex-start;
  }

  .history-dialog > .section-heading {
    padding: 24px 50px 14px 20px;
  }

  .history-dialog-scroll {
    margin-right: 5px;
    padding-right: 9px;
    padding-left: 20px;
  }
}
