:root {
  color-scheme: dark;
  --ink: #fff2cf;
  --muted: #c3bdab;
  --panel: rgba(9, 17, 17, 0.56);
  --panel-strong: rgba(5, 10, 11, 0.72);
  --line: rgba(255, 237, 190, 0.14);
  --line-bright: rgba(255, 239, 198, 0.28);
  --glass: rgba(7, 14, 15, 0.5);
  --gold: #d9a84c;
  --gold-soft: #ffe3a0;
  --red: #b73a2e;
  --teal: #17a398;
  --cyan: #6fd7dc;
  --leaf: #83ba73;
  --bg: #090c0c;
  --texture: url("./assets/lacquer-texture.png");
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family:
    "Avenir Next", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(3, 7, 8, 0.55), rgba(3, 7, 8, 0.78) 52%, rgba(3, 7, 8, 0.92)),
    radial-gradient(circle at 16% 3%, rgba(255, 205, 104, 0.26), transparent 30%),
    radial-gradient(circle at 92% 12%, rgba(62, 210, 200, 0.22), transparent 28%),
    radial-gradient(circle at 70% 98%, rgba(184, 55, 42, 0.24), transparent 36%),
    url("./assets/race-course.png") center top / cover fixed no-repeat,
    #050808;
  overflow-x: hidden;
}

body.modal-open {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.34;
  background-image:
    radial-gradient(circle at 50% 0%, rgba(255, 238, 186, 0.18), transparent 34%),
    linear-gradient(90deg, rgba(2, 7, 8, 0.64), transparent 18%, transparent 82%, rgba(2, 7, 8, 0.68)),
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: auto, auto, 30px 30px, 30px 30px;
  mix-blend-mode: soft-light;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  filter: saturate(0.45) brightness(0.72);
  opacity: 0.72;
}

.prelaunch-locked input,
.prelaunch-locked button:disabled {
  pointer-events: none;
}

.prelaunch-locked .api-status.warn,
.prelaunch-locked .locked-row,
.prelaunch-locked .empty-row,
.prelaunch-locked .claim-details span {
  color: rgba(255, 238, 202, 0.82);
  background: rgba(255, 232, 171, 0.08);
  border: 1px solid rgba(255, 232, 171, 0.14);
}

.test-mode .api-status.warn,
.test-mode .locked-row,
.test-mode .empty-row,
.test-mode .claim-details span {
  color: rgba(210, 247, 255, 0.9);
  background: rgba(93, 214, 224, 0.1);
  border: 1px solid rgba(132, 238, 246, 0.16);
}

.locked-row {
  min-height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-weight: 850;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-nav {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 40;
  width: min(1480px, calc(100% - 28px));
  min-height: 66px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 240, 202, 0.15);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 244, 210, 0.11), rgba(255, 255, 255, 0.025) 42%, rgba(4, 9, 10, 0.58)),
    rgba(4, 10, 11, 0.54);
  box-shadow:
    0 22px 60px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 248, 224, 0.2);
  backdrop-filter: blur(22px) saturate(1.24);
}

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

.nav-brand strong,
.nav-brand em {
  display: block;
}

.nav-brand strong {
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: 20px;
  line-height: 1;
}

