:root {
  --bg: #09090b;
  --bg-subtle: #121218;
  --surface: #18181f;
  --surface-raised: #1f1f28;
  --surface-hover: #282832;
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.2);

  --text: #ffffff;
  --text-secondary: #d4d4d8;
  --text-tertiary: #a1a1aa;

  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-muted: rgba(45, 212, 191, 0.15);
  --accent-ink: #042f2e;
  --accent-text: #5eead4;

  --danger: #fca5a5;
  --danger-muted: rgba(248, 113, 113, 0.15);
  --success: #86efac;
  --success-muted: rgba(74, 222, 128, 0.15);
  --warning: #fcd34d;
  --warning-muted: rgba(251, 191, 36, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --sidebar-w: 240px;
  --header-h: 64px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --ease: 0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  margin: 0;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body { margin: 0; min-height: 100%; min-height: 100dvh; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

body.sidebar-open { overflow: hidden; }

a { color: inherit; text-decoration: none; }
code, .mono { font-family: var(--mono); color: var(--accent-text); }
.muted { color: var(--text-secondary); }
.muted a { color: var(--accent-text); text-decoration: none; }
.muted a:hover { text-decoration: underline; }
.small { font-size: 0.8125rem; }
.hidden { display: none !important; }
.danger-text { color: var(--danger); }

h1, h2, h3, h4, strong { color: var(--text); }

dialog { color: var(--text); }

::selection { background: rgba(45, 212, 191, 0.25); }

/* Background */
.mesh-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 70% 50% at 0% 0%, rgba(45, 212, 191, 0.08), transparent 50%),
    radial-gradient(ellipse 55% 45% at 100% 0%, rgba(139, 92, 246, 0.1), transparent 45%),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(251, 191, 36, 0.05), transparent 50%),
    var(--bg);
}

/* Brand */
.brand-mark {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  max-width: 40px;
  max-height: 40px;
  border-radius: 50%;
  display: block;
  flex: 0 0 40px;
  flex-shrink: 0;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 1px var(--border);
  position: relative;
  contain: layout style paint;
}
.brand-mark img {
  width: 40px;
  height: 40px;
  max-width: 40px;
  max-height: 40px;
  object-fit: cover;
  display: block;
}
.brand-mark-lg {
  width: 52px;
  height: 52px;
  min-width: 52px;
  min-height: 52px;
  max-width: 52px;
  max-height: 52px;
  flex-basis: 52px;
}
.brand-mark-lg img {
  width: 52px;
  height: 52px;
  max-width: 52px;
  max-height: 52px;
}
.brand-text strong { display: block; font-size: 0.9rem; font-weight: 600; letter-spacing: -0.02em; }
.brand-text span { display: block; font-size: 0.7rem; color: var(--text-tertiary); margin-top: 1px; }

.brand-link {
  text-decoration: none;
  color: inherit;
  transition: opacity var(--ease);
}
.brand-link:hover { opacity: 0.85; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.95rem;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), color var(--ease), opacity var(--ease);
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface-raised);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }

.btn-danger {
  background: var(--danger-muted);
  border-color: rgba(248, 113, 113, 0.25);
  color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.2); }

.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.75rem; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent-text);
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
}
.link-btn:hover { text-decoration: underline; text-underline-offset: 2px; }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

/* Forms */
.field { display: grid; gap: 0.4rem; }
.field span { font-size: 0.8125rem; font-weight: 500; color: var(--text); }

input, textarea, select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  transition: border-color var(--ease), box-shadow var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-tertiary); opacity: 1; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}
textarea { resize: vertical; min-height: 96px; font-family: var(--mono); font-size: 0.8125rem; }

