:root {
  color-scheme: light;
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  background: #f4f8ff;
  color: #283044;
  --panel: rgba(255, 255, 255, 0.76);
  --panel-soft: rgba(247, 242, 255, 0.82);
  --panel-strong: rgba(230, 240, 255, 0.9);
  --line: rgba(145, 157, 206, 0.44);
  --text-muted: #6d7891;
  --accent: #ff9fbd;
  --cyan: #78ccef;
  --correct: #23ba79;
  --close: #c98f2e;
  --miss: #c9d1e6;
  --error: #ef6680;
}

* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

html {
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 8%, rgba(130, 211, 255, 0.5), transparent 34rem),
    radial-gradient(circle at 78% 12%, rgba(255, 172, 207, 0.46), transparent 32rem),
    radial-gradient(circle at 44% 52%, rgba(203, 184, 255, 0.36), transparent 42rem),
    linear-gradient(135deg, #eef9ff 0%, #f6eeff 42%, #ffeaf4 72%, #e9f7ff 100%);
  background-attachment: fixed;
}

button,
input {
  font: inherit;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: 24px clamp(12px, 2.4vw, 32px);
}

.page-frame {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  margin: 0 auto;
}

.app-root {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
}

.side-portrait {
  --side-width: calc((100vw - 1080px) / 2);
  position: fixed;
  top: 0;
  z-index: 0;
  width: var(--side-width);
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow: visible;
}

.side-portrait-left {
  left: 0;
}

.side-portrait-right {
  right: 0;
}

.side-portrait img {
  object-fit: contain;
  opacity: 0.96;
  filter: drop-shadow(0 24px 32px rgba(0, 0, 0, 0.45));
}

.side-portrait-left img {
  width: auto;
  height: min(82vh, 960px);
  max-height: calc(100vh - 40px);
}

.side-portrait-right img {
  width: min(744px, 63.55vh);
  height: auto;
  max-height: calc(100vh - 40px);
}

.home-surface,
.game-surface {
  position: relative;
  isolation: isolate;
  z-index: 2;
  width: 100%;
  max-width: 1080px;
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.home-surface {
  justify-content: center;
}

.topbar,
.control-panel,
.feedback-legend,
.board-wrap,
.home-hero,
.mode-card {
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.84), rgba(242, 247, 255, 0.74)),
    var(--panel);
  box-shadow: 0 20px 52px rgba(112, 127, 186, 0.18);
  backdrop-filter: blur(18px);
}

.home-hero {
  min-height: 132px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border-radius: 8px;
}

.home-meta {
  min-width: 100px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 244, 255, 0.9);
}

.home-meta span,
.mode-eyebrow {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.home-meta strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.home-hero-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.home-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.home-nav button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  color: #536080;
  background: transparent;
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.home-nav button:hover,
.home-nav button:focus-visible {
  color: #344167;
  background: rgba(231, 242, 255, 0.82);
}

.home-nav .account-chip {
  max-width: 168px;
  overflow: hidden;
  border: 1px solid rgba(255, 159, 189, 0.56);
  background: rgba(255, 235, 244, 0.76);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.mode-card {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  border-radius: 8px;
  color: #283044;
  text-align: left;
  cursor: pointer;
}

.mode-card:hover,
.mode-card:focus {
  border-color: rgba(255, 143, 183, 0.72);
  box-shadow: 0 22px 54px rgba(164, 139, 207, 0.24);
  transform: translateY(-1px);
}

.mode-card strong {
  font-size: 24px;
}

.mode-card small {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.primary-mode {
  background:
    linear-gradient(135deg, rgba(255, 214, 229, 0.94), rgba(221, 242, 255, 0.86)),
    var(--panel);
}

.match-home-surface {
  justify-content: center;
}

.match-lobby-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 16px;
}

.matchmaking-panel,
.match-rules-panel,
.match-scoreboard {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(242, 247, 255, 0.76)),
    var(--panel);
  box-shadow: 0 20px 52px rgba(112, 127, 186, 0.18);
  backdrop-filter: blur(18px);
}

.matchmaking-panel {
  min-height: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}

.matchmaking-panel h2,
.match-rules-panel h2 {
  margin: 8px 0;
  font-size: 24px;
  letter-spacing: 0;
}

.match-state-detail {
  min-height: 24px;
  margin: 4px 0 18px;
  color: var(--text-muted);
}

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

.room-entry-mark {
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  border: 1px solid rgba(120, 204, 239, 0.72);
  border-radius: 50%;
  color: #3e4a79;
  background: rgba(231, 242, 255, 0.72);
  font-size: 34px;
  font-weight: 850;
}

.room-entry-actions {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
}

.room-entry-actions > .primary-button {
  width: 100%;
}

.room-entry-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.room-entry-divider::before,
.room-entry-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.room-join-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

#room-code-input {
  width: 100%;
  min-width: 0;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: #283044;
  background: rgba(255, 255, 255, 0.86);
  font-weight: 750;
  outline: none;
  text-transform: uppercase;
}

