:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, sans-serif;
  --bg: #0f172a;
  --card: #111827;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #1f2937;
  --input-bg: #0b1220;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-hover: #1d4ed8;
  --hover: #1f2937;
  --table-head: #111827;
  --shadow: 0 1px 3px rgba(0,0,0,0.35);
}

.theme-light {
  color-scheme: light;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2d3d;
  --muted: #475569;
  --border: #d0d7de;
  --input-bg: #ffffff;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-hover: #1d4ed8;
  --hover: #f3f4f6;
  --table-head: #f9fafb;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body.csv-viewer-page {
  background: var(--bg);
}

.csv-viewer-page h1,
.csv-viewer-page h2,
.csv-viewer-page h3 {
  letter-spacing: -0.01em;
}
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.admin-page .container {
  max-width: none;
  width: 100%;
  padding: 24px 24px 32px;
}
.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.header-row > h1,
.header-row > h2 {
  margin: 0;
  padding-right: 52px;
}
.header-row > div:first-child:not(.nav-actions):not(.nav-toggle) {
  padding-right: 52px;
}
.header-row > h1,
.header-row > h2,
.header-row > div:first-child:not(.nav-actions):not(.nav-toggle) {
  flex: 1 1 auto;
}
.header-row > .nav-actions {
  flex-basis: 100%;
  justify-content: flex-start;
  margin-top: 4px;
}
.header-row > .nav-actions > .nav-utility-first {
  margin-left: auto;
}
h1, h2 {
  margin: 0 0 12px;
}

body.analytics-page {
  background: var(--bg);
  color: var(--text);
}

.analytics-page .container {
  max-width: 1200px;
}

.analytics-page h1 {
  font-size: 2rem;
}

.analytics-page .grid {
  display: grid;
  gap: 12px;
}

.analytics-page .grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.analytics-page .stat {
  text-align: center;
  padding: 12px;
  border-radius: 8px;
  background: var(--hover);
  border: 1px solid var(--border);
}

.analytics-page .stat .value {
  font-size: 1.8rem;
  font-weight: 700;
}

.analytics-page .controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.analytics-page .compare-controls {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.analytics-page #compareSessionSelect {
  min-height: 150px;
}

.analytics-page .controls label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.analytics-page select {
  padding-right: 32px;
  background-position: right 10px center;
}

.analytics-page .chart-wrap {
  height: 320px;
}

.analytics-page th {
  background: var(--table-head);
}

.analytics-page tr:hover {
  background: var(--hover);
}

.analytics-page .session-details-wrap {
  overflow-y: auto;
}

.analytics-page .session-details-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}
.card {
  background: var(--card);
  padding: 16px;
  margin-bottom: 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.hidden { display: none !important; }
form .grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.95rem;
  color: var(--text);
}
input {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible,
.btn:focus-visible,
a.btn:focus-visible,
.nav-btn:focus-visible,
.toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}
textarea {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  resize: vertical;
}
select {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat right 10px center;
  font: inherit;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}
button {
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* Shared nav-style buttons (match analytics page) */
.nav-btn,
.toggle-btn {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--accent-strong);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.2;
  font-family: Arial, sans-serif;
}
.nav-btn:hover,
.toggle-btn:hover {
  background: var(--accent-strong);
}
.nav-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--accent-strong);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.nav-toggle::before {
  content: '☰';
  font-size: 1rem;
  line-height: 1;
}
.header-row .inline button { height: 38px; }
.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.app-footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.index-entry-heading {
  align-items: center;
}

.inline-normal {
  gap: 6px;
  font-weight: normal;
}

.entry-page .meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.entry-page .meta-grid > div {
  min-width: 0;
}

.entry-page .meta-grid .value {
  display: block;
}

.entry-page .meta-grid .value input,
.entry-page .meta-grid .value select,
.entry-page .meta-grid .value textarea {
  width: 100%;
  box-sizing: border-box;
}

.entry-page .label {
  font-weight: 600;
  color: var(--muted);
}

.entry-page .value {
  font-size: 1.05rem;
}

.entry-page .media img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.entry-toolbar {
  margin-bottom: 12px;
}

.entry-notes {
  margin-top: 12px;
}

.csv-controls {
  margin-top: 16px;
  padding-top: 4px;
  position: relative;
  z-index: 1;
}

.csv-controls-tight {
  gap: 10px;
  flex-wrap: wrap;
}

.inline-label-compact {
  gap: 6px;
  align-items: center;
}

