/* osu!tegami — shared styles */

:root {
  color-scheme: dark;

  --bg: #0e0b12;
  --bg-elevated: #17131d;
  --bg-card: #1c1723;
  --border: #2c2534;
  --border-soft: #241e2c;

  --text: #f1edf5;
  --text-dim: #b7aec4;
  --text-faint: #7d7389;

  --accent: #ff5da2;
  --accent-strong: #ff2f8f;
  --accent-soft: rgba(255, 93, 162, 0.12);
  --accent-border: rgba(255, 93, 162, 0.35);

  --success: #4ade80;
  --error: #ff6b6b;
  --warning: #fbbf24;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);

  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; }
[hidden] { display: none !important; }

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

/* ---------- layout ---------- */

.page-wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  flex: 1;
}

/* ---------- nav ---------- */

.site-nav {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  background: rgba(14, 11, 18, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}

.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand .dot {
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: auto;
  align-items: center;
}

.nav-links a {
  color: var(--text-dim);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 600;
}
.nav-links a:hover {
  color: var(--text);
  background: var(--bg-card);
  text-decoration: none;
}
.nav-links a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-account {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.nav-search input {
  width: 180px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
}

.nav-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
  font-family: inherit;
  padding: 8px 12px;
  border-radius: var(--radius);
}

.nav-dropdown-trigger:hover {
  background: var(--bg-card);
}

.nav-dropdown-trigger .caret {
  font-size: 0.7em;
  color: var(--text-faint);
  transition: transform 0.15s ease;
}

.nav-dropdown.open .caret {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 170px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 30;
}

.nav-dropdown-menu a {
  display: block;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 600;
}

.nav-dropdown-menu a:hover {
  background: var(--bg-elevated);
  color: var(--text);
  text-decoration: none;
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--border-soft);
  margin-top: 60px;
  padding: 28px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
}

/* ---------- hero ---------- */

.hero {
  padding: 72px 0 48px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  margin: 0 0 14px;
  letter-spacing: -0.02em;
  font-weight: 800;
}

.hero .accent { color: var(--accent); }

.hero p.lead {
  color: var(--text-dim);
  font-size: 1.15rem;
  max-width: 560px;
  margin: 0 auto 32px;
}

.hero-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #180512;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-elevated); }

.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- stats strip ---------- */

.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 40px 0;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  text-align: center;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}

.stat-card .label {
  color: var(--text-faint);
  font-size: 0.85rem;
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- feature grid ---------- */

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin: 32px 0 56px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.feature-card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.feature-card p {
  color: var(--text-dim);
  margin: 0 0 14px;
  font-size: 0.92rem;
}

/* ---------- cards / panels ---------- */

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

.panel-narrow {
  max-width: 420px;
  margin: 56px auto;
}

.panel-wide {
  max-width: 640px;
  margin: 56px auto;
}

.panel + .panel {
  margin-top: 24px;
}

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

.panel-sub {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-top: -8px;
  margin-bottom: 24px;
}

/* ---------- forms ---------- */

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.field textarea {
  resize: vertical;
  min-height: 140px;
  line-height: 1.5;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-counter {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 5px;
  text-align: right;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 5px;
}

.field-error {
  font-size: 0.78rem;
  color: var(--error);
  margin-top: 5px;
  display: none;
}
.field.has-error input {
  border-color: var(--error);
}
.field.has-error .field-error {
  display: block;
}

.form-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* ---------- alerts ---------- */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 18px;
  border: 1px solid transparent;
  display: none;
}
.alert.visible { display: block; }

.alert-error {
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.3);
  color: #ffb0b0;
}

.alert-success {
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.3);
  color: #a7f3c8;
}

/* ---------- tables ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

thead th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.92rem;
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-elevated); }

td.rank { color: var(--text-faint); font-weight: 700; }
td.rank.top1 { color: #ffd54f; }
td.rank.top2 { color: #d8d8d8; }
td.rank.top3 { color: #d99c5f; }

td.player-name a {
  color: var(--text);
  font-weight: 700;
}
td.player-name a:hover { color: var(--accent); }

.flag {
  display: inline-block;
  width: 20px;
  height: 15px;
  border-radius: 2px;
  background-color: var(--bg-elevated);
  box-shadow: 0 0 0 1px var(--border);
  margin-right: 8px;
  vertical-align: middle;
}

/* ---------- mode tabs ---------- */

.mode-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.mode-tab {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

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

.mode-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

/* ---------- profile ---------- */

.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 32px 0 24px;
  flex-wrap: wrap;
}

.profile-avatar {
  width: 84px;
  height: 84px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
  overflow: hidden;
}

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

.avatar-upload-row {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.profile-name {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0;
}

.profile-meta {
  color: var(--text-faint);
  font-size: 0.9rem;
  margin-top: 4px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 40px;
}

.stats-grid .stat-card .value { font-size: 1.5rem; }

/* ---------- setup page ---------- */

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0 0 32px;
}

.steps > li {
  position: relative;
  padding: 0 0 28px 44px;
  border-left: 2px solid var(--border);
  margin-left: 17px;
}
.steps > li:last-child { border-left-color: transparent; padding-bottom: 0; }

.steps > li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: -18px;
  top: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.steps h3 { margin: 4px 0 8px; }
.steps p { color: var(--text-dim); margin: 0 0 8px; }

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

code {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
}

pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  margin: 0 0 8px;
  line-height: 1.6;
}

.callout {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.9rem;
  margin: 24px 0;
}

.callout strong { color: var(--accent); }

/* ---------- bbcode (userpages) ---------- */

.bbcode-notice {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 12px 0;
}

.bbcode-quote {
  border-left: 3px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 10px 14px;
  margin: 12px 0;
}

.bbcode-quote cite {
  display: block;
  font-style: normal;
  font-size: 0.8rem;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.bbcode-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 12px 0;
}

.bbcode-box summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent);
}

.bbcode-box[open] summary { margin-bottom: 8px; }

.bbcode-list {
  margin: 12px 0;
  padding-left: 22px;
}

.bbcode-img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 8px 0;
}

/* ---------- misc ---------- */

.section-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 48px 0 4px;
}

.section-sub {
  color: var(--text-dim);
  margin: 0 0 24px;
}

.empty-state, .loading-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-faint);
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
  margin-bottom: 10px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .nav-links { gap: 0; }
  .hero { padding: 48px 0 32px; }
  .panel { padding: 24px 18px; }
  thead th, tbody td { padding: 10px 12px; }
}

/* light mode support (system preference) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #faf8fb;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --border: #e7e1ec;
    --border-soft: #efe9f2;
    --text: #201a27;
    --text-dim: #5c5468;
    --text-faint: #8a8194;
    --shadow: 0 8px 30px rgba(80, 40, 70, 0.08);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
}