#room-code-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(120, 204, 239, 0.24);
}

.room-code {
  margin: 8px 0 4px;
  color: #3e4a79;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 42px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  user-select: all;
}

.room-status-copy {
  min-height: 24px;
  margin: 6px 0 18px;
  color: var(--text-muted);
}

.room-error {
  width: min(500px, 100%);
  margin: 0 0 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--error);
  color: #99425a;
  background: rgba(255, 232, 239, 0.72);
  font-size: 13px;
  text-align: left;
}

.room-player-list {
  width: min(520px, 100%);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.room-player-row {
  min-height: 66px;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.room-player-row + .room-player-row {
  border-top: 1px solid var(--line);
}

.room-player-row.is-empty {
  color: var(--text-muted);
}

.room-player-index {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.room-player-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-host-label {
  display: inline-block;
  margin-left: 8px;
  color: #6d7891;
  font-size: 10px;
  font-weight: 700;
}

.room-ready-state {
  min-width: 58px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.56);
  font-size: 11px;
  font-weight: 750;
  text-align: center;
}

.room-ready-state.is-ready {
  border-color: rgba(35, 186, 121, 0.4);
  color: #197352;
  background: rgba(209, 245, 229, 0.72);
}

.room-ready-state.is-offline {
  border-color: rgba(239, 102, 128, 0.36);
  color: #99425a;
  background: rgba(255, 232, 239, 0.72);
}

.room-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

.match-action-button {
  min-width: 132px;
}

.match-radar {
  position: relative;
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  margin-bottom: 24px;
  border: 1px solid rgba(120, 204, 239, 0.72);
  border-radius: 50%;
  color: #3e4a79;
  background: rgba(231, 242, 255, 0.72);
  font-size: 24px;
  font-weight: 850;
  overflow: hidden;
}

.match-radar::before,
.match-radar::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 159, 189, 0.48);
  border-radius: 50%;
}

.match-radar::before {
  inset: 19px;
}

.match-radar::after {
  inset: 38px;
}

.match-radar i {
  position: absolute;
  inset: 50% 50% auto;
  width: 48%;
  height: 1px;
  transform-origin: left center;
  background: var(--accent);
}

.match-radar.is-active i {
  animation: match-radar-sweep 1.6s linear infinite;
}

.match-radar.is-active > span:first-child:not(:empty) {
  position: relative;
  z-index: 1;
}

.match-radar.has-error {
  border-color: rgba(239, 102, 128, 0.6);
  color: var(--error);
  background: rgba(255, 232, 239, 0.82);
}

.queue-time {
  min-width: 88px;
  margin: 4px 0;
  color: #3e4a79;
  font-size: 32px;
  font-variant-numeric: tabular-nums;
}

.match-rules-panel {
  min-height: 380px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px;
}

