/* GameCore - Nocturne Design System */

:root {
  --color-bg: #161826;
  --color-surface: #232532;
  --color-text: #e9e9ed;
  --color-accent: #9184d9;
  --color-accent-2: #a7a1db;
  --color-divider: color-mix(in srgb, #e9e9ed 16%, transparent);

  --color-neutral-100: #f3f5fe;
  --color-neutral-200: #e4e7f5;
  --color-neutral-300: #cfd3e5;
  --color-neutral-400: #b2b6ca;
  --color-neutral-500: #9397ab;
  --color-neutral-600: #75798c;
  --color-neutral-700: #595d6c;
  --color-neutral-800: #3f424d;
  --color-neutral-900: #292b31;

  --color-accent-100: #f5f4ff;
  --color-accent-200: #e7e5fe;
  --color-accent-300: #d2cefd;
  --color-accent-400: #b5abfc;
  --color-accent-500: #968ae0;
  --color-accent-600: #796cbf;
  --color-accent-700: #5d5294;
  --color-accent-800: #423a6a;
  --color-accent-900: #2b2741;

  --color-accent-2-100: #f5f4ff;
  --color-accent-2-200: #e7e5fe;
  --color-accent-2-300: #d2cefd;
  --color-accent-2-400: #b5afe8;
  --color-accent-2-500: #9690c9;
  --color-accent-2-600: #7972a9;
  --color-accent-2-700: #5c5783;
  --color-accent-2-800: #423e5d;
  --color-accent-2-900: #2b293a;

  --color-section: #262a60;
  --color-section-glow: #353b80;
  --color-section-ghost: #4c5397;

  /* Status colors - not part of core Nocturne, added for GameCore's server/node status needs */
  --status-online: #4ade80;
  --status-offline: #75798c;
  --status-warning: #facc15;
  --status-danger: #f87171;

  --font-heading: "Inter", system-ui, sans-serif;
  --font-heading-weight: 500;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --space-1: 2.8px;
  --space-2: 5.6px;
  --space-3: 8.4px;
  --space-4: 11.2px;
  --space-6: 16.8px;
  --space-8: 22.4px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;

  --shadow-sm: 0 0 0 1px #3f424d;
  --shadow-md: 0 0 0 1px #595d6c, 0 6px 18px rgba(0,0,0,0.55);
  --shadow-lg: 0 0 0 1px #9397ab, 0 16px 40px rgba(0,0,0,0.65);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 var(--space-2);
}
h1 { font-size: 42px; }
h2 { font-size: 32px; }
h3 { font-size: 25px; }
h4 { font-size: 20px; }
h5 { font-size: 16px; }
h6 { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-accent); text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
.text-muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.text-mono { font-family: var(--font-mono); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

/* — rules — */
.hr {
  height: 1px; border: 0; margin: var(--space-4) 0;
  background: linear-gradient(to right,
    transparent, var(--color-divider) 48px,
    var(--color-divider) calc(100% - 48px), transparent);
}

/* — markdown (README) — */
.markdown-body {
  font-size: 13.5px; line-height: 1.6; color: var(--color-text);
}
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  color: var(--color-text); margin: var(--space-6) 0 var(--space-3);
  line-height: 1.3;
}
.markdown-body h1 { font-size: 22px; padding-bottom: var(--space-2); border-bottom: 1px solid var(--color-neutral-800); }
.markdown-body h2 { font-size: 18px; padding-bottom: var(--space-2); border-bottom: 1px solid var(--color-neutral-800); }
.markdown-body h3 { font-size: 15.5px; }
.markdown-body h4, .markdown-body h5, .markdown-body h6 { font-size: 13.5px; }
.markdown-body p { margin: 0 0 var(--space-3); }
.markdown-body a { color: var(--color-accent-400); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body ul, .markdown-body ol { margin: 0 0 var(--space-3); padding-left: 22px; }
.markdown-body li { margin: 4px 0; }
.markdown-body li > ul, .markdown-body li > ol { margin: 4px 0; }
.markdown-body code {
  font-family: var(--font-mono); font-size: 0.88em;
  background: var(--color-neutral-900); border: 1px solid var(--color-neutral-800);
  border-radius: 4px; padding: 1px 5px;
}
.markdown-body pre {
  background: #0d0e16; border: 1px solid var(--color-neutral-800); border-radius: var(--radius-md);
  padding: var(--space-3); overflow-x: auto; margin: 0 0 var(--space-3);
}
.markdown-body pre code { background: none; border: none; padding: 0; font-size: 12.5px; }
.markdown-body blockquote {
  margin: 0 0 var(--space-3); padding: var(--space-1) var(--space-3);
  border-left: 3px solid var(--color-accent-700); color: var(--color-neutral-400);
}
.markdown-body table { width: 100%; border-collapse: collapse; margin: 0 0 var(--space-3); font-size: 13px; }
.markdown-body th, .markdown-body td { border: 1px solid var(--color-neutral-800); padding: 6px 10px; text-align: left; }
.markdown-body th { background: var(--color-neutral-900); font-weight: 600; }
.markdown-body img { max-width: 100%; border-radius: var(--radius-sm); }
.markdown-body hr { border: 0; height: 1px; background: var(--color-neutral-800); margin: var(--space-4) 0; }

/* — buttons — */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: var(--radius-md);
}
.btn svg { display: block; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { color: var(--color-accent); border-color: var(--color-accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.btn-primary:active { background: color-mix(in srgb, var(--color-accent) 22%, transparent); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-secondary:active { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-danger { color: var(--status-danger); border-color: var(--status-danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--status-danger) 12%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); }
.btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-ghost:active { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-block { width: 100%; margin-top: var(--space-2); }

/* — forms — */
.field { margin-bottom: var(--space-4); }
.field > label {
  display: block; font-size: 12px; margin-bottom: 5px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.input {
  width: 100%; min-height: 36px; padding: 6px 10px; font: inherit;
  font-size: 14px; color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
textarea.input { min-height: 90px; resize: vertical; font-family: var(--font-mono); }
input[type="checkbox"] { accent-color: var(--color-accent); width: 15px; height: 15px; cursor: pointer; }
.radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.radio input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.radio .dot { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 1.5px solid var(--color-divider); }
.radio:hover .dot { border-color: var(--color-accent); }
.radio input:checked + .dot {
  border-color: var(--color-accent); background: var(--color-accent);
  box-shadow: inset 0 0 0 4px var(--color-bg);
}

/* — cards — */
.card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-3); border-radius: var(--radius-md); background: var(--color-surface);
}
.card-kicker { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-accent); }
.card-title {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 17px; line-height: 1.2;
}
.card-body { margin: 0; font-size: 13px; opacity: 0.8; flex: 1; }
.card-meta {
  display: flex; align-items: center; gap: 6px; font-size: 11px;
  color: color-mix(in srgb, var(--color-text) 50%, transparent);
}
.elev-sm { box-shadow: var(--shadow-sm); }
.elev-md { box-shadow: var(--shadow-md); }
.elev-lg { box-shadow: var(--shadow-lg); }

/* — tags — */
.tag {
  display: inline-flex; align-items: center; font-size: 11px;
  letter-spacing: 0.02em; padding: 3px 10px; white-space: nowrap;
  border-radius: calc(var(--radius-md) * 0.75);
}
.tag-accent { background: var(--color-accent-800); color: var(--color-accent-100); }
.tag-accent-2 { background: var(--color-accent-2-800); color: var(--color-accent-2-100); }
.tag-neutral { background: var(--color-neutral-800); color: var(--color-neutral-100); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }
.tag-danger { background: color-mix(in srgb, var(--status-danger) 22%, var(--color-neutral-900)); color: #fecaca; }
.tag-warning { background: color-mix(in srgb, var(--status-warning) 22%, var(--color-neutral-900)); color: #fef08a; }
.tag::before { content: ''; }
.tag-dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  margin-right: 6px; display: inline-block;
}

/* — tables — */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
  padding: var(--space-2); border-bottom: 1px solid transparent;
}
.table td { padding: var(--space-2); border-bottom: 1px solid transparent; }
.table thead tr {
  background: linear-gradient(to right,
    transparent, var(--color-divider) 48px,
    var(--color-divider) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}
.table tbody tr {
  background: linear-gradient(to right,
    transparent, color-mix(in srgb, var(--color-text) 8%, transparent) 48px,
    color-mix(in srgb, var(--color-text) 8%, transparent) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}
.table tbody tr:hover {
  background:
    linear-gradient(color-mix(in srgb, var(--color-text) 4%, transparent),
                    color-mix(in srgb, var(--color-text) 4%, transparent)) no-repeat 0 0 / 100% 100%,
    linear-gradient(to right,
      transparent, color-mix(in srgb, var(--color-text) 8%, transparent) 48px,
      color-mix(in srgb, var(--color-text) 8%, transparent) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}

/* — dialog — */
.dialog-backdrop {
  position: fixed; inset: 0; display: grid; place-items: center;
  padding: var(--space-4); z-index: 10000;
  background: color-mix(in srgb, var(--color-neutral-900) 50%, transparent);
}
.dialog {
  width: min(440px, 100%); display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4); border-radius: var(--radius-lg);
  background: var(--color-surface); box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow-y: auto;
}
.dialog-title {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 20px; display: flex; align-items: center; justify-content: space-between;
}
.dialog-body { font-size: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }

/* — empty state — */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: var(--space-8) var(--space-4); gap: var(--space-2);
  color: color-mix(in srgb, var(--color-text) 55%, transparent);
}
.empty-state .empty-icon { font-size: 32px; opacity: 0.6; }

/* — console — */
.console {
  background: #0d0e16; border: 1px solid var(--color-neutral-800); border-radius: var(--radius-md);
  padding: var(--space-4); font-family: var(--font-mono); font-size: 13px;
  color: var(--color-neutral-300); max-height: 500px; overflow-y: auto;
}
.console-line { white-space: pre-wrap; word-break: break-all; margin-bottom: 2px; }
.console-line.error { color: var(--status-danger); }
.console-line.info { color: var(--color-accent-300); }

/* — utilities — */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

/* ══════ Shell layout ══════ */
.gc-sidebar { flex: none; background: var(--color-neutral-900); border-right: 1px solid var(--color-neutral-800); display: flex; flex-direction: column; transition: width .15s ease; position: sticky; top: 0; height: 100vh; overflow: hidden; }
.gc-hdr { padding: var(--space-4); display: flex; align-items: center; gap: var(--space-3); min-height: 120px; }
.gc-collapsebtn { margin-left: auto; width: 24px; height: 24px; border-radius: var(--radius-sm); background: transparent; border: 1px solid var(--color-neutral-700); color: var(--color-neutral-400); cursor: pointer; display: flex; align-items: center; justify-content: center; flex: none; }
.gc-collapsebtn:hover { color: var(--color-text); border-color: var(--color-accent); }
.gc-navsection { padding: var(--space-3) var(--space-4) var(--space-1); font-size: 10.5px; letter-spacing: .1em; color: var(--color-neutral-500); font-weight: 500; }
.gc-navitem { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4); cursor: pointer; text-decoration: none; color: var(--color-neutral-400); }
.gc-navitem:hover { background: var(--color-neutral-800); }
.gc-navitem.active { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.gc-navlabel { font-size: 15px; white-space: nowrap; }
.gc-footer { padding: var(--space-4); border-top: 1px solid var(--color-neutral-800); display: flex; flex-direction: column; gap: var(--space-2); }
.gc-sidebar.is-collapsed .gc-navlabel, .gc-sidebar.is-collapsed .gc-navsection { display: none !important; }
.gc-sidebar.is-collapsed .gc-navitem { justify-content: center; padding-left: 0; padding-right: 0; }
.gc-sidebar.is-collapsed .gc-hdr { flex-direction: column; gap: 6px; padding: 12px 4px; }
.gc-sidebar.is-collapsed .gc-hdr img { width: 52px; height: 52px; }
.gc-sidebar.is-collapsed .gc-footer { align-items: center; }
.gc-sidebar.is-collapsed .gc-footer button { width: 38px; padding-left: 0; padding-right: 0; }

.gc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.gc-mobiletop { display: none; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-neutral-800); background: var(--color-neutral-900); position: sticky; top: 0; z-index: 20; }
.gc-pageheader { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: var(--space-6); gap: var(--space-4); }
.gc-actions { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; justify-content: flex-end; }
.gc-statgrid { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--space-4); margin-bottom: var(--space-4); }
.gc-2col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }

.gc-bottomnav { display: none; position: fixed; bottom: 0; left: 0; right: 0; height: 64px; background: var(--color-neutral-900); border-top: 1px solid var(--color-neutral-800); z-index: 30; align-items: stretch; }
.gc-bottomnav button, .gc-bottomnav a { flex: 1; background: transparent; border: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; text-decoration: none; color: var(--color-neutral-400); }
.gc-bottomnav .active { color: var(--color-accent); }
.gc-bottomnav span { font-size: 10px; font-weight: 500; }

.gc-drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; }
.gc-drawer { position: absolute; left: 0; right: 0; bottom: 0; background: var(--color-neutral-900); border-top: 1px solid var(--color-neutral-800); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: var(--space-4); }
.gc-drawer-handle { width: 36px; height: 4px; background: var(--color-neutral-700); border-radius: 2px; margin: 0 auto var(--space-4); }
.gc-drawer-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-1); cursor: pointer; text-decoration: none; color: var(--color-text); border-bottom: 1px solid var(--color-neutral-800); }
.gc-drawer-item svg { color: var(--color-accent); }

