/* SGCC online base — dark slate + parchment/gold. Mobile first, no external assets. */

:root {
  color-scheme: dark;
  --bg: #0b1220;
  --bg-deep: #080e19;
  --panel: #141f35;
  --panel-2: #182642;
  --panel-line: rgba(231, 200, 127, 0.18);
  --parchment: #f3e9d2;
  --parchment-strong: #fff7e6;
  --muted: #9aa9c2;
  --muted-2: #7384a1;
  --gold: #e7c87f;
  --gold-strong: #f4dda3;
  --gold-dim: #b9964e;
  --success: #6fd6a8;
  --warn: #f4b860;
  --danger: #ff8f7f;
  --radius: 14px;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(1100px 560px at 50% -12%, rgba(231, 200, 127, 0.1), transparent 62%),
    radial-gradient(760px 480px at 105% 105%, rgba(61, 90, 140, 0.2), transparent 62%),
    linear-gradient(180deg, #0a1120 0%, #0d1729 46%, var(--bg-deep) 100%);
  color: var(--parchment);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.012) 0,
    rgba(255, 255, 255, 0.012) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.5;
  z-index: 0;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

a {
  color: var(--gold-strong);
}

code {
  padding: 0.08em 0.38em;
  border: 1px solid rgba(231, 200, 127, 0.24);
  border-radius: 6px;
  background: rgba(8, 14, 25, 0.72);
  color: var(--gold-strong);
  font-family: var(--mono);
  font-size: 0.9em;
  word-break: break-all;
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 980px;
  min-height: 100svh;
  margin: 0 auto;
  padding: clamp(12px, 2.6vw, 24px);
  gap: clamp(10px, 1.8vw, 16px);
}

/* ------------------------------------------------------------------ */
/* Header                                                              */
/* ------------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(231, 200, 127, 0.55);
  border-radius: 11px;
  background:
    linear-gradient(150deg, rgba(244, 221, 163, 0.2), transparent 62%),
    #162137;
  color: var(--gold-strong);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  color: var(--parchment-strong);
  font-size: 15px;
  letter-spacing: 0.16em;
}

.brand-text span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 4px 11px;
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  background: rgba(20, 31, 53, 0.82);
  color: var(--parchment);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.mode-badge[data-mode="cloud"] {
  border-color: rgba(231, 200, 127, 0.52);
  background: rgba(185, 150, 78, 0.16);
  color: var(--gold-strong);
}

.mode-badge[data-mode="lan"] {
  border-color: rgba(111, 214, 168, 0.46);
  background: rgba(41, 112, 88, 0.2);
  color: #a9efcf;
}

.conn-badge .conn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 0 0 0 rgba(154, 169, 194, 0.4);
}

.conn-badge[data-state="connecting"] .conn-dot,
.conn-badge[data-state="reconnecting"] .conn-dot {
  background: var(--warn);
  animation: dot-pulse 1.25s ease-out infinite;
}

.conn-badge[data-state="online"] .conn-dot {
  background: var(--success);
  box-shadow: 0 0 9px rgba(111, 214, 168, 0.75);
}

.conn-badge[data-state="offline"] .conn-dot {
  background: var(--danger);
}

.conn-badge[data-state="online"] {
  border-color: rgba(111, 214, 168, 0.34);
  color: #abedd0;
}

.conn-badge[data-state="reconnecting"],
.conn-badge[data-state="connecting"] {
  border-color: rgba(244, 184, 96, 0.4);
  color: #ffd89d;
}

.conn-badge[data-state="offline"] {
  border-color: rgba(255, 143, 127, 0.42);
  color: #ffb9ad;
}

@keyframes dot-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(244, 184, 96, 0.55);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(244, 184, 96, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(244, 184, 96, 0);
  }
}

/* ------------------------------------------------------------------ */
/* Degrade banner & config warning                                     */
/* ------------------------------------------------------------------ */

.degrade-banner {
  overflow-y: auto;
  max-height: min(54vh, 460px);
  padding: 14px 16px 16px;
  border: 1px solid rgba(244, 184, 96, 0.5);
  border-radius: var(--radius);
  background:
    linear-gradient(150deg, rgba(244, 184, 96, 0.12), transparent 46%),
    #231a12;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.32);
  scrollbar-width: thin;
  scrollbar-color: rgba(231, 200, 127, 0.4) transparent;
}

.degrade-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.degrade-head h2 {
  margin: 2px 0 6px;
  color: #ffd89d;
  font-size: 20px;
  line-height: 1.2;
}

.degrade-body {
  color: #f2dfbf;
  font-size: 14px;
}

.degrade-body p {
  margin: 8px 0;
}

.steps {
  margin: 8px 0 12px;
  padding-left: 1.25rem;
  color: #e9d6b6;
}

.steps li {
  margin: 5px 0;
}

.degrade-actions {
  align-items: center;
  margin-top: 12px;
}

.degrade-actions .hint {
  flex: 1 1 220px;
}

.config-warning {
  padding: 11px 14px;
  border: 1px solid rgba(255, 143, 127, 0.4);
  border-radius: 12px;
  background: rgba(72, 27, 24, 0.5);
  color: #ffc9bf;
  font-size: 13px;
  line-height: 1.55;
}

/* ------------------------------------------------------------------ */
/* Layout & common blocks                                              */
/* ------------------------------------------------------------------ */

.main {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: screen-in 0.2s ease-out both;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero {
  padding: 4px 2px 2px;
}

.hero h1 {
  margin: 0 0 4px;
  color: var(--parchment-strong);
  font-size: clamp(22px, 5vw, 32px);
  line-height: 1.18;
  letter-spacing: 0.01em;
}

.hero .lede {
  margin: 0;
  max-width: 58ch;
  color: var(--muted);
  font-size: 14px;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.panel {
  position: relative;
  padding: clamp(16px, 3vw, 24px);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(24, 38, 66, 0.94), rgba(16, 26, 46, 0.94));
  box-shadow: var(--shadow);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 18px auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(244, 221, 163, 0.55), transparent);
  pointer-events: none;
}

.field-label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid rgba(231, 200, 127, 0.26);
  border-radius: 11px;
  background: #0b1526;
  color: var(--parchment-strong);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: #667794;
}

