/* ==========================================================================
   CD Digital Chess — Three-Column Layout & Modern App Navigation Styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Application Shell & Desktop 3-Column Layout Structure
   -------------------------------------------------------------------------- */

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

.page-shell {
  position: relative;
  height: var(--app-height);
  max-height: var(--app-height);
  padding: 0.6rem 0.75rem 0.6rem 0.6rem;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  gap: 0.85rem;
  box-sizing: border-box;
}

.app-main-content {
  flex: 1 1 auto;
  min-width: 0;
  height: calc(var(--app-height) - 1.2rem);
  max-height: calc(var(--app-height) - 1.2rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: width 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

.workspace-view {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  overflow: hidden;
}

.workspace-view .workspace {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  align-items: stretch;
  transition:
    max-width 240ms cubic-bezier(0.16, 1, 0.3, 1),
    column-gap 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

.workspace-view .board-pane {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.workspace-view .board-stage-card {
  position: static;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 0.4rem;
}

.workspace-view .control-pane {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.workspace-view .control-pane-scroll {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding-inline-end: max(0.35rem, 8px);
}

/* --------------------------------------------------------------------------
   2. Desktop Left Navigation Sidebar & Collapsible Icon Rail
   -------------------------------------------------------------------------- */

.app-sidebar {
  width: var(--sidebar-width, 240px);
  min-width: var(--sidebar-width, 240px);
  max-width: var(--sidebar-width, 240px);
  height: calc(var(--app-height) - 1.2rem);
  max-height: calc(var(--app-height) - 1.2rem);
  display: flex;
  flex-direction: column;
  background: var(--panel-strong);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-panel, 14px);
  box-shadow: 0 4px 20px var(--panel-shadow);
  padding: 0.9rem 0.65rem 0.75rem;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 10;
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--text-soft) transparent;
  transition:
    width 240ms cubic-bezier(0.16, 1, 0.3, 1),
    min-width 240ms cubic-bezier(0.16, 1, 0.3, 1),
    max-width 240ms cubic-bezier(0.16, 1, 0.3, 1),
    padding 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar::-webkit-scrollbar {
  width: 5px;
}

.app-sidebar::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: color-mix(in srgb, var(--text-soft) 40%, transparent);
}

/* Sidebar Brand Header */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.25rem 0.35rem 0.75rem;
  border-bottom: 1px solid var(--section-divider-soft);
  margin-bottom: 0.65rem;
  min-height: 38px;
  box-sizing: border-box;
}

.sidebar-brand-main {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  overflow: hidden;
}

.sidebar-brand-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.14));
  flex-shrink: 0;
  transition: transform 180ms ease;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand-top {
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  color: var(--text);
  text-transform: uppercase;
}

.sidebar-brand-bottom {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent-strong);
  text-transform: uppercase;
}

/* Sidebar Collapse Toggle Buttons */
.sidebar-collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--chip-border);
  border-radius: 7px;
  background: var(--chip-bg);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 160ms ease;
}

.sidebar-collapse-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: var(--focus-border);
}

.sidebar-toggle-icon {
  transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-collapse-footer-btn {
  display: none;
}

/* Navigation Groups & Items */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1 1 auto;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.nav-group-label {
  padding: 0.25rem 0.55rem 0.15rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-soft);
  white-space: nowrap;
}

.sidebar-nav-item,
.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 2.35rem;
  padding: 0.42rem 0.65rem;
  border: 1px solid transparent;
  border-radius: var(--radius-card, 8px);
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    transform 120ms ease;
}

.sidebar-nav-item:hover,
.drawer-nav-item:hover {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent-strong);
}

.sidebar-nav-item:active,
.drawer-nav-item:active {
  transform: scale(0.985);
}

.sidebar-nav-item:focus-visible,
.drawer-nav-item:focus-visible {
  outline: none;
  border-color: var(--focus-border);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.sidebar-nav-item.is-active,
.drawer-nav-item.is-active {
  background: color-mix(in srgb, var(--accent) 14%, var(--panel-strong));
  border-color: color-mix(in srgb, var(--accent) 45%, var(--card-border));
  color: var(--accent-strong);
  font-weight: 750;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 18%, transparent);
}