.nav-brand em {
  margin-top: 4px;
  color: rgba(255, 242, 207, 0.62);
  font-size: 11px;
  font-style: normal;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.seal-small {
  width: 38px;
  height: 38px;
}

.nav-links {
  justify-self: center;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.nav-links a,
.nav-link-button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: rgba(255, 244, 220, 0.8);
  background: transparent;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease;
}

.nav-links a:hover,
.nav-link-button:hover {
  color: var(--ink);
  border-color: rgba(255, 240, 202, 0.18);
  background: rgba(255, 244, 210, 0.08);
  transform: translateY(-1px);
}

.ca-nav-link {
  color: #08201d !important;
  border-color: rgba(114, 231, 219, 0.42) !important;
  background:
    linear-gradient(135deg, rgba(223, 255, 249, 0.96), rgba(111, 215, 220, 0.86)) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

.wallet-button {
  min-height: 42px;
  min-width: 148px;
  padding: 0 14px;
  border: 1px solid rgba(255, 244, 210, 0.18);
  border-radius: 8px;
  color: #081211;
  background:
    linear-gradient(135deg, rgba(255, 250, 224, 0.98), rgba(255, 206, 101, 0.96) 48%, rgba(90, 220, 206, 0.92));
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-weight: 950;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    filter 0.18s ease;
}

.wallet-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.wallet-button.connected {
  color: #f4fff9;
  background:
    linear-gradient(135deg, rgba(10, 156, 139, 0.92), rgba(24, 84, 92, 0.96)),
    rgba(4, 12, 13, 0.74);
}

.rainbowkit-mount {
  display: none;
  min-height: 42px;
  min-width: 148px;
  align-items: center;
  justify-content: flex-end;
}

.has-rainbowkit .rainbowkit-mount {
  display: flex;
}

.has-rainbowkit .wallet-button {
  display: none;
}

.rainbowkit-mount [data-rk] {
  min-width: 148px;
}

.wallet-orb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, #fff4c4, #ff9858 34%, #6f7cff 64%, #3be5d4 100%);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.25),
    0 0 18px rgba(91, 225, 213, 0.44);
  flex: 0 0 auto;
}

.game-shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 96px 18px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
}

.race-stage,
.side-panel {
  border: 1px solid rgba(255, 240, 202, 0.13);
  background:
    linear-gradient(135deg, rgba(255, 229, 159, 0.09), rgba(255, 255, 255, 0.018) 34%, rgba(8, 12, 12, 0.52)),
    var(--texture) center / cover,
    var(--panel);
  box-shadow:
    0 28px 90px rgba(1, 9, 9, 0.44),
    inset 0 1px 0 rgba(255, 244, 210, 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(24px) saturate(1.22);
}

.race-stage {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  border-radius: 8px;
  overflow: hidden;
}

.topbar {
  min-height: 78px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background:
    linear-gradient(90deg, rgba(4, 10, 11, 0.62), rgba(32, 24, 14, 0.44)),
    var(--texture) center / cover;
  border-bottom: 1px solid rgba(255, 240, 202, 0.11);
  backdrop-filter: blur(16px);
}

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

.seal {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(8, 14, 14, 0.36);
  box-shadow:
    0 0 0 1px rgba(255, 244, 210, 0.28),
    0 12px 26px rgba(130, 64, 22, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  flex: 0 0 auto;
  overflow: hidden;
}

.seal img {
  width: 112%;
  height: 112%;
  object-fit: contain;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.45));
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 1px 0 rgba(255, 236, 180, 0.22);
}

.brand p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  gap: 8px;
  min-width: min(520px, 54%);
}

.metrics div,
.command-card {
  border: 1px solid rgba(255, 239, 198, 0.13);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 244, 210, 0.085), rgba(255, 255, 255, 0.018)),
    rgba(5, 9, 9, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 246, 217, 0.12),
    inset 0 -16px 28px rgba(0, 0, 0, 0.14);
}

.metrics div {
  min-height: 48px;
  padding: 7px 9px;
}

.metrics span,
.command-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.1;
}

.metrics strong {
  display: block;
  margin-top: 5px;
  font-size: 21px;
  line-height: 1;
}

.canvas-wrap {
  position: relative;
  min-height: 0;
  background: #061313;
  overflow: hidden;
}

#raceCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 460px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(90deg, rgba(5, 8, 8, 0.84), rgba(5, 8, 8, 0.28) 54%, rgba(5, 8, 8, 0.12)),
    radial-gradient(circle at 78% 34%, rgba(217, 168, 76, 0.24), transparent 30%);
  backdrop-filter: blur(2px);
}

.overlay-inner {
  width: min(470px, 100%);
  justify-self: start;
  margin-left: clamp(0px, 5vw, 72px);
}