.form-error {
  color: var(--danger);
  font-size: 0.8125rem;
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--danger-muted);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.stack { display: grid; gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ========== LOGIN ========== */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-showcase {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem;
  border-right: 1px solid var(--border);
  background: var(--bg-subtle);
}

.auth-showcase-content { max-width: 400px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.auth-showcase h1 {
  font-size: clamp(1.85rem, 3.5vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 1rem;
}
.auth-showcase h1 em {
  font-style: normal;
  color: var(--accent);
}

.auth-features {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}
.auth-features li {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.feature-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent-muted);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 0.9rem;
}

.auth-panel { display: grid; place-items: center; padding: 2rem; }

.auth-card {
  width: min(100%, 380px);
  padding: 2rem;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.auth-card h2 { margin: 1.25rem 0 0.35rem; font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.auth-card > p { margin: 0 0 1.5rem; color: var(--text-secondary); font-size: 0.875rem; }

/* ========== APP SHELL ========== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  border-right: 1px solid var(--border);
  background: var(--bg-subtle);
  overflow-x: hidden;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.65rem;
  margin-bottom: 1.5rem;
  min-width: 0;
  overflow: hidden;
}

.sidebar-nav { display: grid; gap: 0.2rem; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--ease);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--accent-muted); color: var(--accent); }
.nav-icon { width: 18px; height: 18px; opacity: 0.85; flex-shrink: 0; }
.nav-icon svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.sidebar-footer {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 0.8rem;
  color: white;
}
.user-chip strong { display: block; font-size: 0.8125rem; font-weight: 600; }
.user-chip span { font-size: 0.7rem; color: var(--text-tertiary); }

.app-main { min-width: 0; display: flex; flex-direction: column; }

.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 9, 11, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-header h1 { margin: 0; font-size: 1.125rem; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.app-header p { margin: 0.1rem 0 0; font-size: 0.75rem; color: var(--text-secondary); }
.app-header a { color: var(--text-secondary); }
.app-header a:hover { color: var(--accent-text); }

.header-actions { display: flex; gap: 0.5rem; align-items: center; }

.header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.25rem 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}
.header-user .user-avatar { width: 28px; height: 28px; font-size: 0.7rem; }
.header-user-name { font-size: 0.8125rem; font-weight: 500; padding-right: 0.25rem; }

.app-content {
  padding: 1.75rem;
  flex: 1;
  width: 100%;
  max-width: 1100px;
}

.app-content--detail {
  max-width: 1000px;
}

/* Stats */
.stats-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stat-card {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  min-width: 130px;
}
.stat-card .label {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.stat-card .value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0.15rem;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ========== ACCOUNT CARDS ========== */
.accounts-grid {
  display: grid;
  gap: 1rem;
}

.account-card {
  position: relative;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1.25rem;
  display: grid;
  gap: 1rem;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.account-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }

.account-card-overlay { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.account-card .link-btn,
.account-card .sync-games,
.account-card .copy-id,
.account-card .delete-account,
.account-card .account-actions { position: relative; z-index: 2; }

.account-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.account-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  flex-shrink: 0;
}

.account-meta { flex: 1; min-width: 0; }
.account-meta h2 { margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.account-meta h2 a { color: var(--text); }
.account-meta h2 a:hover { color: var(--accent-text); }

.account-uuid {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.3rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
}
.account-uuid code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-live { background: var(--success-muted); color: var(--success); }
.badge-sync { background: var(--warning-muted); color: var(--warning); }
.badge-error { background: var(--danger-muted); color: var(--danger); }
.badge-game { background: var(--accent-muted); color: var(--accent); }

.account-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.name-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface-hover);
  border: 1px solid var(--border);
}

/* Code section */
.code-section {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.code-ring {
  --progress: 0%;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}
.code-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.code-ring .ring-bg { fill: none; stroke: var(--border-strong); stroke-width: 3; }
.code-ring .ring-progress {
  fill: none;
  stroke: url(#ringGradient);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 251.2;
  stroke-dashoffset: calc(251.2 - (251.2 * var(--progress) / 100));
  transition: stroke-dashoffset 1s linear;
}

.code-display { flex: 1; }
.guard-code {
  font-family: var(--mono);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.guard-code-lg { font-size: 2.25rem; letter-spacing: 0.2em; }

.code-timer { margin-top: 0.25rem; font-size: 0.75rem; color: var(--text-secondary); }
.code-timer strong { color: var(--accent-text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Games */
.games-block { border-top: 1px solid var(--border); padding-top: 0.85rem; }
.games-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.games-header span { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); }

.games-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
  max-height: 180px;
  overflow-y: auto;
}
.games-list-full { max-height: 400px; }

.game-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
}
.game-item:hover { background: var(--surface-hover); }
.game-item img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }

.game-fallback {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-tertiary);
}
.game-item span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.game-more, .games-status { font-size: 0.75rem; color: var(--text-secondary); padding: 0.35rem 0.5rem; }
.games-status { display: flex; align-items: center; gap: 0.45rem; }
.games-status.error { color: var(--danger); }

.account-footer { display: flex; justify-content: flex-end; gap: 0.5rem; }

/* Detail page */
.detail-layout {
  display: grid;
  gap: 1rem;
  max-width: 960px;
}

.detail-card {
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1.35rem;
}

.detail-card-title {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.detail-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.detail-card-header .detail-card-title { margin: 0; }

.code-hero-card {
  padding: 1.5rem;
}

.code-hero-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.account-identity {
  display: flex;
  gap: 1rem;
  align-items: center;
  min-width: 0;
}

.account-avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 1.35rem;
}

.identity-badges {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.account-identity h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.account-meta-line {
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.code-section-hero {
  flex: 1;
  min-width: min(100%, 320px);
  max-width: 420px;
  padding: 1.25rem 1.5rem;
}

.code-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
}

.detail-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

.copy-field {
  margin-bottom: 1rem;
}
.copy-field:last-child { margin-bottom: 0; }

.copy-field label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
}

.copy-field-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.copy-field-row code {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  word-break: break-all;
  color: var(--text);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  display: block;
}

.copy-field-row .btn { flex-shrink: 0; align-self: stretch; }

.detail-games-card .games-list-full {
  max-height: 480px;
}

.account-admin-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
  flex-wrap: wrap;
}

.games-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.35rem;
  max-height: 480px;
  overflow-y: auto;
}

.games-grid .game-item {
  padding: 0.5rem 0.6rem;
  border: 1px solid transparent;
}
.games-grid .game-item:hover {
  background: var(--surface-hover);
  border-color: var(--border);
}

.detail-hero {
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.detail-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.detail-top h1 { margin: 0.35rem 0 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }

.url-panel {
  margin-top: 1.25rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}
.url-panel label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
}
.url-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.url-row code {
  flex: 1;
  min-width: 180px;
  font-size: 0.75rem;
  word-break: break-all;
  color: var(--accent-text);
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  border: 1px solid var(--border);
}

/* Empty / loading */
.empty-state, .loading-state {
  text-align: center;
  padding: 3.5rem 2rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
}
.empty-icon { font-size: 2rem; margin-bottom: 0.75rem; opacity: 0.4; }
.empty-state h2 { margin: 0 0 0.4rem; font-size: 1.125rem; font-weight: 600; }
.empty-state p { margin: 0 0 1.25rem; color: var(--text-secondary); font-size: 0.875rem; }
.loading-state { color: var(--text-secondary); font-size: 0.875rem; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modals */
.modal {
  border: none;
  padding: 0;
  background: transparent;
  width: min(100%, 520px);
  max-height: 90vh;
}
.modal-wide { width: min(100%, 640px); }
.modal::backdrop { background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); }

.modal-panel {
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  color: var(--text);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
}
.modal-header h2 { margin: 0; font-size: 1.05rem; font-weight: 600; color: var(--text); }
.modal-header p { margin: 0.25rem 0 0; font-size: 0.8125rem; color: var(--text-secondary); }

.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; color: var(--text); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface-raised);
}