.nav-icon {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  stroke: currentColor;
  opacity: 0.88;
}

.sidebar-nav-item.is-active .nav-icon,
.drawer-nav-item.is-active .nav-icon {
  stroke: var(--accent-strong);
  opacity: 1;
}

.nav-label {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Footer & Theme Toggle */
.sidebar-footer {
  margin-top: auto;
  padding-top: 0.65rem;
  border-top: 1px solid var(--section-divider-soft);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sidebar-theme-toggle,
.drawer-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 2.3rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--button-tonal-border);
  border-radius: var(--radius-card, 8px);
  background: var(--button-tonal-bg);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
  transition: all 150ms ease;
}

.sidebar-theme-toggle:hover,
.drawer-theme-toggle:hover {
  background: color-mix(in srgb, var(--button-tonal-bg) 85%, var(--accent-soft));
  color: var(--text);
  border-color: var(--focus-border);
}

.theme-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-strong);
  margin-right: 0.4rem;
}

.theme-toggle-label {
  flex: 1 1 auto;
  text-align: left;
}

/* --------------------------------------------------------------------------
   2B. Minimized / Collapsed Sidebar (Slim Icon Rail)
   -------------------------------------------------------------------------- */

.page-shell.is-sidebar-collapsed .app-sidebar,
.app-sidebar.is-collapsed {
  --sidebar-width: 60px;
  padding: 0.75rem 0.35rem;
  align-items: center;
}

.page-shell.is-sidebar-collapsed .sidebar-brand-text,
.app-sidebar.is-collapsed .sidebar-brand-text,
.page-shell.is-sidebar-collapsed .nav-group-label,
.app-sidebar.is-collapsed .nav-group-label,
.page-shell.is-sidebar-collapsed .nav-label,
.app-sidebar.is-collapsed .nav-label,
.page-shell.is-sidebar-collapsed .theme-toggle-label,
.app-sidebar.is-collapsed .theme-toggle-label,
.page-shell.is-sidebar-collapsed .theme-toggle-switch,
.app-sidebar.is-collapsed .theme-toggle-switch {
  display: none !important;
}

.page-shell.is-sidebar-collapsed .sidebar-brand,
.app-sidebar.is-collapsed .sidebar-brand {
  justify-content: center;
  padding: 0.15rem 0 0.55rem;
  width: 100%;
  margin-bottom: 0.5rem;
}

.page-shell.is-sidebar-collapsed .sidebar-brand-main,
.app-sidebar.is-collapsed .sidebar-brand-main {
  justify-content: center;
}

.page-shell.is-sidebar-collapsed #sidebarCollapseToggle,
.app-sidebar.is-collapsed #sidebarCollapseToggle {
  display: none;
}

.page-shell.is-sidebar-collapsed .sidebar-collapse-footer-btn,
.app-sidebar.is-collapsed .sidebar-collapse-footer-btn {
  display: inline-flex;
  width: 38px;
  height: 34px;
  margin: 0 auto;
}

.page-shell.is-sidebar-collapsed .sidebar-collapse-btn .sidebar-toggle-icon,
.app-sidebar.is-collapsed .sidebar-collapse-btn .sidebar-toggle-icon {
  transform: rotate(180deg);
}

.page-shell.is-sidebar-collapsed .sidebar-nav,
.app-sidebar.is-collapsed .sidebar-nav {
  width: 100%;
  align-items: center;
  gap: 0.45rem;
}

.page-shell.is-sidebar-collapsed .nav-group,
.app-sidebar.is-collapsed .nav-group {
  width: 100%;
  align-items: center;
  gap: 0.25rem;
}

.page-shell.is-sidebar-collapsed .sidebar-nav-item,
.app-sidebar.is-collapsed .sidebar-nav-item {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  justify-content: center;
  border-radius: 9px;
}

.page-shell.is-sidebar-collapsed .sidebar-footer,
.app-sidebar.is-collapsed .sidebar-footer {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding-top: 0.5rem;
}

.page-shell.is-sidebar-collapsed .sidebar-theme-toggle,
.app-sidebar.is-collapsed .sidebar-theme-toggle {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  justify-content: center;
  border-radius: 9px;
}