.match-rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 24px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.match-rule-grid > div {
  min-height: 94px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.match-rule-grid strong,
.match-rule-grid span {
  display: block;
}

.match-rule-grid strong {
  color: #3e4a79;
  font-size: 18px;
}

.match-rule-grid span {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 12px;
}

.match-rule-note {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.65;
}

.match-scoreboard {
  min-height: 142px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 156px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
}

.match-player-card {
  min-width: 0;
  text-align: right;
}

.match-player-card.is-you {
  text-align: left;
}

.match-player-card strong,
.match-player-card small,
.match-player-label {
  display: block;
}

.match-player-card strong {
  overflow: hidden;
  margin-top: 4px;
  color: #344167;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-player-card small {
  margin-top: 4px;
  color: var(--text-muted);
}

.match-player-score {
  display: block;
  min-height: 42px;
  margin-top: 6px;
  color: #3e4a79;
  font-size: 38px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.match-opportunity-state {
  min-height: 18px;
  font-variant-numeric: tabular-nums;
}

.match-player-label {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.match-clock {
  text-align: center;
}

.match-clock span,
.match-clock strong,
.match-clock small,
.match-clock b {
  display: block;
}

.match-clock span {
  color: var(--text-muted);
  font-size: 11px;
}

.match-clock strong {
  margin-top: 3px;
  color: #3e4a79;
  font-size: 30px;
  font-variant-numeric: tabular-nums;
}

.match-clock small {
  min-height: 18px;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}

.match-clock b {
  margin-top: 7px;
  color: #57648d;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.match-round-track {
  min-height: 60px;
  display: grid;
  grid-template-columns: repeat(5, minmax(48px, 68px));
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
}

.match-round-step {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
}

.match-round-step b {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(248, 244, 255, 0.86);
  color: #6c7598;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.match-round-step small {
  min-height: 15px;
  overflow: hidden;
  font-size: 10px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-round-step.is-active b {
  border-color: rgba(103, 184, 224, 0.88);
  background: rgba(221, 242, 255, 0.94);
  color: #365e86;
  box-shadow: 0 0 0 4px rgba(120, 204, 239, 0.16);
}

.match-round-step.is-win b {
  border-color: rgba(38, 181, 126, 0.58);
  background: rgba(209, 245, 229, 0.94);
  color: #197352;
}

.match-round-step.is-loss b {
  border-color: rgba(224, 126, 157, 0.45);
  background: rgba(255, 226, 237, 0.88);
  color: #9a4e69;
}

.match-round-step.is-draw b,
.match-round-step.is-revealed b {
  border-color: rgba(201, 143, 46, 0.46);
  background: rgba(255, 232, 188, 0.86);
  color: #8a672c;
}

.match-search-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.match-result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 2px 0;
}

.match-result-actions:empty {
  display: none;
}

.match-rating-result {
  flex: 1 0 100%;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

.match-rating-result.is-positive,
.history-rating.is-positive {
  color: #197352;
}

.match-rating-result.is-negative,
.history-rating.is-negative,
.match-rating-result.is-error {
  color: #a14661;
}

.data-surface {
  justify-content: flex-start;
}

.data-header {
  flex: 0 0 auto;
}

.data-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-surface,
.data-panel,
.current-rank-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(244, 240, 255, 0.76)),
    var(--panel);
  box-shadow: 0 20px 52px rgba(112, 127, 186, 0.18);
  backdrop-filter: blur(18px);
}

.account-surface,
.data-panel {
  min-height: 480px;
  padding: 24px;
}

.profile-summary {
  min-height: 108px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.profile-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-avatar {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 159, 189, 0.62);
  border-radius: 8px;
  color: #49547a;
  background: linear-gradient(145deg, #ffd6e5, #dcefff);
  font-size: 22px;
  font-weight: 850;
}

.profile-identity h2 {
  max-width: min(460px, 58vw);
  overflow: hidden;
  margin: 4px 0;
  color: #303a58;
  font-size: 24px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-identity p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.profile-rating {
  min-width: 112px;
  text-align: right;
}

.profile-rating span,
.profile-stats span,
.current-rank-strip span,
.registered-actions small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
}

.profile-rating strong {
  display: block;
  margin-top: 2px;
  color: #3e4a79;
  font-size: 32px;
  font-variant-numeric: tabular-nums;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.profile-stats > div {
  min-height: 76px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.profile-stats strong {
  margin-top: 4px;
  color: #3e4a79;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.placement-progress {
  position: relative;
  height: 26px;
  overflow: hidden;
  margin-bottom: 20px;
  border-radius: 4px;
  background: rgba(218, 226, 245, 0.68);
}

.placement-progress > span {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--progress);
  background: linear-gradient(90deg, rgba(120, 204, 239, 0.72), rgba(255, 159, 189, 0.76));
}

.placement-progress small {
  position: relative;
  z-index: 1;
  display: block;
  padding: 5px 10px;
  color: #4d5878;
  font-size: 11px;
  text-align: center;
}

.auth-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.auth-form {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 24px;
}

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

.form-heading h3 {
  margin: 5px 0 0;
  font-size: 20px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.auth-form input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: #283044;
  background: rgba(255, 255, 255, 0.82);
  outline: none;
}

.auth-form input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(120, 204, 239, 0.22);
}

.auth-form .primary-button,
.auth-form .secondary-button {
  width: 100%;
  margin-top: auto;
}

.form-message {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--cyan);
  background: rgba(231, 242, 255, 0.72);
  font-size: 13px;
}

.form-message.is-error {
  border-left-color: var(--error);
  color: #99425a;
  background: rgba(255, 232, 239, 0.72);
}

.registered-actions {
  min-height: 98px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--line);
  padding: 20px 4px 0;
}

.registered-actions strong,
.registered-actions small {
  display: block;
  margin-top: 4px;
}

.current-rank-strip {
  min-height: 82px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 0 20px;
}

.current-rank-strip > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 18px;
}