@keyframes gcFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes gcUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1024px) {
  .gc-sidebar { width: 72px !important; }
  .gc-navlabel, .gc-navsection, .gc-logoword { display: none !important; }
  .gc-collapsebtn { display: none !important; }
  .gc-hdr { flex-direction: column; gap: 6px; padding: 12px 4px !important; }
  .gc-hdr img { width: 44px !important; height: 44px !important; }
  .gc-statgrid { grid-template-columns: repeat(2,1fr) !important; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 767px) {
  .gc-sidebar { display: none !important; }
  .gc-bottomnav { display: flex !important; }
  .gc-mobiletop { display: flex !important; }
  .gc-main { padding-bottom: 78px !important; }
  .gc-pageheader { flex-wrap: wrap; gap: var(--space-3) !important; }
  .gc-pageheader .gc-actions { width: 100%; }
  .gc-2col { grid-template-columns: 1fr !important; }
  .gc-statgrid { grid-template-columns: repeat(2,1fr) !important; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

@media (max-width: 639px) {
  .gc-statgrid { grid-template-columns: 1fr 1fr !important; }
  .gc-table thead { display: none; }
  .gc-table, .gc-table tbody, .gc-table tr, .gc-table td { display: block; width: 100%; }
  .gc-table { border: none; }
  .gc-table tr { margin-bottom: var(--space-2); border: 1px solid var(--color-neutral-800); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); background: var(--color-neutral-900); }
  .gc-table td { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-1) 0; border: none !important; text-align: right; }
  .gc-table td:empty { display: none; }
  .gc-table td[data-label]:before { content: attr(data-label); color: var(--color-neutral-500); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; text-align: left; font-family: var(--font-body); }
  .gc-table td.gc-td-actions { flex-wrap: wrap; justify-content: flex-end; }
}

/* — error pages — */
.error-page-container {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 80vh; text-align: center;
  background: radial-gradient(circle at center, color-mix(in srgb, var(--color-accent) 8%, transparent) 0%, transparent 70%);
}
.error-code { font-family: var(--font-heading); font-size: 8rem; font-weight: 700; line-height: 1; opacity: 0.9; }
.error-title { font-size: 2rem; letter-spacing: 2px; margin-bottom: 1rem; font-weight: 500; border-bottom: 2px solid currentColor; padding-bottom: 0.5rem; display: inline-block; }
.error-message { color: var(--color-neutral-400); max-width: 500px; margin-bottom: 2rem; }
.error-icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.8; }
.error-actions { display: flex; gap: var(--space-3); justify-content: center; }
.error-404 { color: var(--status-warning); }
.error-403 { color: var(--status-danger); }
.error-500 { color: var(--status-danger); }
.error-502 { color: var(--color-neutral-500); }
.error-logo { width: 100px; height: 100px; margin-bottom: 2rem; border-radius: var(--radius-md); }
h1:focus, .error-code:focus { outline: none !important; box-shadow: none !important; }
