:root {
  --bg: #07111d;
  --panel: #111f32;
  --panel-soft: #16253b;
  --text: #ecf3ff;
  --muted: #9bb0cf;
  --border: rgba(255,255,255,0.08);
  --accent: #67b7ff;
  --accent-2: #8e7dff;
  --danger: #ff6f86;
  --gold: #ffd36b;
  --silver: #d6e1ff;
  --bronze: #ffbf8b;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, Arial, sans-serif;
  background: radial-gradient(circle at top, #13243d 0%, var(--bg) 60%);
  color: var(--text);
  overflow-x: hidden;
}
button, input, textarea, select {
  font: inherit;
}
button {
  cursor: pointer;
}
.page-shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 18px;
}
.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  background: linear-gradient(135deg, rgba(103,183,255,0.14), rgba(142,125,255,0.1));
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 20px;
  margin-bottom: 18px;
}
.hero h1 { margin: 4px 0 8px; font-size: clamp(1.8rem, 4vw, 3rem); }
.eyebrow { margin: 0; color: var(--accent); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.82rem; }
.subtext, .tiny-muted, small, p { color: var(--muted); }
.hero-actions, .inline-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.soft-pill {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
}
.panel {
  background: rgba(11, 22, 37, 0.92);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 18px;
  backdrop-filter: blur(6px);
}
.public-layout, .admin-layout {
  display: grid;
  grid-template-columns: 1.5fr 0.8fr;
  gap: 18px;
}
.admin-layout {
  grid-template-columns: 0.95fr 1.15fr 0.8fr;
}
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.gap-row { gap: 16px; }
.wrap-mobile { flex-wrap: wrap; }
.slim-top { margin-top: 16px; }
.mode-tabs {
  display: flex;
  gap: 10px;
  overflow: auto;
  padding: 8px 2px 12px;
  margin-bottom: 8px;
  scrollbar-width: thin;
}
.mode-tab, .secondary-button, .danger-button, .ghost-link, button[type="submit"], .page-btn {
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 14px;
  text-decoration: none;
}
.mode-tab.active, button[type="submit"], .page-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #05111f;
  font-weight: 700;
}
.danger-button {
  background: rgba(255,111,134,0.12);
  color: #ffd9df;
}
.search-input, input, textarea, select {
  width: 100%;
  background: #0f1c2d;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
}
.stack-form, .mode-editor-list {
  display: grid;
  gap: 12px;
}
.two-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 12px 0 16px;
}
.podium-card, .admin-player-card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  border-radius: 20px;
  padding: 16px;
  color: var(--text);
  text-align: center;
}
.place-1 { box-shadow: 0 0 0 1px rgba(255,211,107,0.35), 0 14px 32px rgba(255,211,107,0.16); }
.place-2 { box-shadow: 0 0 0 1px rgba(214,225,255,0.35), 0 14px 32px rgba(214,225,255,0.12); }
.place-3 { box-shadow: 0 0 0 1px rgba(255,191,139,0.35), 0 14px 32px rgba(255,191,139,0.12); }
.podium-badge {
  display: inline-block;
  margin-bottom: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}
.avatar-head {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  border-radius: 12px;
  background: #0c1726;
  flex-shrink: 0;
}
.avatar-head.small { width: 38px; height: 38px; }
.podium-head { width: 82px; height: 82px; border-radius: 18px; display: block; margin: 0 auto 10px; }
.podium-note {
  display: block;
  margin: 6px 0 2px;
}
.leaderboard-wrap { margin-top: 10px; }
.leaderboard-header, .leaderboard-row {
  display: grid;
  grid-template-columns: 70px 1.4fr 1fr 1fr;
  gap: 12px;
  align-items: center;
}
.leaderboard-header {
  padding: 12px 14px;
  color: var(--muted);
}
.leaderboard-row {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  border-radius: 18px;
  padding: 12px 14px;
  margin-bottom: 10px;
  text-align: left;
}
.place-cell { font-weight: 700; }
.name-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.name-cell span { min-width: 0; }
.name-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.name-meta strong,
.name-meta small,
.name-meta .player-inline-note {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.name-cell strong, .tier-cell, .point-cell { display: block; }
.name-cell small { display: block; margin-top: 2px; }
.player-inline-note {
  margin-top: 3px;
  font-size: 0.76rem;
  color: #cddcff;
  opacity: 0.92;
}
.points-list, .summary-grid, .recent-logs, .admin-player-list {
  display: grid;
  gap: 10px;
}
.point-row, .summary-card, .log-row, .mode-editor-row, .profile-mode-card {
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
}
.admin-player-card { text-align: left; }
.admin-player-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}
.all-points-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 74px;
  border-radius: 14px;
  padding: 8px 10px;
  background: rgba(103,183,255,0.12);
}
.all-points-card.mini { min-width: 62px; }
.mini-chip-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.mini-chip {
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  padding: 6px 10px;
  font-size: 0.88rem;
}
.message-box {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(103,183,255,0.12);
}
.message-box.error { background: rgba(255,111,134,0.12); color: #ffdce2; }
.hidden { display: none !important; }
.player-dialog {
  border: none;
  background: transparent;
  padding: 0;
  max-width: min(960px, calc(100vw - 20px));
}
.player-dialog::backdrop { background: rgba(0,0,0,0.62); }
.dialog-card {
  background: #0d1727;
  border: 1px solid var(--border);
  border-radius: 24px;
  color: var(--text);
  padding: 18px;
  width: min(960px, calc(100vw - 20px));
}
.wide-card { width: min(1080px, calc(100vw - 20px)); }
.profile-top {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 16px;
  align-items: start;
}
.skin-full {
  width: 96px;
  image-rendering: pixelated;
}
.profile-note { margin-top: 8px; }
.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}
.mode-editor-list {
  grid-template-columns: repeat(2, 1fr);
}
.mode-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.page-ellipsis {
  padding: 10px 4px;
  color: var(--muted);
}
.empty-state {
  border: 1px dashed var(--border);
  border-radius: 18px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}