.eyebrow {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.overlay h2 {
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: clamp(40px, 8vw, 82px);
  line-height: 0.95;
  letter-spacing: 0;
  text-wrap: balance;
  text-shadow:
    0 2px 0 rgba(145, 55, 34, 0.42),
    0 24px 52px rgba(0, 0, 0, 0.42);
}

.overlay p {
  width: min(410px, 100%);
  margin-top: 16px;
  color: #dce8e8;
  font-size: 17px;
  line-height: 1.6;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.primary,
.ghost,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  transition:
    transform 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.primary {
  padding: 0 20px;
  color: #21110a;
  font-weight: 900;
  background: linear-gradient(135deg, #fff2ba, #dca74a 52%, #a93a29);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 12px 28px rgba(177, 91, 34, 0.3);
}

.ghost,
.icon-button {
  border: 1px solid rgba(255, 239, 198, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 244, 210, 0.09), rgba(255, 255, 255, 0.016)),
    rgba(5, 9, 9, 0.38);
}

.ghost {
  padding: 0 18px;
}

.primary:hover,
.ghost:hover,
.icon-button:hover,
.item-button:hover,
.touch-pad button:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 16px 36px rgba(0, 0, 0, 0.28);
}

.hidden {
  display: none !important;
}

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(72px, 15vw, 170px);
  font-weight: 950;
  color: #fff6cd;
  text-shadow: 0 12px 40px rgba(0, 0, 0, 0.42);
  background: rgba(7, 18, 20, 0.28);
}

.command-row {
  display: grid;
  grid-template-columns: 1.25fr 1fr 0.75fr;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(255, 240, 202, 0.11);
  background:
    linear-gradient(90deg, rgba(4, 10, 11, 0.58), rgba(31, 23, 14, 0.46)),
    var(--texture) center / cover;
  backdrop-filter: blur(16px);
}

.command-card {
  min-height: 74px;
  padding: 10px 12px;
}

.command-card strong {
  display: block;
  margin-top: 7px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.command-card.accent strong {
  color: #ffd978;
}

.command-card.speed strong {
  color: #75e6d1;
}

.command-meter,
.speed-bar {
  height: 7px;
  margin-top: 11px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 244, 210, 0.12);
}

.command-meter i,
.speed-bar i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #20b7a8, #ffe3a0, #b73a2e);
  box-shadow: 0 0 18px rgba(217, 168, 76, 0.4);
}

.charge-dots {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
  margin-top: 12px;
}

.charge-dots i {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.charge-dots i.ready {
  background: var(--gold);
  box-shadow: 0 0 18px rgba(244, 201, 93, 0.4);
}

.side-panel {
  max-height: calc(100vh - 114px);
  overflow: auto;
  border-radius: 8px;
  padding: 15px;
}

.league-detail-panel {
  grid-column: 1 / -1;
  border: 1px solid rgba(255, 240, 202, 0.13);
  border-radius: 8px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(255, 229, 159, 0.08), rgba(255, 255, 255, 0.014) 42%, rgba(8, 12, 12, 0.48)),
    var(--texture) center / cover,
    rgba(6, 13, 14, 0.5);
  box-shadow:
    0 28px 86px rgba(1, 9, 9, 0.4),
    inset 0 1px 0 rgba(255, 244, 210, 0.16);
  backdrop-filter: blur(24px) saturate(1.18);
}

.league-detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.9fr);
  gap: 18px;
  align-items: end;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 240, 202, 0.1);
}

.league-detail-header h2 {
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1;
}

.league-detail-header p,
.scoreboard-title p {
  margin-top: 8px;
  max-width: 58ch;
  color: rgba(226, 236, 231, 0.78);
  font-size: 14px;
  line-height: 1.55;
}

.league-detail-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.league-detail-stats div {
  min-height: 66px;
  padding: 10px;
  border: 1px solid rgba(255, 239, 198, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 244, 210, 0.075), rgba(255, 255, 255, 0.012)),
    rgba(5, 9, 9, 0.3);
}

