:root {
  color-scheme: dark;
  --bg: #050811;
  --bg2: #0a1020;
  --panel: rgba(12, 20, 38, 0.74);
  --panel-solid: #0d1629;
  --line: rgba(130, 175, 255, 0.16);
  --line-hot: rgba(255, 184, 56, 0.45);
  --text: #eef3ff;
  --muted: #93a4c4;
  --gold: #ffb838;
  --gold2: #ffe08a;
  --cyan: #4ef0d4;
  --danger: #ff5d73;
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overflow-x: hidden;
}

/* Atmospheric Veil Backdrop */
.bg-fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(62% 48% at 75% 18%, rgba(78, 240, 212, 0.14), transparent 68%),
    radial-gradient(50% 42% at 18% 22%, rgba(255, 184, 56, 0.13), transparent 65%),
    radial-gradient(46% 36% at 50% 90%, rgba(120, 92, 255, 0.10), transparent 70%),
    linear-gradient(180deg, #050811 0%, #080f1f 55%, #050811 100%);
}
.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(78, 240, 212, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(78, 240, 212, 0.08) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 25%, #000 10%, transparent 80%);
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }

.wrap { width: min(1280px, calc(100% - 36px)); margin: 0 auto; }

/* Header */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(18px);
  background: rgba(5, 8, 17, 0.78);
  border-bottom: 1px solid var(--line);
}
.nav-in {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 14px;
}
.brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
}
.brand span b { color: var(--gold); }
.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
}
.nav-links a:hover { color: var(--gold2); }
.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lang-select {
  appearance: none;
  background: rgba(16, 26, 48, 0.9);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 28px 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.lang-select:hover { border-color: var(--line-hot); }

/* Hero + Interactive 3D Podium */
.hero {
  padding: 36px 0 44px;
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(360px, 1.18fr);
  gap: 28px;
  align-items: center;
}
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 999px;
  background: rgba(78, 240, 212, 0.09);
  border: 1px solid rgba(78, 240, 212, 0.34);
  color: var(--cyan);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 16px;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.45;transform:scale(.82)} }

.hero-title {
  margin: 0 0 14px;
  font-size: clamp(36px, 5vw, 62px);
  line-height: 0.98;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.hero-title .t1 {
  display: block;
  background: linear-gradient(180deg, #fff6dc 0%, #ffb838 72%, #d87a16 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 26px rgba(255, 184, 56, 0.25));
}
.hero-title .t2 {
  display: block;
  color: #eef5ff;
  text-shadow: 0 0 32px rgba(78, 240, 212, 0.3);
}
.hero-sub {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 16px;
  max-width: 520px;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 26px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-gold {
  background: linear-gradient(135deg, #ffd166 0%, #ff9f1c 100%);
  color: #0b101d;
  box-shadow: 0 8px 26px rgba(255, 168, 38, 0.34);
}
.btn-gold:hover { box-shadow: 0 12px 32px rgba(255, 168, 38, 0.48); }
.btn-glass {
  background: rgba(16, 28, 52, 0.78);
  border-color: var(--line);
  color: var(--text);
}
.btn-glass:hover { border-color: var(--cyan); box-shadow: 0 6px 20px rgba(78, 240, 212, 0.16); }

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 470px;
}
.stat-card {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.stat-card b {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--gold2);
  line-height: 1.15;
}
.stat-card span {
  font-size: 12px;
  color: var(--muted);
}

/* 3D Showcase Stage */
.stage-card {
  position: relative;
  border-radius: 24px;
  background:
    radial-gradient(70% 65% at 50% 42%, rgba(78, 240, 212, 0.14), rgba(10, 17, 34, 0.92) 72%),
    var(--panel-solid);
  border: 1px solid rgba(255, 184, 56, 0.28);
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.58),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
  min-height: 520px;
  display: flex;
  flex-direction: column;
}
.stage-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 410px;
  width: 100%;
}
.viewer-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(60% 60% at 50% 45%, rgba(78, 240, 212, 0.12), #050811 75%);
  transition: opacity 0.45s ease;
  pointer-events: none;
  z-index: 2;
}
.viewer-loader.done { opacity: 0; }
.spin-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(78, 240, 212, 0.2);
  border-top-color: var(--gold);
  animation: spin360 0.85s linear infinite;
}
@keyframes spin360 { to { transform: rotate(360deg); } }
#viewerFrame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #050811;
  opacity: 0;
  transition: opacity 0.45s ease;
}
#viewerFrame.ready { opacity: 1; }