.page-shell.is-sidebar-collapsed .theme-toggle-icon,
.app-sidebar.is-collapsed .theme-toggle-icon {
  margin-right: 0;
}

/* --------------------------------------------------------------------------
   3. Mobile Top App Bar & Mobile Drawer
   -------------------------------------------------------------------------- */

.mobile-app-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 0.85rem;
  background: var(--panel-strong);
  border-bottom: 1px solid var(--card-border);
  box-shadow: 0 2px 10px var(--panel-shadow);
  z-index: 100;
  position: sticky;
  top: 0;
}

.mobile-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--chip-border);
  border-radius: 8px;
  background: var(--chip-bg);
  color: var(--text);
  cursor: pointer;
}

.mobile-menu-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.lesson-menu-toggle-btn,
.header-fullscreen-button {
  display: none !important;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mobile-brand-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.mobile-brand-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text);
}

.mobile-app-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.mobile-screen-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.03em;
}

.mobile-theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--chip-border);
  border-radius: 8px;
  background: var(--chip-bg);
  color: var(--text);
  cursor: pointer;
}

/* Mobile Drawer */
.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 16, 20, 0.58);
  backdrop-filter: blur(3px);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.mobile-drawer-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(300px, 84vw);
  background: var(--panel-strong);
  border-right: 1px solid var(--card-border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
  padding: 1rem 0.85rem;
  box-sizing: border-box;
  overflow-y: auto;
}

.mobile-drawer.is-open {
  transform: translateX(0);
}

.mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--section-divider-soft);
  margin-bottom: 0.85rem;
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.drawer-brand-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.drawer-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.drawer-brand-top {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text);
}

.drawer-brand-bottom {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent-strong);
}

.mobile-drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--chip-border);
  border-radius: 8px;
  background: var(--chip-bg);
  color: var(--text-muted);
  cursor: pointer;
}

.mobile-drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  flex: 1 1 auto;
}

.drawer-nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.drawer-group-label {
  padding: 0.2rem 0.5rem 0.1rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.drawer-footer {
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px solid var(--section-divider-soft);
}

/* --------------------------------------------------------------------------
   4. Right Workspace Compact Header
   -------------------------------------------------------------------------- */

.workspace-intro {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  padding: 0.65rem 0.85rem 0.6rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-panel, 12px);
  background: var(--header-bg);
  box-shadow: 0 4px 14px var(--panel-shadow);
  box-sizing: border-box;
}

.workspace-intro-kicker {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.15;
  text-transform: uppercase;
}

.workspace-intro-title {
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 1.4vw, 1.32rem);
  font-weight: 750;
  line-height: 1.2;
}

.workspace-intro-description {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.4;
  max-width: 44rem;
}

/* Legacy .site-intro alias for backward compatibility */
.site-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 0.4rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-panel, 12px);
  background: var(--header-bg);
  box-shadow: 0 4px 14px var(--panel-shadow);
}

.site-intro-copy {
  min-width: 0;
}

.site-intro-kicker {
  margin: 0 0 0.1rem;
  color: var(--accent-strong);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.site-intro-title {
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 1.4vw, 1.32rem);
  line-height: 1.2;
}