@media (max-width: 1080px) {
  .public-layout, .admin-layout { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .page-shell {
    padding: 10px;
    max-width: 100%;
  }
  .hero {
    padding: 14px;
    border-radius: 18px;
    flex-direction: column;
    gap: 10px;
  }
  .hero h1 {
    font-size: 1.45rem;
    margin-bottom: 4px;
  }
  .hero .subtext {
    font-size: 0.9rem;
    margin: 0;
  }
  .hero-actions {
    display: none;
  }
  .panel {
    padding: 12px;
    border-radius: 18px;
  }
  .public-main-panel,
  .info-panel {
    width: 100%;
  }
  .section-title-row h2 {
    margin: 0;
    font-size: 1.05rem;
  }
  .search-input {
    min-height: 42px;
  }
  .mode-tabs {
    gap: 8px;
    padding-bottom: 8px;
    margin-bottom: 6px;
  }
  .mode-tab {
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 0.88rem;
    white-space: nowrap;
  }
  .two-grid, .profile-grid, .mode-editor-list { grid-template-columns: 1fr; }
  .podium {
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 10px 0 12px;
  }
  .podium-card {
    display: grid;
    grid-template-columns: 54px 1fr auto;
    gap: 10px;
    align-items: center;
    text-align: left;
    padding: 12px;
  }
  .podium-head {
    width: 54px;
    height: 54px;
    margin: 0;
    border-radius: 14px;
    grid-row: 1 / span 3;
  }
  .podium-badge {
    grid-column: 3;
    grid-row: 1;
    margin: 0;
    justify-self: end;
  }
  .podium-card strong,
  .podium-card .podium-note,
  .podium-card > span:last-child {
    grid-column: 2;
  }
  .leaderboard-header {
    display: none;
  }
  .leaderboard-row {
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 8px 10px;
    padding: 10px 12px;
    border-radius: 16px;
  }
  .place-cell {
    grid-row: 1 / span 3;
    font-size: 0.95rem;
    padding-top: 4px;
  }
  .name-cell {
    align-items: flex-start;
    gap: 10px;
  }
  .avatar-head {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }
  .name-meta strong {
    font-size: 0.98rem;
  }
  .name-meta small,
  .player-inline-note,
  .point-cell,
  .tier-cell {
    font-size: 0.78rem;
  }
  .tier-cell,
  .point-cell {
    grid-column: 2;
    margin-top: 0;
    line-height: 1.35;
  }
  .point-row {
    padding: 10px 12px;
  }
  .dialog-card {
    width: calc(100vw - 14px);
    padding: 14px;
    border-radius: 18px;
  }
  .profile-top {
    grid-template-columns: 70px 1fr;
    gap: 12px;
  }
  .profile-top .secondary-button {
    grid-column: 1 / -1;
    width: 100%;
  }
  .skin-full {
    width: 64px;
  }
}


/* Mobile-first compact public layout improvements */
.public-shell {
  min-height: 100vh;
}
.info-panel {
  align-self: start;
}
@media (max-width: 760px) {
  body.theme-public {
    background: linear-gradient(180deg, #08121e 0%, #0a1625 100%);
  }
  .page-shell {
    padding: 8px;
  }
  .hero {
    padding: 12px;
    border-radius: 16px;
    margin-bottom: 10px;
  }
  .eyebrow {
    font-size: 0.68rem;
  }
  .hero h1 {
    font-size: 1.18rem;
    line-height: 1.15;
  }
  .hero .subtext {
    font-size: 0.78rem;
    line-height: 1.35;
    max-width: 100%;
  }
  .public-layout {
    gap: 10px;
  }
  .panel {
    padding: 10px;
    border-radius: 16px;
  }
  .section-title-row {
    gap: 8px;
  }
  .section-title-row h2 {
    font-size: 0.98rem;
  }
  .tiny-muted {
    font-size: 0.72rem;
    line-height: 1.3;
  }
  .search-input, input, textarea, select {
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 0.92rem;
  }
  .mode-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
    padding: 4px 0 8px;
  }
  .mode-tab {
    width: 100%;
    padding: 8px 8px;
    min-height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.78rem;
  }
  .podium {
    display: none;
  }
  .leaderboard-wrap {
    margin-top: 6px;
  }
  .leaderboard-row {
    padding: 9px 10px;
    border-radius: 14px;
    gap: 6px 8px;
    margin-bottom: 8px;
    grid-template-columns: 38px minmax(0, 1fr);
  }
  .place-cell {
    font-size: 0.82rem;
    padding-top: 2px;
  }
  .name-cell {
    gap: 8px;
  }
  .avatar-head {
    width: 34px;
    height: 34px;
    border-radius: 9px;
  }
  .name-meta strong {
    font-size: 0.9rem;
    line-height: 1.1;
  }
  .name-meta small,
  .player-inline-note,
  .point-cell,
  .tier-cell {
    font-size: 0.72rem;
    line-height: 1.25;
  }
  .player-inline-note {
    margin-top: 2px;
  }
  .point-cell {
    opacity: 0.9;
  }
  .info-panel {
    padding-top: 8px;
  }
  .points-list {
    gap: 6px;
  }
  .point-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
  }
  .point-row strong,
  .point-row span {
    font-size: 0.78rem;
  }
  .pagination {
    gap: 6px;
    margin-top: 10px;
  }
  .page-btn {
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
  }
  .dialog-card {
    width: calc(100vw - 10px);
    padding: 12px;
  }
  .profile-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

.era-tabs {
  margin-bottom: 4px;
}
.era-hint {
  margin: -2px 0 10px;
}
.retired-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  background: rgba(255, 157, 94, 0.16);
  color: #ffd7b5;
  vertical-align: middle;
}
.retired-card {
  box-shadow: inset 0 0 0 1px rgba(255, 157, 94, 0.18);
}
.retired-chip {
  background: rgba(255, 157, 94, 0.16);
}
.retired-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  width: fit-content;
}
.retired-toggle.disabled {
  opacity: 0.48;
}
.retired-toggle input {
  width: auto;
  margin: 0;
}
.retired-help {
  display: block;
  margin-top: -6px;
}
@media (max-width: 760px) {
  .era-tabs {
    grid-template-columns: 1fr 1fr;
  }
  .retired-toggle {
    width: 100%;
    justify-content: flex-start;
  }
  .retired-badge {
    display: inline-flex;
    margin-left: 0;
    margin-top: 4px;
  }
}


