@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  color-scheme: dark;
  --profile-ink: #edf7ff;
  --profile-muted: #a9bfd3;
  --profile-line: rgba(113, 177, 220, 0.22);
  --profile-blue: #41c5f4;
  --profile-green: #8be0ad;
  --profile-red: #ff9f9a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  display: block;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  color: var(--profile-ink);
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(ellipse at 78% -12%, rgba(31, 143, 200, 0.25), transparent 38rem),
    linear-gradient(150deg, #07111d 0%, #0a1a2a 54%, #07111d 100%);
}

body::before {
  background-image:
    linear-gradient(rgba(84, 171, 218, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(84, 171, 218, 0.045) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

.profile-page {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 22px 0 64px;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--profile-line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--profile-ink);
  font-size: 0.96rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(65, 197, 244, 0.55);
  background: rgba(65, 197, 244, 0.1);
  color: var(--profile-blue);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a:not(.brand) {
  color: var(--profile-muted);
  font-size: 0.83rem;
  font-weight: 650;
  text-decoration: none;
  transition: color 160ms ease;
}

.site-nav a:hover, .site-nav a:focus-visible { color: var(--profile-blue); }

.profile-main {
  width: 100%;
  max-width: none;
  margin: 0;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 46px 0 26px;
}

.page-kicker {
  margin: 0 0 10px;
  color: var(--profile-blue);
  font: 700 0.72rem/1.2 "SFMono-Regular", Consolas, monospace;
  text-transform: uppercase;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.page-heading p:last-child {
  max-width: 420px;
  margin: 12px 0 0;
  color: var(--profile-muted);
  line-height: 1.6;
}

.load-state {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  margin: 0 0 18px;
  padding: 12px 16px;
  border: 1px solid var(--profile-line);
  background: rgba(14, 32, 49, 0.72);
  color: var(--profile-muted);
}

.load-state[data-state="error"] { border-color: rgba(255, 159, 154, 0.45); color: var(--profile-red); }
.retry-button {
  margin: 0 0 0 auto;
  padding: 8px 12px;
  border: 1px solid var(--profile-line);
  background: rgba(65, 197, 244, 0.08);
  color: var(--profile-ink);
  box-shadow: none;
  font-size: 0.75rem;
  text-transform: none;
}

.identity-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  padding: 16px 18px;
  border-left: 3px solid var(--profile-blue);
  background: linear-gradient(100deg, rgba(20, 49, 72, 0.9), rgba(14, 32, 49, 0.56));
}

.identity-mark {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(65, 197, 244, 0.36);
  background: rgba(65, 197, 244, 0.12);
  color: var(--profile-blue);
  font-weight: 800;
}

.identity-copy { min-width: 0; }
.identity-copy span { display: block; color: var(--profile-muted); font-size: 0.72rem; }
.identity-copy strong { display: block; margin-top: 3px; overflow-wrap: anywhere; font-size: 0.96rem; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}

.settings-panel {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--profile-line);
  border-top: 3px solid rgba(65, 197, 244, 0.72);
  background: linear-gradient(155deg, rgba(17, 37, 56, 0.96), rgba(10, 24, 38, 0.94));
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.18);
}

.settings-panel.leaderboard-panel { border-top-color: #f0bd60; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.panel-index { color: var(--profile-blue); font: 700 0.68rem/1.2 "SFMono-Regular", Consolas, monospace; }
.leaderboard-panel .panel-index { color: #f0bd60; }
.panel-heading h2 { margin: 5px 0 0; font-size: 1.2rem; letter-spacing: 0; text-transform: none; }
.panel-heading p { margin: 8px 0 0; color: var(--profile-muted); font-size: 0.86rem; line-height: 1.55; }

.profile-form, .leaderboard-form { display: grid; gap: 15px; }
.field { display: grid; gap: 7px; }
.field label { color: #dceaf5; font-size: 0.8rem; font-weight: 700; }
.field input {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid rgba(153, 193, 221, 0.24);
  border-radius: 3px;
  outline: none;
  background: rgba(4, 15, 26, 0.82);
  color: var(--profile-ink);
  font: 500 0.91rem/1.3 "Space Grotesk", "Avenir Next", sans-serif;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field input:focus-visible { border-color: var(--profile-blue); box-shadow: 0 0 0 3px rgba(65, 197, 244, 0.15); }
.field input::placeholder { color: #71899e; }
.field-hint { color: var(--profile-muted); font-size: 0.72rem; line-height: 1.45; }

.primary-button, .secondary-button, .danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 3px 0 0;
  padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: 3px;
  box-shadow: none;
  font: 750 0.78rem/1.2 "Space Grotesk", "Avenir Next", sans-serif;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.primary-button { background: linear-gradient(120deg, #5bd0f5, #259fd5); color: #062033; }
.secondary-button { border-color: var(--profile-line); background: rgba(65, 197, 244, 0.08); color: var(--profile-ink); }
.danger-button { border-color: rgba(255, 159, 154, 0.35); background: rgba(119, 43, 47, 0.22); color: #ffc2bd; }
.primary-button:hover, .secondary-button:hover, .danger-button:hover { transform: translateY(-1px); }
.primary-button:disabled, .secondary-button:disabled, .danger-button:disabled { opacity: 0.58; cursor: wait; transform: none; }

.form-status { min-height: 18px; margin: -3px 0 0; color: var(--profile-muted); font-size: 0.78rem; line-height: 1.5; }
.form-status[data-state="error"] { color: var(--profile-red); }
.form-status[data-state="success"] { color: var(--profile-green); }

.nickname-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 17px;
  padding: 12px 13px;
  border: 1px solid rgba(240, 189, 96, 0.25);
  background: rgba(240, 189, 96, 0.06);
}

.nickname-preview span { color: var(--profile-muted); font-size: 0.72rem; }
.nickname-preview strong { overflow-wrap: anywhere; color: #f4d28c; font-size: 0.86rem; }

.privacy-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-top: 1px solid var(--profile-line);
  border-bottom: 1px solid var(--profile-line);
  cursor: pointer;
}

.privacy-copy strong { display: block; font-size: 0.82rem; }
.privacy-copy span { display: block; margin-top: 4px; color: var(--profile-muted); font-size: 0.72rem; line-height: 1.45; }
.privacy-control input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.toggle-track {
  position: relative;
  flex: 0 0 42px;
  width: 42px;
  height: 24px;
  border: 1px solid rgba(169, 191, 211, 0.35);
  border-radius: 99px;
  background: rgba(5, 17, 28, 0.9);
  transition: background 150ms ease, border-color 150ms ease;
}

.toggle-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #a9bfd3;
  content: "";
  transition: transform 150ms ease, background 150ms ease;
}

.privacy-control input:checked + .toggle-track { border-color: var(--profile-blue); background: rgba(65, 197, 244, 0.25); }
.privacy-control input:checked + .toggle-track::after { transform: translateX(18px); background: var(--profile-blue); }
.privacy-control input:focus-visible + .toggle-track { outline: 3px solid rgba(65, 197, 244, 0.3); outline-offset: 3px; }
.privacy-note { margin: 0; color: var(--profile-muted); font-size: 0.72rem; line-height: 1.55; }

.account-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 20px;
  padding: 18px 20px;
  border-top: 1px solid var(--profile-line);
  border-bottom: 1px solid var(--profile-line);
  background: rgba(8, 22, 35, 0.55);
}

.account-actions p { margin: 0; color: var(--profile-muted); font-size: 0.78rem; }
.action-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.guest-state { max-width: 700px; margin: 20px auto 0; padding: 30px; border: 1px solid var(--profile-line); border-top: 3px solid var(--profile-blue); background: rgba(13, 31, 48, 0.92); }
.guest-state h2 { margin: 0 0 8px; font-size: 1.35rem; }
.guest-state p { margin: 0; color: var(--profile-muted); line-height: 1.6; }
.guest-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.delete-dialog {
  width: min(440px, calc(100% - 28px));
  padding: 0;
  border: 1px solid rgba(255, 159, 154, 0.45);
  background: #0e2031;
  color: var(--profile-ink);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.delete-dialog::backdrop { background: rgba(1, 8, 14, 0.76); backdrop-filter: blur(4px); }
.dialog-content { padding: 24px; }
.dialog-content h2 { margin: 0 0 9px; font-size: 1.2rem; }
.dialog-content p { color: var(--profile-muted); font-size: 0.88rem; line-height: 1.55; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

@media (max-width: 760px) {
  .profile-page { width: min(100% - 32px, 620px); padding-top: 16px; }
  .page-heading { align-items: start; margin: 34px 0 22px; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-panel { padding: 20px; }
}

@media (max-width: 480px) {
  .profile-page { width: min(100% - 24px, 620px); }
  .site-nav { align-items: start; flex-direction: column; }
  .site-nav ul { gap: 10px 16px; }
  .page-heading { margin-top: 28px; }
  .page-heading h1 { font-size: 2rem; }
  .settings-panel { padding: 17px; }
  .account-actions { align-items: start; flex-direction: column; padding-inline: 4px; }
  .action-buttons { width: 100%; }
  .action-buttons button { flex: 1 1 auto; }
  .load-state { align-items: start; flex-wrap: wrap; }
  .retry-button { margin-left: 0; }
}

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