.csv-badges {
  margin-top: 8px;
}

.csv-meta {
  margin-top: 4px;
}

.csv-table-status {
  margin-top: 8px;
}

.page-card-centered {
  text-align: center;
  padding: 32px;
}

.page-link-home {
  display: inline-block;
  margin-top: 12px;
}

.game-shell {
  margin-top: 24px;
  display: inline-block;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}

.game-canvas {
  background: var(--bg);
  border-radius: 4px;
}

.game-hud {
  margin-top: 8px;
  color: var(--muted);
  display: flex;
  gap: 12px;
  justify-content: center;
  font-size: 0.9rem;
}

.game-help {
  margin-top: 6px;
  color: var(--muted);
}

.return-home-btn {
  margin-top: 16px;
}

.analytics-controls-top,
.analytics-note-top {
  margin-top: 8px;
}

.filter-card {
  padding: 12px 16px;
}
.entry-filter-card {
  padding: 0 0 12px;
}
.entry-filter-card .filter-card-title {
  font-size: 1.3rem;
}
.entry-filter-panel form {
  margin: 0;
}
.filter-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.filter-card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.filter-toggle:hover {
  background: var(--hover);
  border-color: var(--muted);
}
.filter-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.45);
}
.filter-toggle-bars {
  position: relative;
  width: 18px;
  height: 14px;
  display: inline-block;
}
.filter-toggle-bars span {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.22s ease, opacity 0.18s ease, top 0.22s ease;
}
.filter-toggle-bars span:nth-child(1) { top: 0; }
.filter-toggle-bars span:nth-child(2) { top: 6px; }
.filter-toggle-bars span:nth-child(3) { top: 12px; }
.filter-card--open .filter-toggle-bars span:nth-child(1) {
  top: 6px;
  transform: rotate(45deg);
}
.filter-card--open .filter-toggle-bars span:nth-child(2) {
  opacity: 0;
}
.filter-card--open .filter-toggle-bars span:nth-child(3) {
  top: 6px;
  transform: rotate(-45deg);
}
.filter-toggle-label {
  letter-spacing: 0.02em;
}
.filter-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  animation: filterPanelFade 0.22s ease;
}
.filter-panel[hidden] {
  display: none;
}
@keyframes filterPanelFade {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (max-width: 720px) {
  .entry-filter-card .filter-card-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }
}

.admin-status {
  margin-bottom: 0.75rem;
}

.manage-actions {
  margin-top: 12px;
  gap: 10px;
}

.login-page .login-card {
  max-width: 420px;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.login-page .login-card h1 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.8rem;
}

.login-page .login-card p {
  margin: 0 0 1rem;
}

.login-page .login-card label {
  display: block;
  margin: 0.5rem 0 0.25rem;
  font-weight: 600;
}

.login-page .login-card input {
  width: 100%;
  box-sizing: border-box;
}

.login-page .login-card button:not(.password-toggle) {
  width: 100%;
  margin-top: 1rem;
  box-sizing: border-box;
}

.login-page .login-card .secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.login-page .login-card .secondary:hover {
  background: var(--hover);
}

.login-page .error,
.login-page .success {
  margin-top: 0.75rem;
  min-height: 1.2rem;
}

.login-page .helper {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.login-page .login-footer-links {
  text-align: center;
  margin-top: 1rem;
  margin-bottom: 0;
  font-size: 0.8rem;
}

.login-page .login-footer-links a {
  color: var(--muted);
  text-decoration: none;
}

.login-page .login-footer-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.page-privacy-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.8rem;
}

.page-privacy-footer a {
  color: var(--muted);
  text-decoration: none;
}

.page-privacy-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}
th, td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
#form-status {
  margin-left: 10px;
}
.inline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.meta-label {
  font-weight: 600;
  color: var(--muted);
}

.meta-value {
  font-size: 1.05rem;
}

.status-text {
  min-height: 1.2rem;
  color: var(--muted);
}

.status-text.status-error {
  color: #f87171;
}

.status-text.status-success {
  color: #34d399;
}

.status-text.status-warning {
  color: #f59e0b;
}