.current-rank-strip > div + div {
  border-left: 1px solid var(--line);
}

.current-rank-strip strong {
  overflow: hidden;
  margin-top: 4px;
  color: #3e4a79;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-list {
  border-top: 1px solid var(--line);
}

.history-row {
  min-height: 76px;
  display: grid;
  grid-template-columns: 42px minmax(180px, 1fr) 80px 82px 110px;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.history-result {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #5f6881;
  background: rgba(226, 231, 246, 0.88);
}

.history-row.is-win .history-result {
  color: #197352;
  background: rgba(209, 245, 229, 0.88);
}

.history-row.is-loss .history-result {
  color: #9a4e69;
  background: rgba(255, 226, 237, 0.88);
}

.history-row.is-draw .history-result {
  color: #8a672c;
  background: rgba(255, 232, 188, 0.86);
}

.history-opponent {
  min-width: 0;
}

.history-opponent span,
.history-opponent strong {
  display: block;
}

.history-opponent span,
.history-row time,
.history-rating {
  color: var(--text-muted);
  font-size: 12px;
}

.history-opponent strong {
  overflow: hidden;
  margin-top: 3px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-score,
.history-rating {
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.history-row time {
  text-align: right;
}

.leaderboard-panel {
  padding: 10px 18px 18px;
}

.leaderboard-table-wrap {
  overflow-x: auto;
}

.leaderboard-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
  height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
  text-align: left;
  white-space: nowrap;
}

.leaderboard-table th {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
}

.leaderboard-table td {
  font-size: 13px;
}

.leaderboard-table tr.is-current td {
  background: rgba(255, 226, 237, 0.48);
}

.loading-state,
.empty-data-state {
  min-height: 390px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  text-align: center;
}

.loading-state span {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(145, 157, 206, 0.28);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

.empty-data-state strong {
  color: #3e4a79;
  font-size: 18px;
}

.empty-data-state span {
  font-size: 13px;
}

.empty-data-state.is-error strong {
  color: #99425a;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes match-radar-sweep {
  to {
    transform: rotate(360deg);
  }
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-radius: 8px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 159, 189, 0.68);
  border-radius: 8px;
  background: linear-gradient(145deg, #ffd4e3, #d8efff);
  color: #3e4a79;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand-lockup p,
.eyebrow,
.status-label {
  color: var(--text-muted);
}

.brand-lockup p {
  margin: 4px 0 0;
}

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

.status-strip {
  display: flex;
  gap: 10px;
}

.status-strip > div {
  min-width: 92px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 244, 255, 0.9);
}

.status-label {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
}

.status-strip strong {
  font-size: 20px;
}

.control-panel {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(280px, 0.62fr) minmax(360px, 1fr);
  gap: 16px;
  padding: 18px;
  border-radius: 8px;
  overflow: visible;
}

.mystery-card {
  min-height: 104px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(245, 241, 255, 0.96), rgba(232, 246, 255, 0.9));
}

.mystery-avatar,
.answer-avatar {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  border-radius: 8px;
}

.mystery-avatar {
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 143, 183, 0.75);
  color: var(--accent);
  font-size: 30px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.78);
}