.stage-top-hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}
.crown-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 184, 56, 0.22), rgba(255, 130, 38, 0.12));
  border: 1px solid rgba(255, 184, 56, 0.55);
  color: var(--gold2);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  backdrop-filter: blur(10px);
}
.stage-tools {
  display: flex;
  gap: 6px;
  pointer-events: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.tool-btn {
  padding: 6px 11px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(8, 14, 28, 0.78);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.15s ease;
}
.tool-btn:hover { color: var(--text); border-color: var(--cyan); }
.tool-btn.on { color: var(--cyan); border-color: rgba(78, 240, 212, 0.55); background: rgba(78, 240, 212, 0.12); }

.drag-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(5, 9, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
}

.stage-footer {
  padding: 14px 18px;
  background: rgba(7, 12, 24, 0.88);
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.fort-meta h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}
.fort-meta .author {
  font-size: 12.5px;
  color: var(--cyan);
  font-weight: 600;
}
.fort-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.spec-item {
  text-align: right;
}
.spec-item small {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.spec-item b {
  font-size: 15px;
  font-weight: 800;
  color: var(--gold2);
}

/* Sections */
.sec { padding: 42px 0; scroll-margin-top: 84px; }
.sec-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.sec-head h2 {
  margin: 0 0 6px;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 800;
  letter-spacing: 0.01em;
}
.sec-head p {
  margin: 0;
  color: var(--muted);
  max-width: 620px;
}

/* Leaderboard */
.tabs {
  display: inline-flex;
  padding: 4px;
  border-radius: 12px;
  background: rgba(12, 20, 38, 0.85);
  border: 1px solid var(--line);
  gap: 4px;
}
.tab-btn {
  padding: 8px 15px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.tab-btn.on {
  background: linear-gradient(135deg, rgba(255, 184, 56, 0.24), rgba(78, 240, 212, 0.14));
  color: var(--gold2);
  box-shadow: inset 0 0 0 1px rgba(255, 184, 56, 0.45);
}

.lb-panel {
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  overflow: hidden;
}
.lb-table-wrap { overflow-x: auto; }
.lb-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}
.lb-table th {
  text-align: left;
  padding: 13px 16px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 12, 24, 0.55);
}
.lb-table td {
  padding: 13px 16px;
  border-bottom: 1px solid rgba(130, 175, 255, 0.08);
  vertical-align: middle;
}
.lb-row {
  cursor: pointer;
  transition: background 0.15s ease;
}
.lb-row:hover { background: rgba(78, 240, 212, 0.07); }
.lb-row.active {
  background: linear-gradient(90deg, rgba(255, 184, 56, 0.15), rgba(78, 240, 212, 0.06));
  box-shadow: inset 3px 0 0 var(--gold);
}
.rank-badge {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-weight: 800;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}
.rank-1 { background: linear-gradient(135deg, #ffd166, #ff9f1c); color: #09101d; box-shadow: 0 0 16px rgba(255, 184, 56, 0.45); }
.rank-2 { background: linear-gradient(135deg, #e2ecff, #9db4d8); color: #09101d; }
.rank-3 { background: linear-gradient(135deg, #f2a679, #b86239); color: #09101d; }

.p-cell { display: flex; align-items: center; gap: 11px; }
.flag-dot {
  width: 11px;
  height: 30px;
  border-radius: 4px;
  flex-shrink: 0;
}
.p-name { font-weight: 700; color: #fff; font-size: 14.5px; }
.p-sub { font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  padding: 3px 8px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #d6e2ff;
}
.num-gold { font-weight: 800; color: var(--gold2); }
.num-cyan { font-weight: 700; color: var(--cyan); }
.view-pill {
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(78, 240, 212, 0.12);
  border: 1px solid rgba(78, 240, 212, 0.35);
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.lb-row.active .view-pill {
  background: var(--gold);
  border-color: var(--gold);
  color: #09101d;
}

/* Sync Banner */
.sync-banner {
  margin-top: 18px;
  padding: 24px 26px;
  border-radius: var(--radius);
  background: linear-gradient(120deg, rgba(255, 184, 56, 0.12), rgba(78, 240, 212, 0.10) 60%, rgba(12, 20, 38, 0.86));
  border: 1px solid rgba(255, 184, 56, 0.32);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.sync-banner h3 { margin: 0 0 6px; font-size: 20px; }
.sync-banner p { margin: 0; color: var(--muted); max-width: 680px; }

/* Features Bento */
.feat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.feat-card {
  padding: 22px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.feat-card:hover { border-color: rgba(78, 240, 212, 0.45); transform: translateY(-3px); }
.feat-ico {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  margin-bottom: 12px;
  background: rgba(255, 184, 56, 0.12);
  border: 1px solid rgba(255, 184, 56, 0.3);
}
.feat-card h3 { margin: 0 0 8px; font-size: 16.5px; }
.feat-card p { margin: 0; color: var(--muted); font-size: 13.8px; }

/* Footer */
.foot {
  margin-top: 32px;
  padding: 24px 0 36px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.foot-in {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.foot-links { display: flex; gap: 18px; align-items: center; }
.foot-links button {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.foot-links button:hover { color: var(--gold2); }

/* Modal */
.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(3, 6, 14, 0.78);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal-bg[hidden] { display: none; }
.modal-box {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 20px;
  background: #0d1629;
  border: 1px solid var(--line-hot);
  padding: 24px;
  position: relative;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
}
.modal-x {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  font-size: 20px;
  cursor: pointer;
}
.modal-box h3 { margin: 0 0 10px; font-size: 20px; }
.modal-box p { margin: 0 0 14px; color: var(--muted); font-size: 13.8px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select {
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #070d1b;
  color: #fff;
}
.code-box {
  padding: 11px 13px;
  border-radius: 11px;
  background: #060a15;
  border: 1px solid var(--line);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--cyan);
  overflow-x: auto;
  margin-bottom: 14px;
}
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  padding: 10px 18px;
  border-radius: 12px;
  background: #0d1a2e;
  border: 1px solid var(--cyan);
  color: #fff;
  font-weight: 600;
  font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}
.toast[hidden] { display: none; }

@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; }
  .stage-card { min-height: 440px; }
  .stage-canvas-wrap { min-height: 340px; }
  .feat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-links { display: none; }
}
@media (max-width: 620px) {
  .feat-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .hero-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .fort-specs { gap: 10px; }
  .spec-item { text-align: left; }
}