@media (max-width: 760px) {
  .header-row {
    align-items: flex-start;
    gap: 8px;
    flex-wrap: wrap;
  }
  .header-row .nav-toggle {
    display: inline-flex;
  }
  .header-row .nav-actions {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin-top: 4px;
  }
  .header-row.nav-open .nav-actions {
    display: flex;
  }
  .header-row.nav-open .nav-actions .nav-btn,
  .header-row.nav-open .nav-actions .toggle-btn {
    width: 100%;
    text-align: left;
    justify-content: flex-start;
    padding: 8px 10px;
    font-size: 0.95rem;
    height: auto;
  }
}
@media (max-width: 600px) {
  .nav-btn,
  .toggle-btn {
    width: 100%;
    text-align: center;
    font-size: 1rem;
    line-height: 1.2;
    font-family: Arial, sans-serif;
  }
}
.info-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid var(--accent-hover);
  cursor: default;
  flex-shrink: 0;
}
.info-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  white-space: normal;
  width: 240px;
  max-width: 60vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 2;
}
.info-icon::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.info-icon:hover::after,
.info-icon:focus-visible::after,
.info-icon:hover::before,
.info-icon:focus-visible::before {
  opacity: 1;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  position: static;
  bottom: 0;
  padding-top: 8px;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, var(--card) 40%);
}

.data-table td { vertical-align: top; }

.data-table .col-id { width: 70px; font-variant-numeric: tabular-nums; }
.data-table .col-user { min-width: 160px; font-weight: 700; letter-spacing: -0.01em; }
.data-table .col-role select { min-width: 120px; }
.data-table .col-created { min-width: 150px; white-space: nowrap; }
.data-table .col-entries { min-width: 160px; }
.admin-page .entry-inline { display: inline-flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.data-table .col-options { min-width: 230px; }
.data-table .col-data { min-width: 240px; }
.data-table .col-actions { min-width: 200px; }

.metric-stack { display: flex; flex-direction: column; gap: 4px; }

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: stretch;
}

.table-actions.compact .btn,
.table-actions.compact select,
.table-actions .btn,
.table-actions input {
  flex: 1 1 120px;
}

.table-actions input { min-width: 140px; }

.table-actions .btn { justify-content: center; }

.table-actions a.btn { text-decoration: none; text-align: center; }

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.header-actions a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.header-actions a.btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
/* keep manage forms from overflowing their card */
.manage-grid form.inline {
  flex-wrap: wrap;       /* allow wrap to avoid clipping */
  overflow: visible;     /* let content stay visible */
}
.manage-grid form.inline > select,
.manage-grid form.inline > input {
  flex: 1 1 140px;
  min-width: 140px;
}
.manage-grid form.inline > button {
  flex: 0 0 auto;
}
.manage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
/* allow wrapping on small screens */
@media (max-width: 600px) {
  .manage-grid form.inline {
    flex-wrap: wrap;
  }
  .manage-grid form.inline > select,
  .manage-grid form.inline > input {
    flex: 1 1 180px;
  }
}
@media (max-width: 720px) {
  .container { padding: 18px; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.2rem; }
  .header-row { flex-direction: column; align-items: flex-start; }
  .header-row .inline { width: 100%; justify-content: flex-start; }
  form .grid { grid-template-columns: 1fr; }
  .card { padding: 14px; }
  .inline { flex-wrap: wrap; }
  table { min-width: 480px; }
  .action-bar { position: static; padding-top: 4px; }
  .table-actions .btn { flex: 1 1 140px; }
}
@media (max-width: 480px) {
  .container { padding: 14px; }
  .manage-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .manage-grid form.inline {
    gap: 6px;
  }
  .manage-grid form.inline > select,
  .manage-grid form.inline > input {
    flex: 1 1 100%;
    min-width: 0;
  }
  .manage-grid form.inline > button {
    width: 100%;
  }
  .header-row .inline .nav-btn,
  .header-row .inline .toggle-btn { width: 100%; }
  table { min-width: 0; }
}

@media (max-width: 900px) {
  .analytics-page .controls {
    flex-direction: column;
    align-items: stretch;
  }
  .analytics-page .controls label {
    width: 100%;
    justify-content: space-between;
  }
  .analytics-page .controls .btn {
    width: 100%;
    text-align: center;
  }
  .analytics-page .chart-wrap {
    height: 260px;
  }
}

