/* 在线房间版增量样式：沿用瑞士考试印刷品视觉系统 */

.server-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.status-dot {
  display: block;
  width: 6px;
  height: 6px;
  background: var(--faint);
}

.server-status.is-online .status-dot {
  background: #0f8a46;
}

.server-status.is-offline .status-dot {
  background: var(--red);
}

/* ---------- 首页入场 ---------- */

.entry-card {
  scroll-margin-top: 24px;
}

.entry-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--ink);
}

.entry-tab {
  padding: 12px 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  background: var(--paper);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  transition: color 150ms var(--ease), background 150ms var(--ease), border-color 150ms var(--ease);
}

.entry-tab + .entry-tab {
  border-left: 1px solid var(--line);
}

.entry-tab.is-active {
  color: #fff;
  border-bottom-color: var(--red);
  background: var(--ink);
}

.entry-tab:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.entry-form {
  display: block;
}

.entry-form .field {
  padding: 14px 18px 15px;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.text-input {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: 0;
  color: var(--ink);
  background: var(--paper);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: border-color 150ms var(--ease), outline-color 150ms var(--ease);
}

.text-input:focus {
  border-color: var(--ink);
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.text-input::placeholder {
  color: var(--faint);
  font-weight: 400;
}

.code-input {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.field-hint {
  margin-top: 7px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.02em;
  line-height: 1.6;
}

.form-error {
  margin: 0 18px 12px;
  padding: 8px 10px;
  border-left: 3px solid var(--red);
  color: var(--red);
  background: #fff5f6;
  font-size: 10px;
  line-height: 1.65;
}

/* ---------- 房间等待 ---------- */

.screen-room {
  padding-top: 40px;
  padding-bottom: 60px;
  animation: rise 500ms var(--ease) both;
}

.room-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding-bottom: 22px;
  border-bottom: 2px solid var(--ink);
}

.room-head h1 {
  margin-top: 10px;
  font-size: clamp(42px, 5.2vw, 72px);
  font-weight: 900;
  letter-spacing: -0.06em;
  line-height: 1;
}

.room-code-inline {
  color: var(--red);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.room-sub {
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.room-head-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  padding-bottom: 3px;
}

.room-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.8fr) minmax(280px, 0.9fr);
  margin-top: 22px;
  border: 1px solid var(--ink);
}

.room-code-panel,
.room-players-panel,
.room-settings-panel {
  min-width: 0;
  padding: 24px 24px 22px;
}

.room-code-panel {
  border-right: 1px solid var(--ink);
}

.room-players-panel {
  border-right: 1px solid var(--ink);
}

.room-code {
  margin: 12px 0 7px;
  color: var(--red);
  font-size: clamp(54px, 6.5vw, 92px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  line-height: 0.95;
  overflow-wrap: anywhere;
}

.room-link-label {
  margin-top: 22px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.room-link-row {
  display: flex;
  align-items: stretch;
  gap: 7px;
  margin-top: 6px;
}

.room-link-row code {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  overflow: hidden;
  padding: 8px 9px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font);
  font-size: 9px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-link-row .button-solid {
  min-width: 82px;
  padding: 8px 10px;
  font-size: 9px;
}

.room-note {
  margin-top: 9px;
  color: var(--faint);
  font-size: 9px;
  line-height: 1.65;
}

.room-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.room-panel-head h2 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.room-panel-head span {
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.16em;
}

.room-players {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.room-player {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid var(--line);
}

.room-player.is-you {
  border-color: var(--ink);
}

.room-player.is-empty {
  border-style: dashed;
  color: var(--faint);
}

.room-player-side {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: #fff;
  background: var(--ink);
  font-size: 9px;
  font-weight: 700;
}

.room-player.slot-0 .room-player-side {
  background: var(--red);
}

.room-player.is-empty .room-player-side {
  color: var(--faint);
  background: var(--line-soft);
}

.room-player-copy {
  min-width: 0;
}

.room-player-copy strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-player-copy small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.04em;
}

.room-player-state {
  color: #0f8a46;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.room-player-state.is-off {
  color: var(--red);
}

.room-status {
  margin-top: 12px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.room-settings {
  margin-top: 4px;
}

.room-settings > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.room-settings dt {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.room-settings dd {
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
}

.room-settings-panel .start-button {
  width: 100%;
  margin: 18px 0 0;
}

.room-settings-panel .start-button:disabled {
  color: var(--faint);
  border-color: var(--line);
  background: var(--line-soft);
}

.room-settings-panel .start-button:disabled .arrow {
  opacity: 0.3;
}

/* ---------- 对局 ---------- */

.online-head {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  align-items: stretch;
  gap: 26px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--ink);
}

.online-head .game-match {
  gap: 4px;
}

.room-chip {
  margin-top: 3px;
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.room-chip b {
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.score-player .you-tag {
  padding: 1px 4px;
  color: #fff;
  background: var(--red);
  font-size: 7px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.score-player .offline-tag {
  padding: 1px 4px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 7px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.score-card.is-offline .score-line strong {
  color: var(--faint);
}

.online-body {
  margin-top: 24px;
}

.question-card .q-top {
  align-items: center;
}

.question-card .q-top-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.turn-badge {
  padding: 3px 6px;
  border: 1px solid var(--red);
  color: var(--red);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.waiting-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 286px;
  min-height: 512px;
  border: 1px solid var(--ink);
}

.waiting-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 42px 44px;
}

.waiting-kicker {
  color: var(--red);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.13em;
}

.waiting-main h2 {
  margin-top: 16px;
  font-size: clamp(38px, 4.5vw, 64px);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 1.08;
}

.waiting-main p {
  max-width: 440px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.waiting-clock {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 30px;
  color: var(--red);
}

.waiting-clock span {
  font-size: clamp(56px, 7vw, 92px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.07em;
  line-height: 0.9;
}

.waiting-clock small {
  font-size: 10px;
}

.waiting-aside {
  display: flex;
  flex-direction: column;
  padding: 26px 22px 22px;
  border-left: 1px solid var(--ink);
  background: #fafafa;
}

.waiting-aside .turn-box {
  border-bottom: 1px solid var(--line);
}

.waiting-aside .mini-stats {
  margin-top: 12px;
}

.waiting-aside .rail-tip {
  margin-top: auto;
}

.waiting-dots {
  display: flex;
  gap: 5px;
  margin-top: 22px;
}

.waiting-dots i {
  display: block;
  width: 5px;
  height: 5px;
  background: var(--red);
  animation: waiting-dot 1.2s infinite ease-in-out;
}

.waiting-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.waiting-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

.countdown-stage {
  display: flex;
  min-height: 560px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 24px;
  border: 1px solid var(--ink);
  text-align: center;
}

.countdown-stage .countdown-kicker {
  color: var(--red);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.18em;
}

.countdown-number {
  margin: 8px 0 2px;
  color: var(--red);
  font-size: clamp(130px, 17vw, 210px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.09em;
  line-height: 0.9;
}

.countdown-stage p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.countdown-players {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
  font-size: 11px;
  font-weight: 600;
}

.countdown-players span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.countdown-players i {
  display: block;
  width: 8px;
  height: 8px;
  background: var(--ink);
}

.countdown-players span:first-child i {
  background: var(--red);
}

.sprint-last {
  margin: -8px 0 18px;
  padding: 8px 10px;
  border-left: 3px solid var(--ink);
  color: var(--muted);
  background: var(--wash);
  font-size: 10px;
  line-height: 1.65;
}

.sprint-last.is-good {
  border-left-color: #0f8a46;
}

.sprint-last.is-bad {
  border-left-color: var(--red);
}

.sprint-last b {
  color: var(--ink);
  font-weight: 600;
}

.sprint-done {
  display: flex;
  min-height: 480px;
  flex-direction: column;
  justify-content: center;
  padding: 38px 40px;
}

.sprint-done h2 {
  margin-top: 12px;
  font-size: clamp(36px, 4.5vw, 60px);
  font-weight: 800;
  letter-spacing: -0.05em;
}

.sprint-done p {
  max-width: 460px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.opponent-mini {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.opponent-mini .rail-label {
  margin-bottom: 5px;
}

.opponent-mini strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opponent-mini span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.sprint-done-badge {
  display: inline-flex;
  align-self: flex-start;
  padding: 4px 7px;
  color: #fff;
  background: var(--ink);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.auto-next {
  margin-top: 10px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.03em;
}

.verdict .verdict-answer {
  margin-top: 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.verdict .verdict-answer span {
  color: var(--red);
}

/* ---------- 结果补充 ---------- */

.result-actions .is-waiting {
  display: inline-flex;
  align-items: center;
  padding: 12px 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.result-card .you-tag {
  margin-left: 2px;
  padding: 1px 4px;
  color: #fff;
  background: var(--red);
  font-size: 7px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.result-card.is-you {
  border-top: 4px solid var(--ink);
}

.result-card.is-winner.is-you {
  border-top-color: var(--red);
}

/* ---------- 连接状态 / 通知 ---------- */

.conn-banner {
  position: fixed;
  z-index: 190;
  right: 24px;
  bottom: 24px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 48px);
  padding: 10px 13px;
  color: #fff;
  background: var(--ink);
  font-size: 10px;
  letter-spacing: 0.03em;
  line-height: 1.5;
}

.conn-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  background: var(--red);
  animation: clock-pulse 900ms infinite;
}

.conn-banner.is-recovered .conn-dot {
  background: #64d89a;
  animation: none;
}

.notice {
  position: fixed;
  z-index: 260;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--paper);
}

.notice-panel {
  width: min(520px, 100%);
  padding: 38px 40px 32px;
  border: 1px solid var(--ink);
  border-top: 7px solid var(--red);
  background: var(--paper);
  animation: overlay-in 320ms var(--ease) both;
}

.notice-kicker {
  color: var(--red);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.notice-panel h2 {
  margin-top: 12px;
  font-size: clamp(34px, 4.2vw, 48px);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1.1;
}

.notice-text {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.notice-panel .overlay-button {
  margin-top: 22px;
}

@keyframes waiting-dot {
  0%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* ---------- responsive additions ---------- */

@media (max-width: 1180px) {
  .room-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
  }

  .room-settings-panel {
    grid-column: 1 / -1;
    border-top: 1px solid var(--ink);
  }

  .room-players-panel {
    border-right: 0;
  }
}

@media (max-width: 940px) {
  .online-head {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .online-head .game-match {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
  }

  .room-grid {
    grid-template-columns: 1fr;
  }

  .room-code-panel,
  .room-players-panel {
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .room-settings-panel {
    grid-column: auto;
    border-top: 0;
  }

  .waiting-body {
    grid-template-columns: 1fr;
  }

  .waiting-aside {
    border-top: 1px solid var(--ink);
    border-left: 0;
  }
}

@media (max-width: 720px) {
  .server-status span:last-child {
    display: none;
  }

  .masthead-tools {
    gap: 11px;
  }

  .screen-room {
    padding-top: 28px;
    padding-bottom: 42px;
  }

  .room-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .room-head h1 {
    font-size: clamp(38px, 11vw, 54px);
  }

  .room-head-actions {
    width: 100%;
  }

  .room-head-actions .button-line {
    flex: 1;
  }

  .room-code-panel,
  .room-players-panel,
  .room-settings-panel {
    padding: 18px;
  }

  .room-code {
    font-size: clamp(48px, 15vw, 72px);
  }

  .room-link-row {
    flex-direction: column;
  }

  .room-link-row .button-solid {
    width: 100%;
  }

  .entry-form .field {
    padding: 13px 14px 14px;
  }

  .form-error {
    margin-right: 14px;
    margin-left: 14px;
  }

  .online-head {
    padding-bottom: 12px;
  }

  .online-head .game-match {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 3px 12px;
  }

  .online-head .game-match > span:first-child {
    grid-column: 1;
  }

  .online-head .game-match > strong {
    grid-column: 1;
  }

  .online-head .room-chip {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    margin: 0;
  }

  .waiting-body {
    min-height: 0;
  }

  .waiting-main {
    padding: 28px 20px;
  }

  .waiting-main h2 {
    font-size: clamp(32px, 9vw, 44px);
  }

  .waiting-clock span {
    font-size: 58px;
  }

  .waiting-aside {
    padding: 18px;
  }

  .countdown-stage {
    min-height: 420px;
  }

  .countdown-number {
    font-size: clamp(108px, 30vw, 150px);
  }

  .countdown-players {
    flex-direction: column;
    gap: 6px;
    margin-top: 16px;
  }

  .sprint-done {
    min-height: 0;
    padding: 28px 20px;
  }

  .conn-banner {
    right: 14px;
    bottom: 14px;
    left: 14px;
    max-width: none;
  }

  .notice {
    padding: 14px;
  }

  .notice-panel {
    padding: 28px 24px 24px;
  }
}