.section-label {
  margin: 0 0 0.65rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.api-snippet {
  margin: 0;
  padding: 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.6;
  color: #bbf7d0;
  white-space: pre-wrap;
  word-break: break-word;
}

.api-key-create { display: grid; grid-template-columns: 1fr auto; gap: 0.65rem; align-items: end; }

.key-banner {
  padding: 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--accent-muted);
  border: 1px solid rgba(45, 212, 191, 0.35);
  color: var(--text);
}
.key-banner .muted { color: var(--text-secondary); }
.key-copy-row { display: flex; gap: 0.5rem; margin-top: 0.45rem; flex-wrap: wrap; }
.key-copy-row code {
  flex: 1;
  min-width: 180px;
  word-break: break-all;
  font-size: 0.75rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
}

.key-list { list-style: none; margin: 0; padding: 0; color: var(--text); }
.key-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.key-item:last-child { border-bottom: none; }
.key-item strong { font-weight: 600; color: var(--text); }
.key-item .muted { color: var(--text-secondary); }

.advanced summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  list-style: none;
}
.advanced summary:hover { color: var(--text); }
.advanced summary::-webkit-details-marker { display: none; }
.advanced[open] summary { margin-bottom: 0.5rem; }

.mobile-nav-toggle { display: none; }

/* Sidebar overlay (mobile) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sidebar-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile bottom navigation */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
  gap: 0.15rem;
  padding: 0.35rem 0.5rem calc(0.45rem + env(safe-area-inset-bottom));
  background: rgba(18, 18, 24, 0.95);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 52px;
  padding: 0.35rem 0.25rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--ease), background var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-item:disabled {
  cursor: default;
  opacity: 1;
}
.mobile-nav-item.active,
.mobile-nav-item[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-muted);
}
.mobile-nav-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.pwa-standalone .app-header {
  padding-top: env(safe-area-inset-top);
  height: calc(var(--header-h) + env(safe-area-inset-top));
}

