
:root {
  color-scheme: dark;

  /* RetroTD dark theme (default) */
  --bg: #111315;
  --bg-elevated: #171a1d;
  --panel: #1b1f23;
  --panel-2: #22272c;
  --text: #f3f4f6;
  --muted: #a1a1aa;
  --border: #30363d;
  --border-strong: #454c54;
  --accent: #f59e0b;
  --accent-2: #fbbf24;
  --accent-soft: rgba(245, 158, 11, 0.16);
  --success: #6fcf97;
  --warning: #f5a623;
  --danger: #f87171;
  --shadow:
    0 0 0 1px rgba(255,255,255,0.04),
    0 10px 28px rgba(0,0,0,0.42),
    0 0 24px rgba(255,255,255,0.08),
    0 2px 0 rgba(255,255,255,0.03) inset;

  --radius-card: 14px;
  --radius-pill: 999px;
  --radius-button: 10px;

  --container: 1120px;
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --space-6: 32px;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f5f7fa;
  --bg-elevated: #ffffff;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #111827;
  --muted: #6b7280;
  --border: #d7dde5;
  --border-strong: #bcc6d1;
  --accent: #f59e0b;
  --accent-2: #d97706;
  --accent-soft: rgba(245, 158, 11, 0.12);
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.45;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

.container {
  width: min(100% - 32px, var(--container));
  margin: 0 auto;
}

.section {
  padding: var(--space-6) 0;
}

.spacer {
  height: var(--space-5);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  box-shadow: var(--shadow);
}

.card h1,
.card h2,
.card h3 {
  margin-top: 0;
}

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

.grid2,
.grid3,
.grid4 {
  display: grid;
  gap: 16px;
}

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

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

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

@media (max-width: 980px) {
  .grid3,
  .grid4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .grid2,
  .grid3,
  .grid4 {
    grid-template-columns: 1fr;
  }
}

.big {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  line-height: 1.05;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.split {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.split b {
  color: var(--text);
  font-weight: 600;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--panel-2);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.pill-accent {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
}

.pill-success {
  background: color-mix(in srgb, var(--success) 16%, transparent);
  border-color: color-mix(in srgb, var(--success) 45%, var(--border));
}

.pill-warning {
  background: color-mix(in srgb, var(--warning) 14%, transparent);
  border-color: color-mix(in srgb, var(--warning) 45%, var(--border));
}

.pill-danger {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
}

.button,
button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-button);
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.button:hover,
button:hover,
input[type="submit"]:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--panel-2) 80%, var(--accent-soft));
  text-decoration: none;
}

.button:active,
button:active,
input[type="submit"]:active {
  transform: translateY(1px);
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1b1200;
  font-weight: 700;
}


.button-primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

/* Prevent iOS Safari zoom on form focus */
input:not([type="submit"]),
textarea,
select {
  font: inherit;
  font-size: 16px;
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
}

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

.nav-toggle {
  display: none;
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 10px;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--text);
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--muted);
}

.nav a:hover,
.nav a.is-active {
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

@media (max-width: 820px) {
  .topbar-inner {
    position: relative;
  }

  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
  }

  .nav {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    left: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--bg-elevated) 94%, transparent);
    box-shadow: var(--shadow);
    flex-direction: column;
    gap: 8px;
    z-index: 60;
  }

  .nav.is-open {
    display: flex;
  }

  .nav a {
    width: 100%;
    justify-content: flex-start;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 10px;
  }

  .nav a:hover,
  .nav a.is-active {
    border-color: var(--border);
  }
}

.hero {
  padding: 48px 0 24px;
}

.hero h1 {
  font-size: clamp(34px, 6vw, 58px);
  line-height: 0.98;
  letter-spacing: -0.03em;
  margin: 0 0 14px;
}

.hero p {
  max-width: 760px;
  font-size: 18px;
  color: var(--muted);
  margin: 0;
}

.footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 22px 0 34px;
  color: var(--muted);
  font-size: 13px;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  vertical-align: middle;
}