.site-intro-description {
  margin: 0.18rem 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.site-intro-actions {
  display: none;
}

/* --------------------------------------------------------------------------
   5. Focus Mode & Embed Visibility Rules
   -------------------------------------------------------------------------- */

html[data-embed="1"] .app-sidebar,
html[data-embed="1"] .mobile-app-bar,
html[data-embed="1"] .workspace-intro,
html[data-board-only="1"] .app-sidebar,
html[data-board-only="1"] .mobile-app-bar,
html[data-board-only="1"] .workspace-intro,
html[data-board-only="1"] .captured-row,
body.focus-mode .app-sidebar,
body.is-focus-mode .app-sidebar,
body.focus-mode-active .app-sidebar,
body.focus-mode .mobile-app-bar,
body.is-focus-mode .mobile-app-bar,
body.focus-mode .workspace-intro,
body.is-focus-mode .workspace-intro,
body.is-board-only .captured-row,
html[data-board-only="1"]:not([data-board-only-setup-open]) .control-pane,
html[data-board-only="1"]:not([data-board-only-setup-open]) .workspace-view .control-pane,
html[data-board-only="1"]:not([data-board-only-setup-open]) .setup-palette-panel,
html[data-board-only="1"]:not([data-board-only-setup-open]) .piece-palette,
html[data-board-only="1"]:not([data-board-only-setup-open]) .setup-board-section,
html[data-board-only="1"]:not([data-board-only-setup-open]) .workspace-tools,
body.is-board-only:not(.is-board-only-setup-open) .control-pane,
body.is-board-only:not(.is-board-only-setup-open) .workspace-view .control-pane,
body.is-board-only:not(.is-board-only-setup-open) .setup-palette-panel,
body.is-board-only:not(.is-board-only-setup-open) .piece-palette,
body.is-board-only:not(.is-board-only-setup-open) .setup-board-section,
body.is-board-only:not(.is-board-only-setup-open) .workspace-tools {
  display: none !important;
}

body.is-focus-mode .page-shell {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 100% !important;
  min-height: 100% !important;
  padding: clamp(0.35rem, 1.1vw, 0.8rem) !important;
}

body.is-board-only .page-shell {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 100% !important;
  width: 100% !important;
  min-height: 100% !important;
  max-height: 100% !important;
  overflow: hidden !important;
  padding: 0 !important;
}

body.is-focus-mode .app-main-content {
  height: 100% !important;
  height: var(--app-height) !important;
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

body.is-board-only .app-main-content {
  height: 100% !important;
  width: 100% !important;
  max-height: 100% !important;
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

body.is-focus-mode .workspace-view,
body.is-focus-mode .workspace-view .workspace {
  height: 100% !important;
  width: 100% !important;
  display: grid !important;
  place-items: center !important;
}

body.is-board-only:not(.is-board-only-setup-open) .workspace-view,
body.is-board-only:not(.is-board-only-setup-open) .workspace-view .workspace {
  height: 100% !important;
  width: 100% !important;
  max-height: 100% !important;
  max-width: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  gap: 0 !important;
}

body.is-focus-mode .workspace-view .board-pane,
body.is-focus-mode .workspace-view .board-stage-card,
body.is-focus-mode .workspace-view .board-block {
  height: 100% !important;
  width: 100% !important;
  display: grid !important;
  place-items: center !important;
  align-content: center !important;
  justify-content: center !important;
}

body.is-board-only .workspace-view .board-pane,
body.is-board-only .workspace-view .board-stage-card,
body.is-board-only .workspace-view .board-block {
  height: 100% !important;
  width: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* --------------------------------------------------------------------------
   6. Responsive Breakpoints
   -------------------------------------------------------------------------- */

/* Large Desktop (> 1400px) */
@media (min-width: 1401px) {
  .workspace {
    column-gap: 2rem;
  }
}

/* Standard Tablet / Medium Viewport (761px - 1100px) */
@media (max-width: 1100px) {
  html,
  body {
    overflow: auto;
  }

  .page-shell {
    height: auto;
    min-height: var(--app-height);
    overflow: visible;
    flex-direction: column;
    padding: 0.55rem;
    gap: 0.55rem;
  }

  .app-sidebar {
    display: none;
  }

  .mobile-app-bar {
    display: flex;
  }

  .app-main-content {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .workspace-view {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .workspace-view .workspace {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .workspace-view .board-pane {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .workspace-view .control-pane {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .workspace-view .control-pane-scroll {
    height: auto;
    max-height: none;
    overflow: visible;
    padding-inline-end: 0;
  }

  .workspace {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  .workspace-intro {
    padding: 0.55rem 0.75rem;
  }
}

/* Mobile & Small Screen (<= 760px) */
@media (max-width: 760px) {
  .page-shell {
    padding: 0.4rem;
    gap: 0.4rem;
  }

  .tab-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .tab-nav::-webkit-scrollbar {
    display: none;
  }

  .tab-chip {
    flex-shrink: 0;
  }
}

/* Unified mobile & tablet portrait layout (all portrait viewports and screens <= 768px):
   Forces single-column vertical flow with full-page scrollability. */
@media (orientation: portrait), (max-width: 768px) {
  html,
  body {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100% !important;
    -webkit-overflow-scrolling: touch;
  }

  .page-shell {
    height: auto !important;
    min-height: var(--app-height) !important;
    max-height: none !important;
    overflow: visible !important;
    flex-direction: column !important;
    padding: 0.4rem 0.5rem 1.5rem !important;
    gap: 0.4rem !important;
  }

  .app-sidebar {
    display: none !important;
  }

  .mobile-app-bar {
    display: flex !important;
  }

  .app-main-content {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    flex: 1 1 auto !important;
  }

  .workspace-view {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .workspace-view .workspace,
  .workspace {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
    max-width: 100% !important;
    gap: 0.5rem !important;
  }

  .workspace-intro {
    display: none !important;
  }

  .workspace-view .control-pane,
  .workspace-view .control-pane-scroll,
  .control-pane,
  .control-pane-scroll {
    display: contents !important;
  }

  .board-pane,
  .workspace-view .board-pane {
    order: 2 !important;
    position: relative !important;
    z-index: 1 !important;
    width: 100% !important;
    max-width: min(72vw, 480px) !important;
    margin-inline: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .board-stage-card,
  .workspace-view .board-stage-card,
  .board-block {
    height: auto !important;
    max-height: none !important;
  }

  /* Embedded board-only view keeps a real pane only when setup is open */
  html[data-board-only="1"][data-board-only-setup-open] .workspace-view .control-pane,
  html[data-board-only="1"][data-board-only-setup-open] .control-pane,
  body.is-board-only.is-board-only-setup-open .workspace-view .control-pane,
  body.is-board-only.is-board-only-setup-open .control-pane {
    display: flex !important;
  }
  html[data-board-only="1"]:not([data-board-only-setup-open]) .workspace-view .control-pane,
  html[data-board-only="1"]:not([data-board-only-setup-open]) .control-pane,
  body.is-board-only:not(.is-board-only-setup-open) .workspace-view .control-pane,
  body.is-board-only:not(.is-board-only-setup-open) .control-pane {
    display: none !important;
  }
}

@media (orientation: portrait) and (max-width: 480px) {
  .board-pane,
  .workspace-view .board-pane {
    max-width: 100% !important;
  }
}

/* Tablet & Mobile landscape split view (up to 1280px landscape or short screens):
   Hide top app bar/sidebar, lock outer viewport, 2 independently scrollable columns. */
@media (max-width: 930px) and (orientation: landscape),
       (max-width: 1280px) and (orientation: landscape),
       (orientation: landscape) and (max-height: 600px) {
  html,
  body {
    overflow: hidden !important;
    height: 100% !important;
    height: var(--app-height) !important;
  }

  .page-shell {
    height: 100% !important;
    height: var(--app-height) !important;
    max-height: var(--app-height) !important;
    min-height: 0 !important;
    padding: 0.35rem 0.45rem !important;
    overflow: hidden !important;
    flex-direction: column !important;
    gap: 0 !important;
  }

  .app-sidebar {
    display: none !important;
  }

  .mobile-app-bar {
    display: none !important;
  }

  .lesson-menu-toggle-btn {
    display: inline-flex !important;
  }

  .header-fullscreen-button {
    display: inline-flex !important;
  }

  .lesson-command-row {
    display: flex !important;
    align-items: center !important;
    gap: 0.25rem !important;
    width: 100% !important;
    min-width: 0 !important;
    flex-wrap: nowrap !important;
  }

  .page-shell .control-pane-scroll > .tab-nav,
  .workspace-view .control-pane-scroll > .tab-nav,
  .control-pane-scroll > .tab-nav,
  .tab-nav {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.35rem !important;
    position: sticky !important;
    top: 2.2rem !important;
    z-index: 19 !important;
    background: var(--panel-strong) !important;
    flex-shrink: 0 !important;
    order: 1 !important;
  }

  html:not([data-active-tab="play"]):not([data-active-tab="puzzle"]) .control-pane-scroll > .tab-nav {
    top: 4.15rem !important;
  }

  html[data-active-tab="play"] .control-pane-scroll > .tab-nav,
  html[data-active-tab="puzzle"] .control-pane-scroll > .tab-nav {
    top: 2.2rem !important;
  }

  .control-pane-scroll > .workspace-tools {
    order: 2 !important;
  }

  .lesson-notation,
  .lesson-position-builder-panel {
    order: 3 !important;
  }

  .app-main-content {
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
  }

  .workspace-view {
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
  }

  .workspace-view .workspace,
  .workspace {
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr) !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
    overflow: hidden !important;
    display: grid !important;
  }

  /* Left column: chess board + move navigation + eval bar (independently scrollable) */
  .workspace-view .board-pane,
  .board-pane {
    order: 0 !important;
    margin-inline: 0 !important;
    width: auto !important;
    min-width: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    padding-inline: clamp(0.25rem, 0.8vw, 0.5rem);
    -webkit-overflow-scrolling: touch;
  }

  /* Right column: header, burger menu, tabs, notation, tools (independently scrollable) */
  .page-shell .control-pane,
  .page-shell .workspace-view .control-pane,
  .workspace-view .control-pane,
  .control-pane {
    display: flex !important;
    flex-direction: column !important;
    order: 1 !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    min-width: 0 !important;
    overflow: hidden !important;
    position: static !important;
  }

  .page-shell .control-pane-scroll,
  .page-shell .workspace-view .control-pane-scroll,
  .workspace-view .control-pane-scroll,
  .control-pane-scroll {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    gap: 0.5rem !important;
    padding-inline-end: max(0.35rem, 8px) !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Embedded board-only mode overrides for landscape viewports */
  body.is-board-only,
  html[data-board-only="1"] {
    overflow: hidden !important;
  }

  body.is-board-only .page-shell,
  html[data-board-only="1"] .page-shell {
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 100% !important;
  }

  body.is-board-only:not(.is-board-only-setup-open) .workspace,
  html[data-board-only="1"]:not([data-board-only-setup-open]) .workspace,
  body.is-board-only:not(.is-board-only-setup-open) .workspace-view .workspace,
  html[data-board-only="1"]:not([data-board-only-setup-open]) .workspace-view .workspace {
    grid-template-columns: minmax(0, 1fr) !important;
    place-items: center !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
  }

  body.is-board-only .board-pane,
  html[data-board-only="1"] .board-pane,
  body.is-board-only .board-stage-card,
  html[data-board-only="1"] .board-stage-card,
  body.is-board-only .board-block,
  html[data-board-only="1"] .board-block {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 auto !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  body.is-board-only .board-column,
  html[data-board-only="1"] .board-column {
    margin: auto !important;
    --focus-side-offset: 0px !important;
    width: calc(var(--board-size) + (var(--board-frame-padding, 0.5rem) * 2) + 2px) !important;
  }

  body.is-board-only .board-frame,
  html[data-board-only="1"] .board-frame {
    margin: 0 auto !important;
  }

  body.is-board-only:not(.is-board-only-setup-open) .control-pane,
  html[data-board-only="1"]:not([data-board-only-setup-open]) .control-pane,
  body.is-board-only:not(.is-board-only-setup-open) .workspace-view .control-pane,
  html[data-board-only="1"]:not([data-board-only-setup-open]) .workspace-view .control-pane {
    display: none !important;
  }

  body.is-board-only .tab-nav,
  html[data-board-only="1"] .tab-nav,
  body.is-board-only .control-pane-scroll > .tab-nav,
  html[data-board-only="1"] .control-pane-scroll > .tab-nav,
  body.is-board-only .board-move-nav-slot,
  html[data-board-only="1"] .board-move-nav-slot {
    display: none !important;
  }
}

/* Notation styling preservation */
.notation-tree > .notation-segment > .notation-line .notation-inline-comment {
  margin-right: 0.5rem;
}

.notation-tree > .notation-segment > .notation-line .notation-inline-comment::before {
  content: "(";
  margin-right: 0.08em;
}

.notation-tree > .notation-segment > .notation-line .notation-inline-comment::after {
  content: ")";
  margin-left: 0.08em;
}

.notation-variation {
  width: fit-content;
  max-width: 100%;
  grid-template-columns: auto minmax(0, auto) auto;
  justify-content: start;
  align-items: baseline;
  column-gap: 0;
}

.notation-variation-body {
  min-width: 0;
  margin-left: 0.18rem;
}

.notation-variation-paren {
  align-self: baseline;
}

/* --------------------------------------------------------------------------
   8. Top Players Leaderboards Modal & Table Styles
   -------------------------------------------------------------------------- */

.top-players-modal {
  z-index: 1500;
}

.top-players-dialog {
  width: min(52rem, 95vw);
  max-height: min(92vh, 860px);
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem 0.9rem;
  border-radius: var(--radius-panel, 14px);
  box-sizing: border-box;
  overflow: hidden;
}

.top-players-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--section-divider-soft);
  flex-shrink: 0;
}

.top-players-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.top-players-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  flex-shrink: 0;
}

.top-players-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.top-players-subtitle {
  margin: 0.12rem 0 0;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.top-players-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 0.6rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 70%, var(--text-soft)) color-mix(in srgb, var(--panel) 90%, transparent);
}

.top-players-body::-webkit-scrollbar {
  width: 8px;
}

.top-players-body::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  border-radius: 4px;
}

.top-players-body::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--accent) 70%, var(--text-soft));
  border-radius: 4px;
}

.top-players-body::-webkit-scrollbar-thumb:hover {
  background: var(--accent-strong);
}

/* Category Selection Pills / Tabs */
.top-players-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex-shrink: 0;
}

.top-players-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--chip-border);
  border-radius: 9999px;
  background: var(--chip-bg);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 150ms ease;
}

.top-players-chip:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: var(--focus-border);
}

.top-players-chip.is-active,
.top-players-chip.is-active:hover {
  background: var(--accent-strong);
  color: var(--button-primary-text, #ffffff);
  border-color: var(--accent-strong);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent-strong) 35%, transparent);
}