/* Responsive */
@media (max-width: 960px) {
  .auth-page { grid-template-columns: 1fr; min-height: 100dvh; }
  .auth-showcase { display: none; }
  .auth-panel { padding: 1.25rem; padding-top: max(1.25rem, env(safe-area-inset-top)); }
  .auth-card { width: min(100%, 420px); padding: 1.5rem; }

  .app-shell {
    grid-template-columns: 1fr;
    min-height: 100dvh;
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
  }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: min(var(--sidebar-w), 85vw);
    box-shadow: var(--shadow);
    padding-top: env(safe-area-inset-top);
    height: 100dvh;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { display: block; }
  .mobile-nav-toggle { display: inline-flex; min-width: 44px; min-height: 44px; }
  .mobile-bottom-nav { display: grid; }

  .app-content {
    padding: 1rem 1rem 1.25rem;
    max-width: none;
  }
  .app-header {
    padding: 0 1rem;
    padding-top: env(safe-area-inset-top);
    height: auto;
    min-height: var(--header-h);
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .app-header h1 { font-size: 1rem; }
  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
  }
  .header-actions .btn:not(.btn-ghost) { display: none; }
  .header-user .btn[data-logout] { display: none; }

  .grid-2, .api-key-create { grid-template-columns: 1fr; }
  .detail-top { flex-direction: column; }
  .detail-columns { grid-template-columns: 1fr; }
  .code-hero-inner { flex-direction: column; align-items: stretch; }
  .code-section-hero { max-width: none; }
  .guard-code { font-size: clamp(1.35rem, 6vw, 1.75rem); letter-spacing: 0.14em; }
  .guard-code-lg { font-size: clamp(1.75rem, 8vw, 2.25rem); }
  .header-user-name { display: none; }

  .code-section {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    gap: 0.85rem;
  }
  .code-ring { margin: 0 auto; }

  .accounts-grid { gap: 0.85rem; }
  .account-card { padding: 1rem; }
  .account-footer { flex-wrap: wrap; }

  .stats-row { gap: 0.5rem; }
  .stat-card { flex: 1; min-width: calc(50% - 0.25rem); }

  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .modal {
    width: min(100%, calc(100vw - 1.5rem));
    margin: auto;
    max-height: calc(100dvh - 2rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
  .modal-panel { max-height: calc(100dvh - 2rem - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }

  .field input,
  .field textarea,
  .field select {
    font-size: 16px;
    min-height: 44px;
  }

  .btn {
    min-height: 44px;
    padding: 0.65rem 1rem;
  }
  .btn-sm { min-height: 40px; }

  .copy-field-row { flex-direction: column; }
  .copy-field-row .btn { width: 100%; }
  .url-row { flex-direction: column; align-items: stretch; }
  .url-row .btn { width: 100%; }
}

@media (max-width: 480px) {
  .header-actions .btn span.btn-label { display: none; }
  .account-uuid code { max-width: 52vw; }
  .api-snippet { font-size: 0.68rem; }
}

@media (min-width: 961px) {
  .mobile-bottom-nav { display: none !important; }
  .app-shell { padding-bottom: 0; }
}