th {
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

td.num,
th.num {
  text-align: right;
}

.code,
pre,
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

pre {
  overflow: auto;
  padding: 14px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

blockquote {
  margin: 0;
  padding-left: 14px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

.research-categories {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.research-category {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel-2);
}

.research-category-title {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.research-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.research-item {
  min-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--border) 88%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 72%, var(--panel-2));
  transition: border-color 140ms ease, transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.research-item:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--panel) 60%, var(--accent-soft));
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.research-item-locked {
  opacity: 0.48;
  background: color-mix(in srgb, #000000 72%, var(--panel));
  border-color: color-mix(in srgb, var(--border) 65%, #000000);
  filter: grayscale(0.85);
}

.research-item-locked:hover {
  border-color: color-mix(in srgb, var(--border) 65%, #000000);
  background: color-mix(in srgb, #000000 72%, var(--panel));
  transform: none;
  box-shadow: none;
}

.research-item-locked .research-item-title,
.research-item-locked .research-item-meta {
  color: color-mix(in srgb, var(--muted) 78%, #ffffff);
}

.research-rank-lock-text {
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0.01em;
}

.research-item-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}

.research-item-meta {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}


@media (max-width: 680px) {
  .research-category {
    padding: 12px;
  }

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

  .research-item {
    min-height: 0;
    padding: 11px 12px;
  }
}

/* === Profile Map Records === */
.profile-map-tab {
  transition: color 0.15s ease, border-color 0.15s ease;
}

.profile-map-tab:hover {
  color: var(--text);
}

#profileMapRecordsList {
  gap: 16px;
}

#profileMapRecordsList > div {
  padding-bottom: 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

#profileMapRecordsList > div:last-child {
  border-bottom: none;
}

@media (max-width: 640px) {
  #profileMapRecordsList > div {
    grid-template-columns: 1fr auto;
  }

  #profileMapRecordsList > div > div:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
    text-align: right;
    font-size: 14px;
    color: var(--muted);
  }
}
/* === Account Bar === */
.account-bar {
  position: sticky;
  top: 64px;
  z-index: 49;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}

.account-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}

.account-bar-inner-guest {
  justify-content: center !important;
  width: 100%;
}

.account-guest-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  width: 100%;
  margin: 0 auto;
  text-align: center;
}

.account-link-guest {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--accent);
}

.account-link-guest:hover {
  color: var(--accent-2);
  text-decoration: none;
}

.account-link-guest::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  background-image: url('/assets/icons/profile_highlight.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.account-left,
.account-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 8px;
  color: var(--muted);
  transition: background 120ms ease, color 120ms ease;
}


.account-link:hover {
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.account-link.is-active {
  color: var(--accent);
}

.account-link.is-active .label {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.account-link .icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: inline-block;
}

.account-link .label {
  font-size: 13px;
  font-weight: 600;
}

.account-link .icon-hover {
  display: none;
}

.account-link:hover .icon-default,
.account-link.is-active .icon-default,
.account-link.has-unread .icon-default {
  display: none;
}

.account-link:hover .icon-hover,
.account-link.is-active .icon-hover,
.account-link.has-unread .icon-hover {
  display: inline-block;
}

/* === Badges === */
.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.badge-unread {
  background: var(--accent);
  color: #1b1200;
  box-shadow: 0 0 6px rgba(245,158,11,0.5);
}

.badge-reward {
  width: 8px;
  height: 8px;
  min-width: 8px;
  padding: 0;
  border-radius: 999px;
  background: #60a5fa;
  top: -2px;
  right: -2px;
}

/* === Responsive === */
@media (max-width: 680px) {
  /* Hide the left profile/username link entirely on mobile */
  .account-left {
    display: none;
  }

  /* Hide labels for right-side icons only */
  .account-right .account-link .label {
    display: none;
  }

  /* Keep right-side actions aligned to the right */
  .account-bar-inner {
    justify-content: flex-end;
    min-height: 44px;
  }

  .account-bar-inner-guest {
    justify-content: center !important;
    width: 100%;
  }

  .account-guest-actions {
    gap: 20px;
  }

  /* Make right-side icons slightly bigger for touch */
  .account-right .icon {
    width: 22px;
    height: 22px;
  }

  .account-link {
    padding: 8px;
  }
}
/* Profile action icons */
#openUsernameChange,
#openEmailChange,
#openPasswordChange {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  transition: color 0.15s ease;
}

#openUsernameChange:hover,
#openEmailChange:hover,
#openPasswordChange:hover {
  color: var(--text);
}

#openUsernameChange::before,
#openEmailChange::before,
#openPasswordChange::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

#openUsernameChange::before {
  background-image: url('/assets/icons/profile.png');
}

#openEmailChange::before {
  background-image: url('/assets/icons/inbox.png');
}

#openPasswordChange::before {
  background-image: url('/assets/icons/password.png');
}

#openUsernameChange:hover::before {
  background-image: url('/assets/icons/profile_highlight.png');
}

#openEmailChange:hover::before {
  background-image: url('/assets/icons/inbox_highlight.png');
}

#openPasswordChange:hover::before {
  background-image: url('/assets/icons/password_highlight.png');
}