@media (max-width: 600px) {
  .analytics-page h1 {
    font-size: 1.6rem;
  }
  .analytics-page table,
  .analytics-page th,
  .analytics-page td {
    font-size: 0.9rem;
  }
  .analytics-page .nav-btn,
  .analytics-page .toggle-btn {
    width: 100%;
    text-align: center;
  }
}
.pill-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pill {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pill.compact { padding: 4px 8px; font-size: 0.9rem; }
.type-pill { background: rgba(37, 99, 235, 0.14); color: #cbd5ff; border-color: rgba(37, 99, 235, 0.4); }

.warning-stack { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.warning-pill { background: #f59e0b; color: #111; padding: 6px 10px; border-radius: 999px; font-weight: 700; border: 1px solid #d97706; }
.pill button {
  background: none;
  color: var(--muted);
  border: none;
  cursor: pointer;
  padding: 0 4px;
}
.pill button:hover {
  color: #ef4444;
}

.badge {
  background: #f59e0b;
  color: #111;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  border: 1px solid #d97706;
}

.summary-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.top-values { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 6px; margin: 8px 0; }
.metric { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 0.95rem; }
.metric strong { font-weight: 700; }
.histogram { display: flex; align-items: flex-end; gap: 4px; height: 80px; margin-top: 8px; }
.histogram-bar { width: 8px; background: var(--accent); border-radius: 999px 999px 2px 2px; transition: opacity 0.2s ease; }
.histogram-bar:hover { opacity: 0.8; }

/* Admin table refinements */
.admin-page .table-wrapper { border-radius: 10px; border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.admin-page .table-wrapper.users-scroll { max-height: 960px; overflow-y: auto; }
.admin-page .table-wrapper.users-scroll thead { position: sticky; top: 0; z-index: 2; }
.admin-page .data-table { width: 100%; min-width: 0; table-layout: fixed; background: var(--card); }
.admin-page table { width: 100%; min-width: 0; }

.admin-page main.container {
  max-width: 90vw;
}
.admin-page .data-table thead { background: var(--card); }
.admin-page .data-table th,
.admin-page .data-table td { padding: 12px 14px; vertical-align: top; word-break: break-word; }
.admin-page .data-table .col-id { width: 64px; font-variant-numeric: tabular-nums; color: var(--muted); }
.admin-page .data-table .col-user { font-weight: 700; letter-spacing: -0.01em; }
.admin-page .data-table .col-created { white-space: nowrap; color: var(--muted); }
.admin-page .metric-stack { display: flex; flex-direction: column; gap: 4px; }
.admin-page .table-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: stretch; }
.admin-page .table-actions.compact .btn,
.admin-page .table-actions.compact select,
.admin-page .table-actions .btn,
.admin-page .table-actions input { flex: 1 1 120px; min-width: 0; }
.admin-page .table-actions input { min-width: 120px; }
.admin-page .table-actions .btn { justify-content: center; }
.admin-page .table-actions a.btn { text-decoration: none; text-align: center; }

@media (max-width: 1100px) {
  .admin-page .table-actions .btn { flex: 1 1 140px; }
}

@media (max-width: 640px) {
  .action-bar {
    position: static;
    bottom: 0;
    padding: 8px 0 0;
  }
}

/* Toast notifications */
.sdt-toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.sdt-toast {
  pointer-events: auto;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  animation: sdt-toast-in 0.25s ease;
  max-width: 420px;
}
.sdt-toast.toast-success { border-left: 4px solid #34d399; }
.sdt-toast.toast-error { border-left: 4px solid #f87171; }
.sdt-toast.toast-warning { border-left: 4px solid #f59e0b; }
.sdt-toast .toast-action {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}
.sdt-toast .toast-action:hover { background: var(--accent); color: #fff; }
@keyframes sdt-toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Confirmation modal */
.sdt-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: sdt-fade-in 0.15s ease;
}
.sdt-modal {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  max-width: 400px;
  width: 90vw;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.sdt-modal h3 { margin: 0 0 8px; }
.sdt-modal p { margin: 0 0 16px; color: var(--muted); }
.sdt-modal .sdt-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.sdt-modal .sdt-modal-cancel {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.sdt-modal .sdt-modal-cancel:hover { background: var(--hover); }
.sdt-modal .sdt-modal-confirm {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}
.sdt-modal .sdt-modal-confirm:hover { background: #dc2626; border-color: #dc2626; }
.sdt-modal input.sdt-modal-input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 16px;
}
@keyframes sdt-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Edit mode highlight */
.edit-mode-active .meta-grid {
  background: var(--hover);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 16px;
}

/* Field validation error */
.field-error input,
.field-error select,
.field-error textarea {
  border-color: #f87171 !important;
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.2);
}
.field-error-msg {
  color: #f87171;
  font-size: 0.8rem;
  margin-top: 2px;
}

/* Password strength meter */
.password-strength {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin-top: 4px;
  overflow: hidden;
}
.password-strength-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease, background 0.3s ease;
}
.strength-weak { background: #f87171; width: 33%; }
.strength-fair { background: #f59e0b; width: 66%; }
.strength-strong { background: #34d399; width: 100%; }
.password-strength-label {
  font-size: 0.8rem;
  margin-top: 2px;
}

/* Password toggle visibility */
.password-wrapper {
  position: relative;
}
.password-wrapper input {
  padding-right: 40px;
}
.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.password-toggle .eye-off { display: block; }
.password-toggle .eye { display: none; }
.password-toggle.showing .eye-off { display: none; }
.password-toggle.showing .eye { display: block; }
.password-toggle:hover { color: var(--text); }

/* Rifle empty hint */
.rifle-empty-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}
.rifle-empty-hint a {
  color: var(--accent);
  text-decoration: none;
}
.rifle-empty-hint a:hover {
  text-decoration: underline;
}

/* Filter toolbar grouping */
.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
}
.filter-group-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}
@media (max-width: 720px) {
  .filter-group-divider { display: none; }
}

/* ── Competition styles ──────────────────────────────────────────── */
.comp-invite-code {
  font-family: monospace;
  font-size: 1.2em;
  letter-spacing: 0.15em;
  padding: 4px 10px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  user-select: all;
}
.comp-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: 600;
  text-transform: capitalize;
}
.comp-badge-open { background: #166534; color: #bbf7d0; }
.comp-badge-closed { background: #92400e; color: #fde68a; }
.comp-badge-archived { background: var(--hover); color: var(--muted); }
.comp-leaderboard-rank { font-weight: bold; font-size: 1.1em; text-align: center; }
.comp-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.comp-target-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
}
.comp-shot-inputs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}
.comp-shot-input {
  width: 100%;
  text-align: center;
  padding: 8px 4px;
}
.comp-group-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.comp-group-tab {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
  font-weight: 500;
}
.comp-group-tab:hover { background: var(--hover); }
.comp-group-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.comp-group-tab.submitted { border-color: #22c55e; }
.comp-group-tab.submitted::after { content: ' \2713'; color: #22c55e; }
.comp-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
}
.comp-details-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.9em;
  color: var(--muted);
}
.btn-warning {
  background: #92400e;
  border-color: #b45309;
  color: #fde68a;
}
.btn-warning:hover { background: #b45309; }
.btn-danger {
  background: #991b1b;
  border-color: #dc2626;
  color: #fecaca;
}
.btn-danger:hover { background: #dc2626; }
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.overlay-content {
  max-height: 90vh;
  overflow-y: auto;
  width: 100%;
}
/* Competition comments */
.comp-comment-list { list-style: none; padding: 0; margin: 0; }
.comp-comment-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.comp-comment-list li:last-child { border-bottom: none; }

/* Notifications bell — fixed top-right */
.notif-bell {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 1100;
}
.notif-bell button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
  padding: 0;
}
.notif-bell button:hover {
  background: var(--hover);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  font-size: 0.65em;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  pointer-events: none;
}
.notif-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 1200;
  padding: 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.notif-dropdown::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 14px;
  width: 12px;
  height: 12px;
  background: var(--card);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}
.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8em;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.notif-clear-all {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 1em;
  padding: 0;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
}
.notif-clear-all:hover { text-decoration: underline; }
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  font-size: 0.85em;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
}
.notif-item-content { flex: 1; min-width: 0; }
.notif-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.2em;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.notif-dismiss:hover {
  color: #ef4444;
  background: rgba(239,68,68,0.1);
}
.notif-item:last-child { border-bottom: none; }
.notif-item.unread {
  font-weight: 600;
  background: rgba(37,99,235,0.06);
}
.notif-item.notif-empty {
  text-align: center;
  color: var(--muted);
  padding: 24px 14px;
  justify-content: center;
}
@media (max-width: 480px) {
  .notif-dropdown { width: calc(100vw - 32px); right: -8px; }
}

/* Responsive shot input grid */
@media (max-width: 600px) {
  .comp-shot-inputs { grid-template-columns: repeat(3, 1fr); }
}

.theme-light .comp-badge-open { background: #dcfce7; color: #166534; }
.theme-light .comp-badge-closed { background: #fef3c7; color: #92400e; }
.theme-light .btn-warning { background: #fef3c7; color: #92400e; border-color: #f59e0b; }
.theme-light .btn-danger { background: #fee2e2; color: #991b1b; border-color: #ef4444; }