.league-detail-stats b {
  display: block;
  overflow: hidden;
  color: var(--gold-soft);
  font-size: 18px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.league-detail-stats span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.scoreboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.18fr);
  gap: 14px;
  margin-top: 16px;
}

.scoreboard-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(255, 239, 198, 0.11);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 244, 210, 0.06), rgba(255, 255, 255, 0.01)),
    rgba(4, 9, 10, 0.28);
}

.scoreboard-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.scoreboard-title h3 {
  font-size: 17px;
  line-height: 1.2;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 240, 202, 0.11);
}

.panel-header h2 {
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: 22px;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.section {
  padding: 15px 0;
  border-bottom: 1px solid rgba(255, 240, 202, 0.09);
}

.section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.section h3 {
  margin-bottom: 10px;
  color: #fff2cf;
  font-size: 14px;
  letter-spacing: 0.04em;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-title-row h3 {
  margin-bottom: 0;
}

.mini-button,
.small-action {
  min-height: 34px;
  border: 1px solid rgba(255, 239, 198, 0.14);
  border-radius: 8px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 244, 210, 0.085), rgba(255, 255, 255, 0.016)),
    rgba(5, 9, 9, 0.36);
}

.mini-button {
  padding: 0 10px;
  color: var(--gold-soft);
  font-size: 12px;
  font-weight: 800;
}

.api-status {
  min-height: 34px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(111, 215, 220, 0.22);
  border-radius: 8px;
  color: #cfeeed;
  background:
    linear-gradient(90deg, rgba(23, 163, 152, 0.18), rgba(255, 244, 210, 0.035)),
    rgba(5, 9, 9, 0.34);
  font-size: 12px;
  line-height: 1.35;
}

.api-status.warn {
  border-color: rgba(217, 168, 76, 0.44);
  color: #ffe3a0;
  background:
    linear-gradient(90deg, rgba(217, 168, 76, 0.16), rgba(183, 58, 46, 0.08)),
    rgba(5, 9, 9, 0.55);
}

.contract-strip {
  display: grid;
  gap: 7px;
  margin: 0 0 10px;
  padding: 12px;
  border: 1px solid rgba(115, 232, 223, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(116, 229, 224, 0.12), rgba(255, 228, 158, 0.06)),
    rgba(3, 12, 13, 0.32);
}

.contract-strip span {
  color: rgba(255, 244, 220, 0.66);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.contract-strip a {
  min-width: 0;
  color: rgba(226, 255, 251, 0.98);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.field,
.field-pair {
  display: grid;
  gap: 7px;
}

.field {
  margin-bottom: 10px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
}

.field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(255, 239, 198, 0.13);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 244, 210, 0.06), rgba(255, 255, 255, 0.012)),
    rgba(4, 8, 8, 0.46);
  outline: none;
  font: inherit;
  font-size: 13px;
}

.field input:focus {
  border-color: rgba(111, 215, 220, 0.7);
  box-shadow: 0 0 0 3px rgba(23, 163, 152, 0.18);
}

.field-pair {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.field-pair .field {
  margin-bottom: 0;
}

.small-action {
  height: 40px;
  padding: 0 12px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
}

.rule-strip,
.player-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.rule-strip div,
.player-summary div,
.settlement-summary,
.team-card,
.league-board li,
.record-board li {
  border: 1px solid rgba(255, 239, 198, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 244, 210, 0.075), rgba(255, 255, 255, 0.012)),
    rgba(5, 9, 9, 0.32);
}

.rule-strip div,
.player-summary div {
  min-height: 54px;
  padding: 8px;
}

