:root {
  color-scheme: dark;
  --bg: #07080c;
  --ink: #f4f1ea;
  --muted: #9aa3b5;
  --line: rgba(255, 255, 255, 0.08);
  --pink: #fe2c55;
  --cyan: #25f4ee;
  --gold: #f4c95d;
  --silver: #d7dde8;
  --bronze: #d0895b;
  --panel: rgba(12, 14, 20, 0.72);
  --font: "IBM Plex Sans JP", "Hiragino Sans", sans-serif;
  --display: "Geist", "IBM Plex Sans JP", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
}

html[data-page="overlay"],
html[data-page="overlay"] body {
  background: transparent;
  min-height: 0;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; }

.overlay {
  width: min(440px, 100%);
  padding: 18px 16px 24px;
}

.overlay-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  border-radius: 18px;
}

.kicker {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.18em;
}

.overlay-head h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
  letter-spacing: -0.04em;
  line-height: 1;
}

.live-badge,
.demo-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.live-badge {
  background: var(--pink);
  color: white;
  box-shadow: 0 0 16px rgba(254, 44, 85, 0.45);
}

.demo-badge {
  background: #2a3142;
  color: var(--cyan);
}

.meta {
  display: grid;
  justify-items: end;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.overlay-error {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(254, 44, 85, 0.16);
  color: #ffd4dc;
  font-size: 13px;
}

.rank-stage { position: relative; }

.rank-row {
  position: absolute;
  inset: 0 0 auto;
  height: 64px;
  display: grid;
  grid-template-columns: 46px 48px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 0 12px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.3s, box-shadow 0.3s;
}

.rank-row.no-avatar {
  grid-template-columns: 46px minmax(0, 1fr) auto;
}

.rank-row.is-highlight {
  border-color: rgba(37, 244, 238, 0.7);
  box-shadow: 0 0 0 1px rgba(37, 244, 238, 0.25), 0 10px 32px rgba(0, 0, 0, 0.28);
}

.you-dock {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px dashed rgba(37, 244, 238, 0.35);
}

.you-label {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.you-dock .rank-row {
  position: relative;
  transform: none !important;
}

.rank-row.is-you {
  height: 70px;
  border-color: rgba(37, 244, 238, 0.85);
  background: linear-gradient(90deg, rgba(37, 244, 238, 0.16), rgba(12, 14, 20, 0.82) 42%);
  box-shadow: 0 0 0 1px rgba(37, 244, 238, 0.28), 0 12px 36px rgba(0, 0, 0, 0.32);
}

.rank-row.is-missing {
  color: var(--muted);
}

.you-chip {
  display: inline-flex;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--cyan);
  color: #061014;
  font-size: 9px;
  letter-spacing: 0.12em;
  vertical-align: 1px;
}

.rank-num {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.06em;
  text-align: center;
}

.rank-row.rank-1 .rank-num { color: var(--gold); }
.rank-row.rank-2 .rank-num { color: var(--silver); }
.rank-row.rank-3 .rank-num { color: var(--bronze); }

.avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #1a2030, #10131b);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.live-dot {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 0 2px #0c0e14;
  animation: pulse 1.6s infinite;
}

.identity { min-width: 0; display: grid; }

.identity strong {
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity span {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metrics {
  display: grid;
  justify-items: end;
  gap: 1px;
}

.metrics b {
  font-family: var(--display);
  font-size: 16px;
  letter-spacing: -0.03em;
}

.metrics em {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
}

.metrics .up { color: var(--cyan); }
.metrics .down { color: var(--pink); }
.metrics .same { color: #5d6678; }
.metrics small { color: var(--muted); font-size: 10px; }

[data-theme="neon"] .rank-row,
[data-theme="neon"] .overlay-head {
  background: rgba(6, 8, 14, 0.55);
  border-color: rgba(37, 244, 238, 0.28);
  box-shadow: 0 0 24px rgba(254, 44, 85, 0.08);
}

[data-theme="solid"] .rank-row,
[data-theme="solid"] .overlay-head {
  background: #12151d;
  backdrop-filter: none;
}

[data-theme="minimal"] .rank-row,
[data-theme="minimal"] .overlay-head {
  background: rgba(0, 0, 0, 0.35);
  border-color: transparent;
  backdrop-filter: blur(8px);
}

[data-theme="minimal"] .overlay-head h1 { font-size: 22px; }

.setup {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(340px, 1fr) 460px;
  min-height: 100vh;
}

.setup-copy,
.setup-panel,
.setup-preview { padding: 36px 32px; }

.setup-copy {
  background:
    radial-gradient(600px 280px at 0% 0%, rgba(37, 244, 238, 0.16), transparent 60%),
    radial-gradient(500px 240px at 20% 80%, rgba(254, 44, 85, 0.16), transparent 55%),
    #08090e;
  border-right: 1px solid var(--line);
}

.brand {
  margin: 0 0 18px;
  letter-spacing: 0.28em;
  font-size: 12px;
  color: var(--cyan);
}

.setup-copy h1 {
  margin: 0 0 16px;
  font-size: 36px;
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.setup-copy p,
.setup-copy li {
  color: #c5ccd8;
  line-height: 1.7;
}

.setup-copy ol { padding-left: 18px; }

.status-line {
  margin-top: 28px;
  color: var(--cyan) !important;
  font-size: 13px;
}

.setup-panel {
  display: grid;
  align-content: start;
  gap: 18px;
}

.setup-panel section,
.url-box {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #0d1017;
}

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

label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

input, select, textarea {
  width: 100%;
  color: var(--ink);
  background: #161a24;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}

textarea {
  min-height: 88px;
  resize: vertical;
  font-size: 12px;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(37, 244, 238, 0.7);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
}

.check input { width: 16px; height: 16px; }

.toggles {
  grid-template-columns: repeat(3, max-content);
  grid-auto-flow: column;
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: linear-gradient(90deg, var(--cyan), #7af6f1);
  color: #061014;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

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

.setup-preview {
  background: #10131a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Crect width='8' height='8' fill='%23181c26'/%3E%3C/svg%3E");
  border-left: 1px solid var(--line);
}

.setup-preview > p {
  margin: 0 0 12px;
  color: var(--muted);
  letter-spacing: 0.16em;
  font-size: 12px;
}

.preview-frame {
  width: 440px;
  max-width: 100%;
  min-height: 720px;
  border-radius: 20px;
  overflow: hidden;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.85); opacity: 0.55; }
}

@media (max-width: 1200px) {
  .setup { grid-template-columns: 1fr; }
  .setup-preview {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