/* Admin overflow and dialog fit fixes */
body.theme-admin .page-shell {
  max-width: 1500px;
}
.admin-left-panel,
.admin-center-panel,
.admin-right-panel,
.admin-player-list,
.summary-grid,
.mode-editor-list,
.mode-editor-row,
.mode-editor-row > * {
  min-width: 0;
}
.admin-layout {
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(220px, 300px);
  align-items: start;
}
.player-dialog {
  width: min(1120px, calc(100vw - 24px));
  max-width: min(1120px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  margin: auto;
  overflow: hidden;
}
.dialog-card,
.wide-card {
  width: 100%;
  max-width: 100%;
}
.editor-card {
  max-height: calc(100vh - 32px);
  overflow: auto;
}
.mode-editor-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.mode-editor-row select,
.mode-editor-row input,
.mode-editor-row textarea {
  min-width: 0;
}
.dialog-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
@media (max-width: 1320px) {
  .admin-layout {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  }
  .admin-right-panel {
    grid-column: 1 / -1;
  }
  .player-dialog {
    width: min(980px, calc(100vw - 18px));
    max-width: min(980px, calc(100vw - 18px));
  }
}
@media (max-width: 980px) {
  .player-dialog {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
    max-height: calc(100vh - 12px);
  }
  .editor-card {
    max-height: calc(100vh - 16px);
  }
  .mode-editor-list {
    grid-template-columns: 1fr;
  }
}