.rule-strip b,
.player-summary b {
  display: block;
  overflow: hidden;
  color: var(--gold-soft);
  font-size: 16px;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rule-strip span,
.player-summary span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.team-list {
  display: grid;
  gap: 8px;
}

.team-card {
  width: 100%;
  min-height: 62px;
  padding: 9px 10px;
  color: var(--ink);
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.team-card::before {
  content: "";
  width: 10px;
  height: 42px;
  border-radius: 999px;
  background: var(--team-color, var(--gold));
  box-shadow: 0 0 18px rgba(217, 168, 76, 0.32);
}

.team-card.selected,
.team-card.joined {
  border-color: rgba(255, 227, 160, 0.46);
  background:
    linear-gradient(90deg, rgba(217, 168, 76, 0.18), rgba(23, 163, 152, 0.08)),
    rgba(5, 9, 9, 0.42);
}

.team-card strong,
.team-card span,
.team-card em {
  display: block;
}

.team-card strong {
  font-size: 14px;
}

.team-card span,
.team-card em {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.team-card b {
  min-width: 58px;
  color: var(--gold-soft);
  font-size: 17px;
  text-align: right;
}

.wide-action {
  width: 100%;
  margin-top: 10px;
}

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

.league-board {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  counter-reset: teamrank;
}

.league-board li,
.record-board li {
  min-height: 68px;
  padding: 10px;
  display: grid;
  gap: 10px;
  align-items: center;
}

.league-board li {
  grid-template-columns: 34px minmax(150px, 1.2fr) repeat(3, minmax(82px, 0.7fr));
  counter-increment: teamrank;
}

.record-board {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.record-board li {
  grid-template-columns: 34px minmax(154px, 1.2fr) repeat(4, minmax(74px, 0.7fr));
}

.league-board li::before {
  content: counter(teamrank);
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #091417;
  background: var(--gold);
  font-size: 12px;
  font-weight: 950;
}

.team-scoreboard li::before {
  display: none;
}

.league-board .joined {
  background:
    linear-gradient(90deg, rgba(23, 163, 152, 0.22), rgba(217, 168, 76, 0.08)),
    rgba(5, 9, 9, 0.58);
}

.record-board .me {
  background:
    linear-gradient(90deg, rgba(23, 163, 152, 0.2), rgba(217, 168, 76, 0.08)),
    rgba(5, 9, 9, 0.42);
}

.rank-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #091417;
  background: linear-gradient(135deg, #fff2ba, var(--gold) 58%, #8f261e);
  font-size: 13px;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.scoreboard-identity {
  min-width: 0;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.scoreboard-identity i {
  width: 10px;
  height: 42px;
  border-radius: 999px;
  background: var(--team-color, var(--teal));
  box-shadow: 0 0 18px rgba(217, 168, 76, 0.3);
}

.record-board .scoreboard-identity i {
  background: linear-gradient(180deg, var(--cyan), var(--gold));
}

.scoreboard-identity strong,
.league-board li > span > strong,
.record-board li > span > strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.scoreboard-identity em,
.league-board li > span > em,
.record-board li > span > em {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.league-board li > span:not(.scoreboard-identity),
.record-board li > span:not(.scoreboard-identity) {
  min-width: 0;
  text-align: right;
}

.league-board li > span:not(.scoreboard-identity) strong,
.record-board li > span:not(.scoreboard-identity) strong {
  color: var(--gold-soft);
}

.empty-row {
  min-height: 76px;
  display: grid !important;
  grid-template-columns: 1fr !important;
  place-items: center;
  color: rgba(226, 236, 231, 0.74);
  text-align: center;
}

.settlement-summary {
  margin-top: 8px;
  padding: 10px;
  color: #dbe8e7;
  font-size: 12px;
  line-height: 1.45;
}

.settlement-summary b {
  color: var(--gold-soft);
}

.claim-panel {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 239, 198, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(23, 163, 152, 0.13), rgba(217, 168, 76, 0.08)),
    rgba(5, 9, 9, 0.3);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.claim-panel h3 {
  margin-bottom: 5px;
  font-size: 15px;
}

.claim-panel p,
.claim-details {
  color: rgba(226, 236, 231, 0.78);
  font-size: 12px;
  line-height: 1.45;
}

.claim-details {
  grid-column: 1 / -1;
  min-height: 20px;
}

.claim-details b {
  color: var(--gold-soft);
}

.claim-details .warn {
  color: #ffe3a0;
}

.claim-button {
  min-width: 112px;
  white-space: nowrap;
}

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

.crew {
  min-height: 42px;
  padding: 8px;
  border: 1px solid rgba(255, 239, 198, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 244, 210, 0.07), rgba(255, 255, 255, 0.015)),
    rgba(4, 8, 8, 0.3);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.crew b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.crew span {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #071416;
  font-size: 13px;
  font-weight: 950;
  background: rgba(255, 255, 255, 0.2);
}

.crew.good span {
  background: var(--leaf);
}

.crew.bad span {
  color: #fff;
  background: var(--red);
}

.item-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.item-button {
  width: 100%;
  min-height: 66px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 239, 198, 0.12);
  border-radius: 8px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255, 244, 210, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(5, 9, 9, 0.36);
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  transition:
    transform 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.item-button.selected,
.item-button.has-stock {
  border-color: rgba(255, 227, 160, 0.46);
  background:
    linear-gradient(90deg, rgba(217, 168, 76, 0.18), rgba(255, 255, 255, 0.03)),
    rgba(5, 9, 9, 0.42);
  box-shadow:
    inset 0 0 0 1px rgba(255, 243, 202, 0.1),
    0 10px 28px rgba(0, 0, 0, 0.16);
}

.item-icon {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  object-fit: contain;
  padding: 3px;
  background:
    radial-gradient(circle at 42% 32%, rgba(255, 238, 184, 0.2), rgba(8, 15, 16, 0.48) 62%, rgba(0, 0, 0, 0.32)),
    rgba(5, 9, 9, 0.34);
  box-shadow:
    inset 0 0 0 1px rgba(255, 241, 196, 0.16),
    0 8px 20px rgba(0, 0, 0, 0.35);
}

.item-button strong {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
}

.item-hotkey {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 239, 198, 0.28);
  border-radius: 5px;
  color: #160d08;
  background: linear-gradient(135deg, #fff1bd, #d9a84c);
  font-size: 11px;
  font-style: normal;
  line-height: 1;
  flex: 0 0 auto;
}

.item-button span:not(.item-count) {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.item-count {
  min-width: 32px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 25%, #fff5c8, var(--gold) 46%, #72451f);
  color: #140b06;
  font-size: 12px;
  font-weight: 900;
}

.leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
  counter-reset: rank;
}

.leaderboard li {
  min-height: 36px;
  padding: 8px 9px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 244, 210, 0.07), rgba(255, 255, 255, 0.02)),
    rgba(5, 9, 9, 0.32);
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 8px;
  align-items: center;
  counter-increment: rank;
}

.leaderboard li::before {
  content: counter(rank);
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #091417;
  background: var(--gold);
  font-size: 12px;
  font-weight: 950;
}

.leaderboard .me {
  background:
    linear-gradient(90deg, rgba(23, 163, 152, 0.22), rgba(217, 168, 76, 0.08)),
    rgba(5, 9, 9, 0.42);
}

.leaderboard b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.leaderboard span {
  color: var(--muted);
  font-size: 12px;
}

.compact {
  padding-bottom: 0;
}

.log {
  height: 112px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  color: #dbe8e7;
  font-size: 12px;
  line-height: 1.35;
}

.log p {
  padding: 7px 8px;
  border-radius: 8px;
  background: rgba(255, 244, 210, 0.065);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 50% 18%, rgba(217, 168, 76, 0.18), transparent 32%),
    rgba(1, 5, 6, 0.72);
  backdrop-filter: blur(12px);
}

.rules-dialog {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  border: 1px solid rgba(255, 240, 202, 0.16);
  border-radius: 8px;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(255, 244, 210, 0.11), rgba(255, 255, 255, 0.025) 38%, rgba(4, 10, 11, 0.72)),
    var(--texture) center / cover,
    rgba(4, 10, 11, 0.68);
  box-shadow:
    0 36px 110px rgba(0, 0, 0, 0.58),
    inset 0 1px 0 rgba(255, 248, 224, 0.22);
  backdrop-filter: blur(24px) saturate(1.18);
}

.rules-dialog h2 {
  margin-bottom: 18px;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: clamp(30px, 6vw, 52px);
  line-height: 1;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

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

.rules-grid div {
  min-height: 74px;
  padding: 12px;
  border: 1px solid rgba(255, 239, 198, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 244, 210, 0.075), rgba(255, 255, 255, 0.012)),
    rgba(5, 9, 9, 0.32);
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: start;
  gap: 10px;
}

.rules-grid b {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff2ba, #d9a84c 60%, #9a3328);
  color: #190d08;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 950;
}

.rules-grid span {
  color: #e5eee9;
  font-size: 14px;
  line-height: 1.5;
}

.touch-pad {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 8;
  width: min(560px, calc(100% - 28px));
  transform: translateX(-50%);
  display: none;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  pointer-events: none;
}

.touch-pad button {
  min-height: 48px;
  border: 1px solid rgba(255, 239, 198, 0.18);
  border-radius: 8px;
  color: #1d1108;
  font-weight: 950;
  background: linear-gradient(135deg, rgba(255, 244, 210, 0.96), rgba(217, 168, 76, 0.88));
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

@media (max-width: 1120px) {
  .game-shell {
    grid-template-columns: 1fr;
    padding-bottom: 86px;
  }

  .side-panel {
    max-height: none;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 18px;
  }

  .panel-header {
    grid-column: 1 / -1;
  }

  .league-detail-header,
  .scoreboard-grid {
    grid-template-columns: 1fr;
  }

  .league-detail-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  body.game-active .touch-pad {
    display: grid;
  }
}

@media (max-width: 760px) {
  .site-nav {
    top: 8px;
    width: calc(100% - 16px);
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px;
  }

  .nav-brand strong {
    font-size: 18px;
  }

  .nav-links {
    grid-column: 1 / -1;
    justify-self: stretch;
    justify-content: space-between;
    order: 3;
    gap: 4px;
  }

  .nav-links a,
  .nav-link-button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 12px;
  }

  .wallet-button {
    min-width: 122px;
    min-height: 38px;
    padding: 0 10px;
    font-size: 13px;
  }

  .rainbowkit-mount {
    min-width: 122px;
    min-height: 38px;
  }

  .wallet-orb {
    width: 16px;
    height: 16px;
  }

  .game-shell {
    padding: 126px 10px 10px;
    gap: 10px;
  }

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

  .metrics {
    min-width: 0;
    width: 100%;
    grid-template-columns: repeat(2, 1fr);
  }

  .command-row {
    grid-template-columns: 1fr;
  }

  #raceCanvas {
    min-height: 420px;
  }

  .overlay {
    padding: 18px;
  }

  .overlay-inner {
    margin-left: 0;
  }

  .overlay p {
    font-size: 15px;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .league-detail-panel {
    padding: 12px;
  }

  .league-detail-header {
    gap: 12px;
  }

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

  .scoreboard-card {
    padding: 10px;
  }

  .league-board li,
  .record-board li {
    grid-template-columns: 34px repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .scoreboard-identity {
    grid-column: 2 / -1;
  }

  .league-board li > span:not(.scoreboard-identity),
  .record-board li > span:not(.scoreboard-identity) {
    text-align: left;
  }

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

  .field-pair,
  .rule-strip,
  .player-summary {
    grid-template-columns: 1fr;
  }

  .rules-dialog {
    padding: 22px;
  }

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

@media (max-height: 700px) {
  .overlay h2 {
    font-size: clamp(34px, 7vw, 58px);
  }

  .overlay p {
    margin-top: 10px;
    line-height: 1.35;
  }

  .overlay-actions {
    margin-top: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