.chip-flag {
  font-size: 0.95rem;
  line-height: 1;
}

/* Category Header Banner */
.top-players-cat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  background: color-mix(in srgb, var(--accent) 8%, var(--panel-strong));
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card, 8px);
  flex-shrink: 0;
}

.cat-head-info {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.cat-head-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-head-badge {
  display: inline-block;
  padding: 0.12rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.cat-fide-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--accent-strong);
  text-decoration: none;
  padding: 0.15rem 0.4rem;
  border-radius: 5px;
  transition: background-color 140ms ease;
  flex-shrink: 0;
}

.cat-fide-link:hover {
  background: var(--accent-soft);
  text-decoration: underline;
}

/* Table Wrapper */
.top-players-table-wrap {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card, 8px);
  overflow-y: scroll;
  overflow-x: hidden;
  background: var(--panel-strong);
  flex: 1 1 auto;
  max-height: min(480px, calc(86vh - 230px));
  scrollbar-width: thin;
  scrollbar-color: var(--accent-strong) color-mix(in srgb, var(--panel) 85%, transparent);
  scrollbar-gutter: stable;
}

.top-players-table-wrap::-webkit-scrollbar {
  width: 10px;
  display: block;
}

.top-players-table-wrap::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  border-radius: 6px;
}

.top-players-table-wrap::-webkit-scrollbar-thumb {
  background: var(--accent-strong);
  border-radius: 6px;
  border: 2px solid var(--panel-strong);
}

