:root {
  --bg-deep: #0a0e17;
  --bg-panel: #111827;
  --bg-card: #1a2234;
  --border: #2a3548;
  --text: #e8edf5;
  --text-muted: #8896ab;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #22c55e;
  --canvas-bg: #141a26;
  --platform-color: #1e2738;
  --canvas-hint-bg: rgba(17, 24, 39, 0.82);
  --canvas-hint-border: rgba(42, 53, 72, 0.55);
  --face-u: #0051ba;
  --face-d: #009b48;
  --face-f: #e60012;
  --face-b: #ff5800;
  --face-r: #ffd500;
  --face-l: #f5f5f5;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --panel-w: 260px;
  --subpage-panel-w: 288px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body.page-scroll {
  overflow: auto;
}

body.page-scroll #app {
  min-height: 100vh;
  height: auto;
}

body {
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99, 102, 241, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(34, 197, 94, 0.06), transparent);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: "logo menu stats";
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header:not(:has(.stats)) {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "logo menu";
}

.logo {
  grid-area: logo;
  justify-self: start;
  min-width: 0;
}

.header-center {
  grid-area: menu;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
}

.header:not(:has(.stats)) .header-center {
  justify-self: end;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-account {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-account-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.header-toggle-btn {
  display: none;
}

.header-panel-quick {
  display: none;
}

.stats {
  grid-area: stats;
  display: flex;
  gap: 32px;
  flex-shrink: 0;
  justify-self: end;
}

.header-nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

.nav-label {
  line-height: 1;
}

.btn-nav-practice,
.btn-nav-competition,
.btn-nav-duel,
.btn-leaderboard,
.btn-nav-profile,
.btn-nav-admin {
  flex: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 10px;
  font-size: 0.78rem;
  white-space: nowrap;
  line-height: 1.2;
  font-weight: 600;
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, filter 0.15s;
}

.header-nav-links .btn:not(.active):hover:not(:disabled) {
  background: #243049;
  border-color: #3d4f6a;
  color: var(--text);
}

[data-theme="light"] .header-nav-links .btn:not(.active):hover:not(:disabled) {
  background: #e2e8f0;
  border-color: #b8c4d4;
}

.header-nav-links .btn.active:hover:not(:disabled) {
  filter: brightness(1.07);
}

.btn-nav-practice.active {
  background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 12px rgba(56, 189, 248, 0.35);
}

.btn-nav-competition.active {
  background: linear-gradient(135deg, #eab308 0%, #f59e0b 55%, #ea580c 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 12px rgba(234, 179, 8, 0.35);
}

.btn-nav-duel.active {
  background: linear-gradient(135deg, #f97316 0%, #ef4444 55%, #db2777 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 14px rgba(239, 68, 68, 0.45);
}

.btn-leaderboard.active {
  background: linear-gradient(135deg, #6366f1 0%, #22c55e 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.35);
}

.btn-nav-profile.active {
  background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 12px rgba(139, 92, 246, 0.35);
}

.btn-nav-admin.active {
  background: linear-gradient(135deg, #64748b 0%, #94a3b8 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 12px rgba(100, 116, 139, 0.35);
}

.btn-nav-profile[hidden],
.btn-nav-admin[hidden] {
  display: none !important;
}

.header-link {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.header-link:hover {
  color: var(--text);
  background: var(--bg-card);
}

.panel-header-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  background: #243049;
  border-color: #3d4f6a;
}

.auth-guest, .auth-user {
  display: flex;
  align-items: center;
  gap: 6px;
}

.auth-username {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-right: 4px;
  text-decoration: none;
}

.auth-username:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.profile-panel {
  margin-bottom: 14px;
}

.profile-panel .page-card-head {
  border-radius: 0;
}

.profile-form {
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.profile-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.profile-form input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.profile-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.profile-form input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.profile-form-divider {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 4px 0 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.profile-alert {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
}

.profile-alert--ok {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac;
}

.profile-alert--err {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

.profile-link-btn {
  text-decoration: none;
  display: block;
  text-align: center;
}

.panel-link-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-link-stack .btn,
.panel-link-stack a.btn {
  flex: none;
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  font-size: 0.82rem;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
  box-sizing: border-box;
  text-decoration: none;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Yan paneller: kaydırılabilir gövde + sabit alt bölüm */
.panel-sidebar {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.panel-sidebar-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 8px;
}

.panel-sidebar-foot {
  flex-shrink: 0;
  padding: 8px 16px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.12);
}

.panel-sidebar-foot .panel-section {
  margin-bottom: 0;
}

.panel-section--compact h2 {
  margin-bottom: 10px;
}

.main--subpage .panel-left,
.main--subpage .panel-right {
  width: var(--subpage-panel-w);
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.main--subpage.panel-sidebar-panel .panel-left,
.main--subpage.panel-sidebar-panel .panel-right.panel-sidebar {
  overflow: hidden;
}

.profile-hero-btn {
  margin-top: 14px;
  text-decoration: none;
}

.profile-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.profile-form-actions .btn {
  flex: 1;
  text-decoration: none;
  text-align: center;
}

.profile-stat-small {
  font-size: 0.72rem;
}

[data-theme="light"] .profile-alert--ok {
  color: #15803d;
}

[data-theme="light"] .profile-alert--err {
  color: #b91c1c;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  flex: none;
}

.btn-block {
  width: 100%;
}

.btn-danger {
  border-color: #b91c1c;
  color: #fca5a5;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(185, 28, 28, 0.2);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-cube {
  font-size: 1.6rem;
  color: var(--accent);
  animation: spin-slow 8s linear infinite;
}

@keyframes spin-slow {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(360deg); }
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.puzzle-type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.puzzle-type-btn,
a.puzzle-type-btn {
  min-width: 48px;
  padding: 8px 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.puzzle-type-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
}

.puzzle-type-btn.active {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
}

.puzzle-type-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

/* Main layout */
.main {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.main .canvas-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.panel-left,
.panel-right {
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--panel-w);
  z-index: 4;
  transition: transform 0.25s ease;
  will-change: transform;
}

.panel-left {
  left: 0;
  transform: translateX(0);
}

.panel-right {
  right: 0;
  transform: translateX(0);
}

.main.left-collapsed .panel-left {
  transform: translateX(-100%);
  pointer-events: none;
}

.main.right-collapsed .panel-right {
  transform: translateX(100%);
  pointer-events: none;
}

.main-content-page {
  overflow-y: auto;
  padding: 16px;
}

.page-main-area {
  overflow-y: auto;
  background: var(--canvas-bg);
  padding: 20px 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.main--subpage .canvas-wrap.page-main-area {
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
}

.subpage-shell,
.subpage-shell--wide {
  width: 100%;
  max-width: min(1080px, 100%);
  padding-bottom: 24px;
  margin: 0 auto;
}

.subpage-hero {
  text-align: center;
  margin-bottom: 14px;
  padding: 8px 12px 4px;
}

.subpage-hero-icon {
  font-size: 1.75rem;
  line-height: 1;
  margin-bottom: 6px;
  filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.35));
}

.subpage-hero-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  color: var(--text);
}

.subpage-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.subpage-chip {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.subpage-chip--accent {
  border-color: rgba(99, 102, 241, 0.45);
  color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.rank-badge--small {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 999px;
  vertical-align: middle;
}

.lb-player {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lb-player-name {
  font-weight: 500;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-width: 1px;
  border-style: solid;
}

.rank-badge-icon {
  font-size: 0.85em;
  line-height: 1;
}

.rank-badge--beginner {
  border-color: rgba(34, 197, 94, 0.45);
  color: #4ade80;
  background: rgba(34, 197, 94, 0.12);
}

.rank-badge--intermediate {
  border-color: rgba(59, 130, 246, 0.45);
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.12);
}

.rank-badge--advanced {
  border-color: rgba(249, 115, 22, 0.45);
  color: #fb923c;
  background: rgba(249, 115, 22, 0.12);
}

.rank-badge--pro {
  border-color: rgba(168, 85, 247, 0.45);
  color: #c084fc;
  background: rgba(168, 85, 247, 0.12);
}

.rank-badge--world_class {
  border-color: rgba(234, 179, 8, 0.5);
  color: #facc15;
  background: rgba(234, 179, 8, 0.14);
}

[data-theme="light"] .rank-badge--beginner { color: #15803d; }
[data-theme="light"] .rank-badge--intermediate { color: #1d4ed8; }
[data-theme="light"] .rank-badge--advanced { color: #c2410c; }
[data-theme="light"] .rank-badge--pro { color: #7e22ce; }
[data-theme="light"] .rank-badge--world_class { color: #a16207; }

.user-rank-badge {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rank-card {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.rank-card--beginner { border-color: rgba(34, 197, 94, 0.35); }
.rank-card--intermediate { border-color: rgba(59, 130, 246, 0.35); }
.rank-card--advanced { border-color: rgba(249, 115, 22, 0.35); }
.rank-card--pro { border-color: rgba(168, 85, 247, 0.35); }
.rank-card--world_class { border-color: rgba(234, 179, 8, 0.4); }

.rank-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rank-card-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.rank-card--compact .rank-card-icon {
  font-size: 1.25rem;
}

.rank-card-label {
  font-weight: 700;
  font-size: 0.92rem;
}

.rank-card-score {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.rank-progress {
  margin-top: 10px;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-card);
  overflow: hidden;
}

.rank-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  transition: width 0.35s ease;
}

.rank-progress-hint {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.rank-progress-hint--max {
  color: var(--accent);
}

.rank-points-remaining {
  color: var(--accent);
  font-weight: 700;
}

.rank-threshold-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rank-threshold-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.rank-threshold-icon {
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.rank-threshold-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rank-threshold-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.rank-threshold-points {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.list-pagination {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
}

.list-pagination-range {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-pagination-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.list-pagination-current {
  font-size: 0.75rem;
  color: var(--text);
  font-weight: 600;
  padding: 0 2px;
  white-space: nowrap;
}

.list-pagination-btn {
  white-space: nowrap;
  min-width: unset;
  width: auto;
  padding: 5px 9px;
  font-size: 0.72rem;
  line-height: 1.2;
}

.list-pagination-btn.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

@media (max-width: 560px) {
  .list-pagination {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .list-pagination-range {
    text-align: center;
    overflow: visible;
    text-overflow: unset;
  }

  .list-pagination-actions {
    justify-content: center;
  }
}

.profile-panel .list-pagination {
  border-radius: 0 0 var(--radius) var(--radius);
}

.score-points-earned {
  color: #4ade80;
  font-weight: 600;
}

.score-points-lost {
  color: #f87171;
  font-weight: 600;
}

.admin-user-edit-panel {
  margin-bottom: 16px;
}

.admin-user-edit-panel .page-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-user-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px 16px;
}

.admin-check-label--block {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: end;
  min-height: 42px;
}

.rank-points-hint {
  margin: 12px 0 0;
  padding: 0 0 0 1rem;
  list-style: disc;
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rank-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.rank-panel-scroll {
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.rank-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-card);
}

.rank-table .rank-num {
  width: 44px;
  text-align: center;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.rank-table tbody tr.rank-gold td {
  background: rgba(255, 193, 7, 0.09);
}

.rank-table tbody tr.rank-silver td {
  background: rgba(180, 190, 200, 0.1);
}

.rank-table tbody tr.rank-bronze td {
  background: rgba(205, 127, 50, 0.1);
}

.rank-medal {
  display: inline-block;
  min-width: 1.4em;
}

.main--subpage .canvas-wrap {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-left: var(--subpage-panel-w);
  padding-right: var(--subpage-panel-w);
  box-sizing: border-box;
  transition: padding 0.25s ease;
}

.main--subpage.left-collapsed .canvas-wrap {
  padding-left: 0;
}

.main--subpage.right-collapsed .canvas-wrap {
  padding-right: 0;
}

.main--subpage .page-main-area {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* legacy card aliases */
.page-content-card {
  width: 100%;
  max-width: none;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.page-content-card--wide {
  max-width: none;
}

.page-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.page-card-head h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  margin: 0;
}

.page-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.lb-table-wrap--card {
  border: none;
  border-radius: 0;
  max-height: calc(100vh - 168px);
  overflow: auto;
}

.lb-period-stack {
  flex-direction: column;
  align-items: stretch;
}

.lb-period-stack .lb-tab {
  text-align: center;
}

.subpage-stat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.subpage-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.subpage-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.subpage-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--text);
}

.btn-block {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
}

.auth-switch {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.auth-switch-btn {
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.auth-switch-btn:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.content-panel {
  max-width: 960px;
  margin: 0 auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.logo-link {
  color: inherit;
  text-decoration: none;
}

.logo-link:hover {
  color: var(--accent);
}

.header-link.active {
  color: var(--accent);
  font-weight: 600;
}

.panel-header-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.auth-guest[hidden],
.auth-user[hidden],
#auth-loading[hidden] {
  display: none !important;
}

.auth-loading {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0 4px;
}

.panel {
  background: var(--bg-panel);
  border-color: var(--border);
  overflow-y: auto;
  padding: 16px;
}

.panel-left {
  border-right: 1px solid var(--border);
}

.panel-right {
  border-left: 1px solid var(--border);
}

.panel-section {
  margin-bottom: 18px;
}

.panel-section h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

.panel .btn-block,
.panel a.btn-block,
.panel .btn-sm.btn-block {
  flex: none;
  width: 100%;
  box-sizing: border-box;
}

.friend-request-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.friend-request-form .btn {
  flex: none;
}

/* Buttons */
.btn-group {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.btn {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: #243049;
  border-color: #3d4f6a;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

[data-theme="light"] .btn:hover:not(:disabled) {
  background: #e2e8f0;
  border-color: #b8c4d4;
}

.header-nav-links .btn-nav-practice.active,
.header-nav-links .btn-nav-practice.active:hover:not(:disabled) {
  background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%);
  border-color: transparent;
  color: #fff;
}

.header-nav-links .btn-nav-competition.active,
.header-nav-links .btn-nav-competition.active:hover:not(:disabled) {
  background: linear-gradient(135deg, #eab308 0%, #f59e0b 55%, #ea580c 100%);
  border-color: transparent;
  color: #fff;
}

.header-nav-links .btn-nav-duel.active,
.header-nav-links .btn-nav-duel.active:hover:not(:disabled) {
  background: linear-gradient(135deg, #f97316 0%, #ef4444 55%, #db2777 100%);
  border-color: transparent;
  color: #fff;
}

.header-nav-links .btn-leaderboard.active,
.header-nav-links .btn-leaderboard.active:hover:not(:disabled) {
  background: linear-gradient(135deg, #6366f1 0%, #22c55e 100%);
  border-color: transparent;
  color: #fff;
}

.header-nav-links .btn-nav-profile.active,
.header-nav-links .btn-nav-profile.active:hover:not(:disabled) {
  background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
  border-color: transparent;
  color: #fff;
}

.header-nav-links .btn-nav-admin.active,
.header-nav-links .btn-nav-admin.active:hover:not(:disabled) {
  background: linear-gradient(135deg, #64748b 0%, #94a3b8 100%);
  border-color: transparent;
  color: #fff;
}

[data-theme="light"] .face-l {
  border-color: #8a96a8;
}

/* Puzzle type selector (legacy list — unused) */
.puzzle-type-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.megaminx-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.face-btn.face-generic {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}

/* Cube type selector (legacy) */
.cube-type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 4px;
}

.cube-type-btn {
  padding: 10px 4px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cube-type-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
}

.cube-type-btn.active {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
}

.cube-type-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Face buttons */
.face-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
}

.face-row {
  display: flex;
  gap: 4px;
}

.face-btn {
  width: 48px;
  height: 48px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  color: #111;
}

.face-btn:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.face-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.face-u { background: var(--face-u); color: #fff; }
.face-d { background: var(--face-d); color: #111; }
.face-f { background: var(--face-f); color: #fff; }
.face-b { background: var(--face-b); color: #111; }
.face-r { background: var(--face-r); color: #111; }
.face-l { background: var(--face-l); color: #333; border-color: #ccc; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  cursor: pointer;
}

.checkbox-label input {
  accent-color: var(--accent);
}

.start-orient {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.start-orient-heading {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 600;
}

.start-orient-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 0;
  cursor: default;
}

.start-orient-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.start-orient-select {
  width: 100%;
  padding: 9px 32px 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.start-orient-select:hover {
  border-color: #3d4f6a;
}

.start-orient-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.start-orient-select option {
  background: var(--bg-panel);
  color: var(--text);
}

.start-orient-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 8px 0 0;
  opacity: 0.85;
}

.start-orient.is-locked,
.start-orient-section.is-locked {
  display: none;
}

.section-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: -4px 0 12px;
  line-height: 1.4;
}

.view-block {
  margin-bottom: 14px;
}

.view-block:last-child {
  margin-bottom: 0;
}

.view-block-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.view-grid {
  display: grid;
  gap: 5px;
  justify-items: center;
}

.view-grid-compact .view-btn {
  width: 38px;
  height: 38px;
  font-size: 0.8rem;
}

.view-row {
  display: flex;
  gap: 5px;
}

.view-btn {
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.view-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

.view-btn.view-b-wide {
  width: 100%;
  max-width: 136px;
  margin-top: 2px;
}

.view-corner-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.view-corner-btn {
  padding: 10px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.view-corner-btn:hover {
  background: #243049;
  border-color: var(--accent);
}

.shortcuts {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.8;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  margin-right: 2px;
}

/* Canvas */
.canvas-wrap {
  position: relative;
  overflow: hidden;
  background: var(--canvas-bg);
  min-height: 400px;
}

.error-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
  text-align: center;
  color: #c41e3a;
  font-size: 0.95rem;
  line-height: 1.6;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.canvas-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--canvas-hint-bg);
  border: 1px solid var(--canvas-hint-border);
  padding: 6px 14px;
  border-radius: 20px;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

@media (max-width: 768px) {
  .canvas-hint {
    display: none;
  }
}

.cube-arrows {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 3;
}

.cube-arrows .arrow-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.arrow-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.85);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.arrow-btn:hover {
  background: rgba(26, 34, 52, 0.95);
}

.cube-orientation {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  background: rgba(17, 24, 39, 0.88);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  backdrop-filter: blur(8px);
  min-width: 148px;
}

.orient-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-align: center;
}

.orient-grid {
  display: grid;
  gap: 6px;
  justify-items: center;
}

.orient-row {
  display: flex;
  gap: 6px;
}

.orient-cell {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.orient-back {
  margin-top: 8px;
  font-size: 0.72rem;
  text-align: center;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.orient-face-u { background: var(--face-u); color: #fff; }
.orient-face-d { background: var(--face-d); color: #fff; }
.orient-face-f { background: var(--face-f); color: #fff; }
.orient-face-b { background: var(--face-b); color: #fff; }
.orient-face-r { background: var(--face-r); color: #1a1a1a; }
.orient-face-l { background: var(--face-l); color: #1a1a1a; }

.orient-back.orient-face-u,
.orient-back.orient-face-d,
.orient-back.orient-face-f,
.orient-back.orient-face-b {
  color: #fff;
}

.orient-back.orient-face-r,
.orient-back.orient-face-l {
  color: #1a1a1a;
}

/* Win overlay */
.win-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 23, 0.75);
  backdrop-filter: blur(6px);
  z-index: 10;
}

.win-overlay[hidden] {
  display: none;
}

.win-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.win-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.win-card h2 {
  font-size: 1.75rem;
  margin-bottom: 8px;
}

.win-card p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.win-card strong {
  color: var(--success);
  font-family: 'JetBrains Mono', monospace;
}

/* Move history */
.move-history {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-muted);
  max-height: 200px;
  overflow-y: auto;
  word-break: break-all;
}

.move-history .move {
  display: inline-block;
  padding: 2px 6px;
  margin: 2px;
  background: var(--bg-card);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.move-history .move.current {
  border-color: var(--accent);
  color: var(--accent);
}

.empty-hint {
  font-style: italic;
  font-size: 0.85rem;
}

/* Settings sliders */
.slider-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.slider-label input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

/* Color legend */
.color-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.color-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

.swatch-u { background: var(--face-u); }
.swatch-d { background: var(--face-d); }
.swatch-f { background: var(--face-f); }
.swatch-b { background: var(--face-b); }
.swatch-r { background: var(--face-r); }
.swatch-l { background: var(--face-l); }

.color-note {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Responsive */
@media (max-width: 1024px) {
  .panel-left,
  .panel-right {
    width: 240px;
    max-height: none;
  }
}

.header-toggle-btn {
  display: none;
  flex-shrink: 0;
}

.header-panel-quick {
  display: none;
  flex-shrink: 0;
  align-items: stretch;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.header-panel-quick-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.header-panel-quick-btn:hover {
  background: #243049;
  border-color: #3d4f6a;
}

.header-panel-quick-btn.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.45);
  color: var(--accent);
}

[data-theme="light"] .header-panel-quick-btn:hover {
  background: #e2e8f0;
  border-color: #b8c4d4;
}

.header-panel-quick-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.header-panel-quick-label {
  line-height: 1.2;
}

@media (max-width: 768px) {
  .header-panel-quick {
    display: flex;
  }

  .header-toggle-btn {
    display: inline-flex;
    width: 40px;
    height: 40px;
    font-size: 1.05rem;
    grid-area: toggle;
  }

  .header {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "logo toggle"
      "stats stats"
      "menu menu";
    gap: 10px;
    padding: 10px 12px;
  }

  .header:not(:has(.stats)) {
    grid-template-areas:
      "logo toggle"
      "menu menu";
  }

  .logo {
    justify-self: stretch;
  }

  .header-center {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    width: 100%;
  }

  .header-tools .panel-toggle--desktop {
    display: none !important;
  }

  .stats {
    justify-content: center;
    justify-self: stretch;
    width: 100%;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  .header-nav-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .btn-nav-practice,
  .btn-nav-competition,
  .btn-leaderboard,
  .btn-nav-admin,
  .btn-nav-profile,
  .btn-nav-duel {
    width: 100%;
    justify-content: flex-start;
    padding: 12px 14px;
    font-size: 0.88rem;
    gap: 10px;
    min-height: 48px;
  }

  .nav-icon {
    width: 18px;
    height: 18px;
  }

  .nav-icon svg {
    width: 18px;
    height: 18px;
  }

  .header-tools {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    padding: 4px 0;
  }

  .header-tools .icon-btn,
  .header-tools .lang-btn {
    width: 100%;
    height: 44px;
    min-height: 44px;
    font-size: 1.05rem;
  }

  .header-tools .lang-switcher {
    min-width: 0;
  }

  .header-account {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
  }

  .header-account .auth-guest,
  .header-account .auth-user {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }

  .header-account .auth-guest .btn,
  .header-account .auth-user .btn {
    width: 100%;
    min-height: 42px;
    font-size: 0.88rem;
  }

  .header-account .auth-user {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .header-account-info {
    flex: 1;
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .header-account .auth-username {
    margin-right: 0;
    font-size: 0.95rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-account .user-rank-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
  }

  .header-account .auth-user .btn {
    width: auto;
    flex-shrink: 0;
  }

  #app.header-collapsed .header {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "logo stats toggle";
    gap: 10px;
    padding: 8px 12px;
  }

  #app.header-collapsed .header:not(:has(.stats)) {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "logo toggle";
  }

  #app.header-collapsed .header-center {
    display: none !important;
  }

  #app.header-collapsed .stats {
    padding: 0;
    border: none;
    justify-content: flex-end;
    gap: 16px;
  }

  #app.header-collapsed .logo h1 {
    font-size: 1.05rem;
  }

  .main.mobile-panels .panel-left,
  .main.mobile-panels .panel-right {
    width: 100%;
    max-width: 100%;
    z-index: 30;
    box-shadow: var(--shadow);
  }

  .main.mobile-panels.left-collapsed .panel-left,
  .main.mobile-panels.right-collapsed .panel-right {
    transform: translateX(-100%);
    pointer-events: none;
  }

  .main.mobile-panels.right-collapsed .panel-right {
    transform: translateX(100%);
  }

  .main.mobile-panels:not(.left-collapsed) .panel-left,
  .main.mobile-panels:not(.right-collapsed) .panel-right {
    transform: translateX(0);
    pointer-events: auto;
  }

  .main.mobile-panels.panel-overlay-open::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 25;
    background: rgba(0, 0, 0, 0.55);
    pointer-events: auto;
  }

  .main--subpage .page-main-area {
    -webkit-overflow-scrolling: touch;
  }

  .subpage-shell,
  .subpage-shell--wide {
    max-width: 100%;
  }
}

.duel-tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0 16px;
  flex-wrap: wrap;
}

/* —— Düello lobisi —— */
.duel-lobby {
  position: relative;
}

.duel-lobby-hero {
  position: relative;
  text-align: center;
  margin-bottom: 28px;
}

.duel-lobby-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fdba74;
  background: rgba(249, 115, 22, 0.12);
  border: 1px solid rgba(249, 115, 22, 0.25);
  margin-bottom: 12px;
}

.duel-lobby-hero-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 8px;
  background: linear-gradient(135deg, #fff 0%, #fed7aa 50%, #f472b6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

[data-theme="light"] .duel-lobby-hero-title {
  background: linear-gradient(135deg, #1e293b 0%, #c2410c 50%, #be185d 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.duel-lobby-hero-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.duel-lobby-stat {
  text-align: center;
  min-width: 72px;
}

.duel-lobby-stat-value {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.duel-lobby-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.duel-tips-list {
  margin: 0;
  padding: 0 0 0 1.1rem;
  list-style: disc;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.duel-recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.duel-recent-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.duel-recent-result {
  font-size: 0.78rem;
  font-weight: 600;
}

.duel-recent-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duel-recent-more {
  margin-top: 10px;
}

.duel-mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
  position: relative;
}

.duel-mode-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  overflow: hidden;
  color: inherit;
  font: inherit;
}

.duel-mode-card:hover {
  border-color: rgba(249, 115, 22, 0.45);
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.duel-mode-card.active {
  border-color: #f97316;
  box-shadow: 0 0 0 1px #f97316, 0 12px 36px rgba(249, 115, 22, 0.2);
}

.duel-mode-card-visual {
  position: relative;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.duel-mode-card-visual::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.9;
}

.duel-mode-card-visual--online::before {
  background: linear-gradient(145deg, #0ea5e9 0%, #6366f1 50%, #1e1b4b 100%);
}

.duel-mode-card-visual--friend::before {
  background: linear-gradient(145deg, #22c55e 0%, #14b8a6 50%, #134e4a 100%);
}

.duel-mode-card-visual--bot::before {
  background: linear-gradient(145deg, #a855f7 0%, #ec4899 50%, #4c1d95 100%);
}

.duel-mode-icon-wrap {
  position: relative;
  z-index: 1;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 1.75rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.duel-mode-card-body {
  padding: 14px 16px 16px;
}

.duel-mode-card-title {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
}

.duel-mode-card-desc {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.duel-mode-content {
  position: relative;
  animation: duelContentIn 0.35s ease;
}

@keyframes duelContentIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.duel-mode-content-head {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.duel-mode-content-title {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.duel-mode-content-title-icon {
  font-size: 1.25rem;
}

.duel-mode-content-desc {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

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

.duel-panel-card .form-field {
  margin-bottom: 4px;
}

.duel-panel-card .btn-primary {
  margin-top: 8px;
}

.duel-panel-card .btn-primary {
  background: linear-gradient(135deg, #f97316 0%, #ef4444 100%);
  border-color: transparent;
  font-weight: 600;
}

.duel-panel-card .btn-primary:hover {
  filter: brightness(1.06);
}

.duel-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.duel-panel[hidden] {
  display: none !important;
}

.duel-overlay {
  position: absolute;
  z-index: 5;
  pointer-events: auto;
}

.duel-hud {
  top: 12px;
  left: calc(var(--panel-w) + 12px);
  max-width: min(360px, calc(100% - 2 * var(--panel-w) - 48px));
  background: var(--canvas-hint-bg);
  border: 1px solid var(--canvas-hint-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  backdrop-filter: blur(8px);
}

.main.left-collapsed .duel-hud {
  left: 12px;
}

.main.right-collapsed .duel-opponent-corner {
  right: 12px;
}

.duel-hud[hidden],
.duel-opponent-corner[hidden] {
  display: none !important;
}

.duel-hud-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.duel-hud-mode {
  font-weight: 700;
  color: var(--accent);
}

.duel-hud-vs {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.duel-hud-opponent {
  font-weight: 600;
  flex: 1;
}

.duel-opponent-corner {
  top: 12px;
  right: calc(var(--panel-w) + 12px);
  width: 196px;
  padding: 10px 12px;
  background: var(--canvas-hint-bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  font-size: 0.78rem;
  box-shadow: var(--shadow);
}

.duel-opp-canvas-wrap {
  width: 100%;
  aspect-ratio: 1;
  margin: 6px 0 8px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--canvas-bg);
  border: 1px solid var(--border);
}

.duel-opp-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.duel-opp-canvas-wrap--hidden {
  display: none;
}

.duel-opp-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 4px;
}

.duel-opp-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.duel-opp-icon {
  font-size: 1rem;
  line-height: 1;
}

.duel-opp-name {
  font-weight: 600;
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duel-opp-stats {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.duel-opp-sep {
  opacity: 0.5;
}

.duel-opp-bar-track {
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.duel-opp-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #6366f1, #22c55e);
  transition: width 0.15s linear;
}

.duel-opp-status {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.duel-result-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 23, 0.78);
  backdrop-filter: blur(6px);
}

.duel-result-overlay[hidden] {
  display: none !important;
}

.duel-result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  text-align: center;
  max-width: 360px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow);
}

.duel-result-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.duel-result-card h2 {
  margin-bottom: 8px;
  color: #fca5a5;
}

.duel-result-card p {
  color: var(--text-muted);
  line-height: 1.5;
}

.duel-result-detail {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  margin-top: 8px;
  color: var(--text);
}

.duel-result-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: center;
}

.duel-result-actions .btn {
  min-width: 110px;
}

[data-theme="light"] .duel-result-card h2 {
  color: #b91c1c;
}

.duel-hero-hint {
  margin-top: 4px;
  text-align: center;
}

.duel-invite-banner--page {
  position: static;
  transform: none;
  margin: 0 0 16px;
  border-radius: var(--radius);
  width: 100%;
}

@media (max-width: 720px) {
  .duel-mode-grid {
    grid-template-columns: 1fr;
  }

  .duel-mode-card-visual {
    height: 80px;
  }

  .duel-lobby-hero-title {
    font-size: 1.45rem;
  }
}

.duel-hud-status {
  margin-top: 8px;
  font-size: 0.88rem;
}

.duel-status-ok { color: #86efac; }
.duel-status-err { color: #fca5a5; }

.duel-bot-bar {
  margin-top: 8px;
}

.duel-bot-bar-track {
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  overflow: hidden;
}

.duel-bot-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #6366f1, #ef4444);
  transition: width 0.1s linear;
}

.duel-bot-timer {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.duel-invite-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  background: var(--canvas-hint-bg);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
}

.duel-invite-banner[hidden] {
  display: none !important;
}

.modal-card--wide {
  max-width: 420px;
}

.profile-duel-cube-field {
  margin-bottom: 12px;
}

.friend-list {
  list-style: none;
  margin: 8px 0;
  padding: 0;
}

.profile-friends-scroll {
  max-height: min(42vh, 400px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 4px;
  padding-right: 2px;
}

.friend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.friend-actions {
  display: flex;
  gap: 6px;
}

.friend-item-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.friend-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.friend-status.online {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}

.friend-status.offline {
  background: #64748b;
}

.friend-duel-badge {
  font-size: 0.65rem;
  color: var(--accent);
  font-weight: 600;
}

.duel-queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
  max-height: 240px;
  overflow-y: auto;
}

.queue-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.queue-player-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.queue-player-name {
  font-weight: 600;
  font-size: 0.88rem;
}

.queue-player-cube {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.queue-empty {
  margin: 8px 0;
  text-align: center;
}

.notify-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 23, 0.78);
  backdrop-filter: blur(6px);
  padding: 16px;
}

.notify-overlay[hidden] {
  display: none !important;
}

.notify-card {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 24px 28px;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow);
  text-align: center;
}

.notify-badge {
  display: inline-block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 8px;
}

.notify-badge--friend {
  color: #22c55e;
}

.notify-card h3 {
  margin-bottom: 8px;
}

.notify-card p {
  color: var(--text-muted);
  line-height: 1.5;
}

.notify-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}

.notify-actions .btn {
  min-width: 100px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.friend-request-form input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.form-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.field-input,
.field-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-select {
  padding-right: 32px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.field-input:hover,
.field-select:hover,
.start-orient-select:hover {
  border-color: #3d4f6a;
}

.field-input:focus,
.field-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.field-input::placeholder {
  color: var(--text-muted);
  opacity: 0.75;
}

.field-select option,
.start-orient-select option {
  background: var(--bg-panel);
  color: var(--text);
}

.profile-friend-msg {
  margin-top: 8px;
  font-size: 0.85rem;
}

.duel-queue-label {
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
}

[data-theme="light"] .duel-status-ok { color: #15803d; }
[data-theme="light"] .duel-status-err { color: #b91c1c; }

[data-theme="light"] .field-input:hover,
[data-theme="light"] .field-select:hover,
[data-theme="light"] .start-orient-select:hover {
  border-color: #9aa8bc;
}

[data-theme="light"] .field-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235c6b82' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
}

[data-theme="light"] .start-orient-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235c6b82' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
}

[data-theme="light"] .rank-table tbody tr.rank-gold td {
  background: rgba(255, 193, 7, 0.14);
}

@media (max-width: 900px) {
  .duel-hud {
    left: 12px;
    max-width: calc(100% - 200px);
  }

  .duel-opponent-corner {
    right: 12px;
    width: 156px;
  }
}

@media (max-width: 600px) {
  .stats {
    gap: 20px;
  }

  .stat-value {
    font-size: 1.2rem;
  }

  .header-nav-links {
    grid-template-columns: 1fr;
  }

  .face-grid {
    gap: 4px;
  }

  .face-btn {
    min-width: 2.2rem;
    padding: 8px 6px;
    font-size: 0.85rem;
  }
}

.lb-table td.mono {
  font-family: 'JetBrains Mono', monospace;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.admin-form {
  display: inline;
  margin: 0;
}

.admin-muted {
  color: var(--text-muted);
}

.icon-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Auth modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay[hidden] { display: none; }

.modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.modal-card h2 {
  font-size: 1.2rem;
  margin-bottom: 16px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.auth-form input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-error {
  color: #f87171;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.auth-error[hidden],
.auth-guest[hidden],
.auth-user[hidden],
#auth-loading[hidden] {
  display: none !important;
}

.win-score-msg {
  font-size: 0.9rem;
  color: var(--success);
  margin: 8px 0 12px;
}

/* ─── Light theme ─── */
[data-theme="light"] {
  --bg-deep: #eef2f7;
  --bg-panel: #ffffff;
  --bg-card: #f4f6fa;
  --border: #c5ced9;
  --text: #1a2234;
  --text-muted: #5c6b82;
  --canvas-bg: #e8ecf2;
  --platform-color: #c8d0dc;
  --canvas-hint-bg: rgba(255, 255, 255, 0.9);
  --canvas-hint-border: rgba(180, 190, 204, 0.85);
  color-scheme: light;
}

[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99, 102, 241, 0.08), transparent);
}

[data-theme="light"] .view-btn {
  border-color: #9aa8bc;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .face-l,
[data-theme="light"] .view-btn.face-l {
  color: #333;
  border-color: #8a96a8;
}

/* ─── Leaderboard & admin pages ─── */
.page-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.page-header h1 {
  flex: 1;
  font-size: 1.35rem;
}

.page-back {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.page-back:hover { color: var(--accent); }

.lb-filters {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

.lb-filter-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.lb-cube-grid {
  max-width: 280px;
}

.lb-period-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lb-tab,
a.lb-tab {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-block;
}

.lb-tab:hover { border-color: var(--accent); color: var(--text); }
.lb-tab.active {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent);
  font-weight: 600;
}

.lb-table-wrap, .admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.lb-table th,
.lb-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.lb-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-card);
}

.lb-table tbody tr:last-child td { border-bottom: none; }
.lb-table tbody tr:hover { background: rgba(99, 102, 241, 0.05); }

.lb-rank { font-weight: 700; color: var(--text-muted); width: 48px; }
.lb-time { font-family: 'JetBrains Mono', monospace; font-weight: 600; }
.lb-empty { text-align: center; color: var(--text-muted); padding: 32px !important; }
.lb-error { color: #f87171; }
.lb-top-1 .lb-rank { color: #ffd500; }
.lb-top-2 .lb-rank { color: #c0c0c0; }
.lb-top-3 .lb-rank { color: #cd7f32; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-admin { background: rgba(99, 102, 241, 0.2); color: var(--accent); }
.badge-user { background: var(--bg-card); color: var(--text-muted); }
.badge-banned { background: rgba(185, 28, 28, 0.2); color: #f87171; }
.badge-ok { background: rgba(34, 197, 94, 0.15); color: var(--success); }

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.admin-status {
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ─── Game modes & guest lock ─── */
.game-mode-section {
  padding-bottom: 0px;
}

.game-mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.game-mode-badge--practice {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.game-mode-badge--competition {
  background: rgba(234, 179, 8, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(234, 179, 8, 0.35);
}

.guest-lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 14, 23, 0.22);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

[data-theme="light"] .guest-lock-overlay {
  background: rgba(255, 255, 255, 0.28);
}

.guest-lock-overlay[hidden] {
  display: none !important;
}

body.guest-locked #app {
  pointer-events: none;
}

body.guest-locked #app .header {
  pointer-events: auto;
  position: relative;
  z-index: 96;
}

.guest-lock-card {
  width: 100%;
  max-width: 420px;
  background: rgba(20, 26, 38, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

[data-theme="light"] .guest-lock-card {
  background: rgba(255, 255, 255, 0.94);
}

.guest-lock-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.guest-lock-card h2 {
  margin: 0 0 10px;
  font-size: 1.35rem;
}

.guest-lock-card p {
  margin: 0 0 20px;
  color: var(--text-muted);
  line-height: 1.55;
  font-size: 0.95rem;
}

.guest-lock-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--bg-card);
  border-color: var(--border);
}

.logo-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}

.lang-switcher {
  position: relative;
}

.lang-btn {
  min-width: 36px;
  padding: 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 140px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 120;
}

.lang-menu[hidden] {
  display: none !important;
}

.lang-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
}

.lang-menu-item:hover,
.lang-menu-item.active {
  background: var(--bg-card);
}

.lang-menu-code {
  font-weight: 700;
  min-width: 24px;
}

.lang-menu-name {
  color: var(--text-muted);
}

.admin-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}

.admin-tab {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
}

.admin-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.admin-settings-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 8px;
}

.admin-settings-form {
  padding-bottom: 8px;
}

.admin-settings-form textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.admin-check-label {
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
}

.maintenance-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.maintenance-wrap {
  width: 100%;
  max-width: 480px;
}

.maintenance-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  text-align: center;
  box-shadow: var(--shadow);
}

.maintenance-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.maintenance-card h1 {
  margin: 0 0 12px;
  font-size: 1.4rem;
}

.maintenance-card p {
  color: var(--text-muted);
  line-height: 1.55;
}

.maintenance-hint {
  margin-top: 16px;
  font-size: 0.85rem;
}

.site-footer {
  padding: 10px 16px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  flex-shrink: 0;
}

.site-footer-text {
  margin-bottom: 8px;
}

.site-social-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.site-social-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.site-social-links a:hover {
  text-decoration: underline;
}

.admin-locale-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

.admin-translations-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.admin-translations-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.admin-translations-toolbar .field-input,
.admin-translations-toolbar .field-select {
  width: 100%;
}

.admin-translations-add {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
}

.admin-translations-scroll {
  max-height: calc(100vh - 280px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.admin-translation-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  align-items: start;
}

.admin-translation-row:last-child {
  border-bottom: none;
}

.admin-translation-key {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  word-break: break-all;
}

.admin-translation-row textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  resize: vertical;
}

@media (max-width: 768px) {
  .admin-translation-row {
    grid-template-columns: 1fr;
  }

  .admin-translations-toolbar {
    grid-template-columns: 1fr;
  }

  .main--subpage .canvas-wrap {
    padding-left: 0;
    padding-right: 0;
  }
}