.answer-avatar {
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.eyebrow {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  text-transform: uppercase;
}

.mystery-card strong {
  display: block;
  font-size: 20px;
}

.mystery-card small {
  display: block;
  margin-top: 5px;
  color: var(--text-muted);
}

.guess-form {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guess-form label {
  color: var(--text-muted);
  font-size: 13px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

#guess-input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: #283044;
  background: rgba(255, 255, 255, 0.86);
  outline: none;
}

#guess-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(120, 204, 239, 0.24);
}

#guess-input::placeholder {
  color: #8b94aa;
}

.primary-button,
.secondary-button,
.icon-button,
.suggestion-item {
  border: 0;
  cursor: pointer;
}

.primary-button {
  height: 48px;
  min-width: 88px;
  border-radius: 8px;
  padding: 0 18px;
  color: #2e3146;
  background: linear-gradient(135deg, #ff9fbd, #ffd4e3);
  font-weight: 800;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.secondary-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: #3e4a79;
  background: rgba(255, 255, 255, 0.72);
  font-weight: 750;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.secondary-button.compact {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.icon-button {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #3e4a79;
  background: rgba(231, 242, 255, 0.92);
  font-size: 22px;
}

.suggestions {
  position: absolute;
  z-index: 100;
  top: 78px;
  right: 0;
  left: 0;
  display: none;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 48px rgba(112, 127, 186, 0.24);
}

.suggestions.open {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.suggestion-item {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  padding: 8px;
  text-align: left;
  color: #283044;
  background: transparent;
}

.suggestion-item:hover,
.suggestion-item:focus {
  background: var(--panel-strong);
}

.suggestion-item img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.suggestion-item strong,
.suggestion-item small {
  display: block;
}

.suggestion-item small,
.empty-suggestion {
  color: var(--text-muted);
}

.empty-suggestion {
  padding: 18px;
  text-align: center;
}

.feedback-legend {
  position: relative;
  z-index: 2;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  margin-right: 7px;
  border-radius: 50%;
}

.legend-dot.correct {
  background: var(--correct);
}

.legend-dot.close {
  background: var(--close);
}

.legend-dot.miss {
  background: var(--miss);
}

.board-wrap {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow: auto;
  border-radius: 8px;
}

.guess-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0 8px;
  padding: 10px;
}

.guess-table th {
  height: 36px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.guess-table td {
  height: 72px;
  padding: 0 4px;
}

.character-cell,
.feedback-cell {
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.character-cell {
  min-width: 186px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}

.character-cell img {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 8px;
  background: var(--panel-strong);
}

.character-cell strong,
.character-cell span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-cell span {
  max-width: 110px;
  color: var(--text-muted);
  font-size: 12px;
}

.feedback-cell {
  min-width: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px;
  text-align: center;
  font-weight: 750;
}

.feedback-cell span:first-child {
  overflow-wrap: anywhere;
}

.feedback-cell.correct {
  border-color: rgba(35, 186, 121, 0.42);
  background: rgba(159, 235, 206, 0.52);
}

.feedback-cell.close {
  border-color: rgba(201, 143, 46, 0.42);
  background: rgba(255, 222, 160, 0.58);
}

.feedback-cell.miss {
  background: rgba(226, 231, 246, 0.78);
}

.arrow {
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}

.site-footer {
  position: relative;
  z-index: 3;
  width: min(1080px, 100%);
  margin: 14px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px 18px;
  flex-wrap: wrap;
  color: #68738d;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.site-footer a {
  color: #4c75a8;
  text-decoration: none;
}

.site-footer a:hover {
  color: #2e5f99;
  text-decoration: underline;
}

@media (max-width: 780px) {
  .app-shell {
    padding: 12px;
  }

  .home-surface,
  .game-surface {
    min-height: calc(100vh - 24px);
  }

  .topbar,
  .control-panel {
    grid-template-columns: 1fr;
  }

  .home-hero,
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .home-hero-tools {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .home-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .home-nav .account-chip {
    max-width: none;
  }

  .data-header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-form + .auth-form {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .history-row {
    grid-template-columns: 42px minmax(0, 1fr) 72px 86px;
  }

  .history-row time {
    display: none;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  h1 {
    font-size: 21px;
  }

  .status-strip {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .match-lobby-layout {
    grid-template-columns: 1fr;
  }

  .matchmaking-panel,
  .match-rules-panel {
    min-height: 320px;
  }

  .room-code {
    font-size: 36px;
  }

  .match-scoreboard {
    grid-template-columns: minmax(0, 1fr) 120px minmax(0, 1fr);
    gap: 8px;
    padding: 14px;
  }

  .match-player-card strong {
    font-size: 15px;
  }

  .match-clock strong {
    font-size: 24px;
  }

  .match-player-score {
    font-size: 32px;
  }

  .match-round-track {
    grid-template-columns: repeat(5, minmax(44px, 58px));
    gap: 6px;
  }

  .search-row {
    grid-template-columns: minmax(0, 1fr) 76px 48px;
    gap: 6px;
  }

  .match-search-row {
    grid-template-columns: minmax(0, 1fr) 76px;
  }

  .primary-button {
    min-width: 76px;
  }

  .feedback-legend {
    flex-wrap: wrap;
  }
}

@media (max-width: 520px) {
  .account-surface,
  .data-panel {
    min-height: 420px;
    padding: 16px;
  }

  .profile-summary {
    align-items: flex-start;
  }

  .profile-identity h2 {
    max-width: 48vw;
    font-size: 20px;
  }

  .profile-rating {
    min-width: 74px;
  }

  .profile-rating strong {
    font-size: 26px;
  }

  .profile-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-form {
    padding: 20px 4px;
  }

  .registered-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .current-rank-strip {
    grid-template-columns: 1fr;
    padding: 4px 16px;
  }

  .current-rank-strip > div {
    min-height: 58px;
    padding: 8px 4px;
  }

  .current-rank-strip > div + div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .history-row {
    grid-template-columns: 36px minmax(0, 1fr) 62px;
    gap: 8px;
  }

  .history-rating {
    display: none;
  }

  .history-score {
    font-size: 13px;
  }

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

  .room-player-row {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .room-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .match-scoreboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .match-clock {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .match-player-card {
    grid-row: 2;
  }

  .match-round-track {
    grid-template-columns: repeat(5, minmax(40px, 1fr));
    gap: 2px;
    padding-inline: 2px;
  }

  .match-round-step small {
    font-size: 9px;
  }

  .match-result-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  .match-radar.is-active i {
    animation: none;
  }
}

@media (max-width: 1500px) {
  .page-frame {
    display: block;
    width: min(1080px, 100%);
  }

  .side-portrait {
    display: none;
  }
}