.top-players-table-wrap::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--accent-strong) 80%, #ffffff);
}

.top-players-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
}

.top-players-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.45rem 0.65rem;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel-strong));
  color: var(--text-soft);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--section-divider-soft);
  white-space: nowrap;
}

.top-players-table td {
  padding: 0.28rem 0.65rem;
  border-bottom: 1px solid var(--section-divider-soft);
  color: var(--text);
  vertical-align: middle;
}

.top-player-row:last-child td {
  border-bottom: none;
}

.top-player-row:hover td {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

/* Rank column */
.th-rank,
.td-rank {
  width: 40px;
  text-align: center;
  padding-left: 0.6rem !important;
  padding-right: 0.4rem !important;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.rank-badge.rank-gold {
  background: #fef3c7;
  color: #b45309;
  font-size: 0.95rem;
}

.rank-badge.rank-silver {
  background: #f1f5f9;
  color: #475569;
  font-size: 0.95rem;
}

.rank-badge.rank-bronze {
  background: #ffedd5;
  color: #c2410c;
  font-size: 0.95rem;
}

[data-theme="dark"] .rank-badge.rank-gold {
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
}

[data-theme="dark"] .rank-badge.rank-silver {
  background: rgba(148, 163, 184, 0.22);
  color: #cbd5e1;
}

[data-theme="dark"] .rank-badge.rank-bronze {
  background: rgba(234, 88, 12, 0.22);
  color: #fb923c;
}

/* Player name & Title */
.player-name-cell {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.player-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-title-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.12rem 0.35rem;
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 1;
  border-radius: 4px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.player-title-badge.title-gm {
  background: #fef08a;
  color: #854d0e;
  border: 1px solid #facc15;
}

.player-title-badge.title-wgm {
  background: #fbcfe8;
  color: #9d174d;
  border: 1px solid #f472b6;
}

.player-title-badge.title-im {
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #7dd3fc;
}

.player-title-badge.title-wim {
  background: #f3e8ff;
  color: #6b21a8;
  border: 1px solid #c084fc;
}

.player-title-badge.title-fm,
.player-title-badge.title-wfm,
.player-title-badge.title-cm {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

[data-theme="dark"] .player-title-badge.title-gm {
  background: rgba(234, 179, 8, 0.2);
  color: #fde047;
  border-color: rgba(234, 179, 8, 0.4);
}

[data-theme="dark"] .player-title-badge.title-wgm {
  background: rgba(236, 72, 153, 0.2);
  color: #f472b6;
  border-color: rgba(236, 72, 153, 0.4);
}

[data-theme="dark"] .player-title-badge.title-im {
  background: rgba(14, 165, 233, 0.2);
  color: #38bdf8;
  border-color: rgba(14, 165, 233, 0.4);
}

[data-theme="dark"] .player-title-badge.title-wim {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.4);
}

[data-theme="dark"] .player-title-badge.title-fm,
[data-theme="dark"] .player-title-badge.title-wfm,
[data-theme="dark"] .player-title-badge.title-cm {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.4);
}

/* Country flag & code */
.fed-cell {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.fed-flag {
  font-size: 1rem;
  line-height: 1;
}

.fed-code {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-soft);
}

/* Rating badge */
.rating-badge {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  font-family: var(--font-mono, monospace);
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 5px;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel-strong));
  color: var(--accent-strong);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}