.input:focus {
  border-color: rgba(244, 221, 163, 0.8);
  box-shadow: 0 0 0 3px rgba(231, 200, 127, 0.16);
}

.room-input {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.inline-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-row .input {
  flex: 1 1 180px;
  min-width: 0;
}

.hint {
  margin: 6px 0 0;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.5;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 3px 10px;
  border: 1px solid rgba(231, 200, 127, 0.28);
  border-radius: 999px;
  background: rgba(231, 200, 127, 0.08);
  color: var(--gold-strong);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill b {
  font-size: 14px;
}

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform 0.12s ease, filter 0.15s ease, background 0.15s ease,
    border-color 0.15s ease;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: 2px solid var(--gold-strong);
  outline-offset: 2px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  filter: saturate(0.55);
}

.btn-primary {
  border-color: rgba(255, 240, 199, 0.62);
  background: linear-gradient(180deg, var(--gold-strong), #d4ad5c);
  color: #211707;
  box-shadow: 0 8px 22px rgba(185, 150, 78, 0.22);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-secondary {
  border-color: rgba(231, 200, 127, 0.46);
  background: rgba(231, 200, 127, 0.08);
  color: var(--gold-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(231, 200, 127, 0.15);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: var(--parchment);
}

.btn-small {
  min-height: 34px;
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 9px;
}

.btn-wide {
  width: 100%;
}

.btn-action {
  width: 100%;
  min-height: 58px;
  font-size: 19px;
  letter-spacing: 0.2em;
  border-radius: 13px;
}

.action-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* ------------------------------------------------------------------ */
/* Lobby                                                               */
/* ------------------------------------------------------------------ */

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 18px;
}

.lobby-action {
  min-width: 0;
}

.notes {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed rgba(231, 200, 127, 0.18);
  color: var(--muted);
  font-size: 12.5px;
}

.notes p {
  margin: 4px 0;
}

.notes strong {
  color: var(--gold);
}

.lobby-message {
  margin: 12px 0 0;
  padding: 9px 12px;
  border: 1px solid rgba(255, 143, 127, 0.38);
  border-radius: 10px;
  background: rgba(72, 27, 24, 0.42);
  color: #ffc9bf;
  font-size: 13px;
}

.mode-switch {
  display: inline-block;
  margin-top: 14px;
  color: var(--gold-strong);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(231, 200, 127, 0.35);
  padding-bottom: 1px;
}

.mode-switch:hover {
  color: #fff2cf;
  border-bottom-color: var(--gold-strong);
}

/* ------------------------------------------------------------------ */
/* Room                                                                */
/* ------------------------------------------------------------------ */

.room-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.room-code {
  margin-top: 2px;
  color: var(--gold-strong);
  font-family: var(--mono);
  font-size: clamp(30px, 8vw, 46px);
  font-weight: 700;
  letter-spacing: 0.18em;
  line-height: 1.05;
  text-shadow: 0 0 24px rgba(231, 200, 127, 0.18);
}

.room-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.room-status {
  color: var(--muted);
  font-size: 12.5px;
}

.players {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 18px;
}

.player-card {
  padding: 13px 14px;
  border: 1px solid rgba(231, 200, 127, 0.16);
  border-radius: 12px;
  background: rgba(9, 16, 29, 0.5);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.player-card.is-you {
  border-color: rgba(231, 200, 127, 0.55);
  background:
    linear-gradient(150deg, rgba(231, 200, 127, 0.12), transparent 58%),
    rgba(9, 16, 29, 0.5);
}

.player-card.is-empty {
  border-style: dashed;
  opacity: 0.78;
}

.player-card.is-offline {
  border-color: rgba(255, 143, 127, 0.28);
}

.player-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.player-name {
  overflow: hidden;
  color: var(--parchment-strong);
  font-size: 16px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.you-tag {
  flex: none;
  padding: 1px 7px;
  border: 1px solid rgba(231, 200, 127, 0.45);
  border-radius: 999px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.player-meta {
  display: flex;
  gap: 14px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.player-meta span:first-child::before {
  content: "连接：";
  color: var(--muted-2);
}

.player-meta span:last-child::before {
  content: "状态：";
  color: var(--muted-2);
}

/* ------------------------------------------------------------------ */
/* Game                                                                */
/* ------------------------------------------------------------------ */

.game-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.turn-text {
  margin: 4px 0 0;
  color: var(--parchment-strong);
  font-size: clamp(19px, 4vw, 24px);
  line-height: 1.2;
}

.scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.score-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 14px 10px 12px;
  border: 1px solid rgba(231, 200, 127, 0.16);
  border-radius: 12px;
  background: rgba(9, 16, 29, 0.48);
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.score-card.is-you {
  border-color: rgba(231, 200, 127, 0.46);
}

.score-card.is-turn {
  border-color: rgba(244, 221, 163, 0.78);
  background:
    linear-gradient(180deg, rgba(231, 200, 127, 0.13), transparent 70%),
    rgba(9, 16, 29, 0.48);
  box-shadow: 0 0 0 1px rgba(231, 200, 127, 0.14) inset;
}

.score-name {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-value {
  color: var(--gold-strong);
  font-family: var(--mono);
  font-size: clamp(34px, 9vw, 48px);
  font-weight: 700;
  line-height: 1.05;
}

.turn-mark {
  padding: 1px 8px;
  border: 1px solid rgba(244, 221, 163, 0.4);
  border-radius: 999px;
  color: var(--gold-strong);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.log-panel {
  margin-top: 18px;
  padding-top: 13px;
  border-top: 1px dashed rgba(231, 200, 127, 0.18);
}

.log-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.log-head h2 {
  margin: 0;
  color: var(--parchment);
  font-size: 14px;
  letter-spacing: 0.06em;
}

.log-head .hint {
  margin: 0;
}

.game-log {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 150px;
  margin: 9px 0 0;
  padding: 0 2px 0 0;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(231, 200, 127, 0.32) transparent;
}

.game-log li {
  padding: 6px 9px;
  border-left: 2px solid rgba(231, 200, 127, 0.3);
  border-radius: 0 7px 7px 0;
  background: rgba(9, 16, 29, 0.44);
  color: #d9d2c1;
  font-size: 12.5px;
  line-height: 1.4;
}

.game-log li.is-empty {
  border-left-color: transparent;
  background: transparent;
  color: var(--muted-2);
  padding-left: 0;
}

/* ------------------------------------------------------------------ */
/* Ended                                                               */
/* ------------------------------------------------------------------ */

.ended-panel {
  padding: clamp(24px, 5vw, 40px);
  text-align: center;
}

.winner-text {
  margin: 8px 0 6px;
  color: var(--gold-strong);
  font-size: clamp(28px, 7vw, 44px);
  line-height: 1.15;
  text-shadow: 0 0 32px rgba(231, 200, 127, 0.16);
}

.ended-detail {
  margin: 0 auto;
  max-width: 46ch;
  color: var(--muted);
  font-size: 14px;
}

.ended-actions {
  justify-content: center;
  flex-wrap: wrap;
}

.ended-actions .btn {
  flex: 1 1 160px;
  max-width: 240px;
}

/* ------------------------------------------------------------------ */
/* Footer & toast                                                      */
/* ------------------------------------------------------------------ */

.footer {
  padding: 6px 2px 2px;
  color: var(--muted-2);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-align: center;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 14px;
  z-index: 80;
  max-width: 560px;
  margin: 0 auto;
  padding: 11px 15px;
  border: 1px solid rgba(231, 200, 127, 0.42);
  border-radius: 12px;
  background: rgba(20, 31, 53, 0.97);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.5);
  color: var(--parchment-strong);
  font-size: 13.5px;
  line-height: 1.45;
  animation: toast-in 0.18s ease-out both;
}

.toast[data-kind="error"] {
  border-color: rgba(255, 143, 127, 0.55);
  background: rgba(58, 24, 23, 0.97);
  color: #ffd6cd;
}

.toast[data-kind="success"] {
  border-color: rgba(111, 214, 168, 0.5);
  background: rgba(16, 45, 37, 0.97);
  color: #c4f3df;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (min-width: 620px) {
  .lobby-grid {
    grid-template-columns: 1fr 1.25fr;
    align-items: start;
  }

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

  .room-head {
    align-items: center;
  }
}

@media (max-width: 420px) {
  .brand-text span {
    letter-spacing: 0.18em;
  }

  .btn {
    padding-right: 14px;
    padding-left: 14px;
  }

  .ended-actions .btn {
    flex-basis: 100%;
    max-width: none;
  }
}

@media (max-height: 700px) {
  .app {
    gap: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .main {
    justify-content: flex-start;
  }

  .hero h1 {
    font-size: 22px;
  }

  .hero .lede {
    font-size: 13px;
  }

  .panel {
    padding: 14px;
  }

  .score-value {
    font-size: 34px;
  }

  .game-log {
    max-height: 104px;
  }

  .footer {
    padding-top: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