.birth-year {
  font-size: 0.78rem;
  color: var(--text-soft);
}

/* Action button */
.fide-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.45rem;
  border-radius: 5px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--accent-strong);
  background: var(--accent-soft);
  text-decoration: none;
  transition: all 140ms ease;
  white-space: nowrap;
}

.fide-profile-btn:hover {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  transform: translateY(-1px);
}

/* Footer metadata */
.top-players-footer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.4rem;
  font-size: 0.74rem;
  color: var(--text-soft);
  flex-shrink: 0;
}

.top-players-footer-meta strong {
  color: var(--text-muted);
}

.meta-link {
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 600;
}

.meta-link:hover {
  text-decoration: underline;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  /* Hide secondary columns: Country, B-Year, Profile — keep Rank, Player, Rating */
  .th-fed,
  .td-fed,
  .th-year,
  .td-year,
  .th-action,
  .td-action {
    display: none;
  }

  .player-name {
    max-width: none;
    width: 100%;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .player-name-cell {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .top-players-dialog {
    width: 96vw;
    max-height: min(88vh, 860px);
    margin-top: max(0.75rem, env(safe-area-inset-top, 0px));
    padding: 0.85rem 0.85rem 0.75rem;
  }

  .top-players-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .top-players-nav::-webkit-scrollbar {
    display: none;
  }

  .top-players-table th,
  .top-players-table td {
    padding: 0.4rem 0.5rem;
  }

  .rating-badge {
    font-size: 0.78rem;
  }
}

