@import url('https://fonts.googleapis.com/css2?family=Oxanium:wght@400;600;700&family=Rajdhani:wght@400;600&display=swap');

:root {
  --bg1: #0b1433;
  --bg2: #0c2b2c;
  --ink: #e9f2ff;
  --muted: #b7c5e6;
  --gold: #d6b25a;
  --electric: #f6d04d;
  --accent: #6fe3ff;
  --win: #9cff6b;
  --shadow: rgba(4, 8, 16, 0.6);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  padding: 32px 16px 60px;
  font-family: "Rajdhani", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: none;
  min-height: 100vh;
  position: relative;
}

/* Fixed background layer for mobile-safe rendering */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(8, 12, 20, 0.12), rgba(8, 12, 20, 0.20)),
    var(--page-bg, none);
  /* subtle base glow */
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.35);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: var(--page-bg-pos, 50% 50%);
  width: 100vw;
  height: 100dvh;
  transform: translateZ(0);
}

/* Dedicated background layer for stats/rankings pages (more reliable on iOS) */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(8, 12, 20, 0.12), rgba(8, 12, 20, 0.20)),
    var(--page-bg, none);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: var(--page-bg-pos, 50% 50%);
  width: 100vw;
  height: 100dvh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(2px 2px at 20% 30%, rgba(255, 255, 255, 0.5), transparent 60%),
    radial-gradient(2px 2px at 70% 40%, rgba(255, 255, 255, 0.4), transparent 60%),
    radial-gradient(3px 3px at 40% 10%, rgba(255, 255, 255, 0.4), transparent 60%),
    radial-gradient(2px 2px at 60% 70%, rgba(255, 255, 255, 0.3), transparent 60%);
  opacity: 0.12;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  border-radius: 14px;
  padding: 28px 24px 32px;
  position: relative;
  z-index: 1;
}

.header {
  text-align: center;
  padding: 12px 10px 24px;
  border-bottom: none;
}

.header h1 {
  margin: 6px 0 6px;
  font-family: "Oxanium", "Rajdhani", sans-serif;
  letter-spacing: 1px;
  font-size: 34px;
  color: var(--electric);
  text-shadow: 0 2px 8px rgba(246, 208, 77, 0.35);
}

.subtitle {
  color: var(--muted);
  font-size: 16px;
  letter-spacing: 0.5px;
}

.nav {
  margin-top: 10px;
  font-size: 14px;
}

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

.nav a:hover {
  color: var(--electric);
  text-decoration: underline;
}

body.party-page .nav a {
  color: #fff6bf;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.65);
  font-weight: 700;
}

body.party-page .nav a:hover {
  color: #ffffff;
  text-decoration: underline;
}

@media (min-width: 769px) {
  body.index-page .nav {
    position: fixed;
    top: 14px;
    right: 18px;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: right;
    z-index: 30;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(111, 227, 255, 0.25);
    background: linear-gradient(180deg, rgba(11, 20, 46, 0.9), rgba(8, 14, 34, 0.86));
    box-shadow: 0 12px 26px rgba(5, 10, 20, 0.45);
    backdrop-filter: blur(4px);
  }

  body.index-page .nav a {
    display: block;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(111, 227, 255, 0.3);
    background: rgba(8, 22, 52, 0.72);
    color: #c8f0ff;
    text-decoration: none;
    letter-spacing: 0.3px;
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, color 120ms ease;
  }

  body.index-page .nav a::before {
    content: "› ";
    color: var(--electric);
  }

  body.index-page .nav a:hover {
    transform: translateX(-2px);
    border-color: rgba(246, 208, 77, 0.75);
    background: rgba(18, 34, 76, 0.85);
    color: var(--electric);
    text-decoration: none;
  }
}

.search-panel {
  margin: 18px auto 8px;
  max-width: 760px;
}

.search-tabs {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 10px;
}

.search-tab {
  border: 1px solid rgba(111, 227, 255, 0.35);
  background: rgba(8, 20, 50, 0.55);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: "Rajdhani", sans-serif;
  font-size: 14px;
  cursor: pointer;
}

.search-tab.is-active {
  border-color: rgba(246, 208, 77, 0.8);
  color: var(--electric);
}

.search-box {
  position: relative;
}

.search-input {
  width: 100%;
  border: 1px solid rgba(111, 227, 255, 0.35);
  background: rgba(8, 20, 50, 0.6);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 16px;
  font-family: "Rajdhani", sans-serif;
}

.search-input::placeholder {
  color: var(--muted);
}

.search-suggestions {
  display: none;
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  margin-top: 6px;
  border: 1px solid rgba(111, 227, 255, 0.35);
  border-radius: 10px;
  background: rgba(8, 20, 50, 0.95);
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}

.search-suggestions.is-open {
  display: block;
}

.search-suggestion {
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(111, 227, 255, 0.14);
}

.search-suggestion:last-child {
  border-bottom: none;
}

.search-suggestion:hover {
  background: rgba(111, 227, 255, 0.14);
}

.search-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.log-list h2 {
  margin: 24px 0 12px;
  font-size: 20px;
  font-weight: 600;
  color: var(--gold);
  text-align: center;
  border: none;
  box-shadow: none;
}

.log-item {
  margin: 14px 0;
  padding: 16px 18px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(22, 43, 90, 0.9), rgba(15, 26, 59, 0.9));
  border: 1px solid rgba(111, 227, 255, 0.25);
  box-shadow: 0 10px 20px rgba(5, 10, 20, 0.45);
  position: relative;
  overflow: hidden;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.log-item::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 10px;
  bottom: 10px;
  width: 6px;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--accent), var(--electric));
  box-shadow: 0 0 8px rgba(111, 227, 255, 0.45);
}

.log-item:hover {
  transform: translateY(-2px);
  border-color: rgba(214, 178, 90, 0.55);
  box-shadow: 0 14px 26px rgba(5, 10, 20, 0.6);
}

.log-item a {
  text-decoration: none;
  color: inherit;
  display: block;
  padding-left: 12px;
}

.log-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
}

.index-page .log-header {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.index-page .timestamp {
  margin-top: 2px;
}

.players {
  font-size: 16px;
  font-weight: 600;
}

.winner {
  color: var(--win);
  font-weight: 700;
}

.timestamp {
  font-size: 13px;
  color: var(--muted);
  opacity: 0.85;
}

.build-info {
  margin-top: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border: none;
  box-shadow: none;
}

.battle-log {
  background: #0b132a;
  border: 1px solid rgba(214, 178, 90, 0.3);
  padding: 16px;
  margin: 18px 0;
  font-family: "Oxanium", monospace;
  font-size: 12px;
  line-height: 1.5;
  max-height: 70vh;
  overflow-y: auto;
  text-align: left;
  border-radius: 10px;
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.35);
}

.battle-log p {
  margin: 2px 0;
  padding: 0;
}

.battle-log p[align="right"] {
  text-align: right;
}

/* Page backgrounds */
body.auth-page {
  --page-bg: url("/pbs/assets/auth-bg.png?v=20260219232500");
  --page-bg-pos: 50% 50%;
}

body.index-page {
  --page-bg: url("/pbs/assets/logs-bg.png");
  --page-bg-pos: 60% 40%;
}

body.stats-page {
  --page-bg: url("/pbs/assets/player-stats-bg.png?v=20260205");
  --page-bg-pos: 70% 60%;
}

body.rankings-page {
  --page-bg: url("/pbs/assets/pokemon-usage-bg.png?v=20260205");
  --page-bg-pos: 70% 45%;
}

body.stats-page::after,
body.rankings-page::after {
  display: none;
}

/* Remove panels for all three pages */
body.index-page .container,
body.stats-page .container,
body.rankings-page .container {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

body.index-page .container::after {
  content: none !important;
}

body.index-page .log-list,
body.stats-page .log-list,
body.rankings-page .log-list,
body.stats-page .stats-table-wrap,
body.rankings-page .stats-table-wrap {
  background: transparent !important;
}

body.stats-page .stats-table-wrap {
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible;
}

body.rankings-page .stats-table-wrap {
  border: none;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none;
  overflow: visible;
}

body.stats-page .stats-table,
body.rankings-page .stats-table {
  width: auto;
  border-collapse: collapse;
  font-size: 16px;
}

body.stats-page .stats-table {
  table-layout: auto;
}

body.stats-page .stats-table thead th {
  padding: 10px 12px;
  color: #1a2233;
  background: transparent;
  border-bottom: none;
  text-align: left;
  white-space: nowrap;
}

body.rankings-page .stats-table thead th {
  padding: 10px 12px;
  color: #ffe07f;
  background: transparent;
  border-bottom: none;
  text-align: left;
  white-space: nowrap;
}

body.stats-page .stats-table tbody td {
  padding: 9px 12px;
  color: #131a29;
  border-bottom: none;
  white-space: nowrap;
}

body.rankings-page .stats-table tbody td {
  padding: 9px 12px;
  color: #f2f7ff;
  border-bottom: none;
  white-space: nowrap;
}

body.stats-page .stats-table tbody tr:last-child td,
body.rankings-page .stats-table tbody tr:last-child td {
  border-bottom: none;
}

body.stats-page .stats-table td.rank {
  color: #0f1726;
  font-weight: 700;
  width: 56px;
}

body.rankings-page .stats-table td.rank {
  color: #9cd9ff;
  font-weight: 700;
  width: 56px;
}

body.stats-page .stats-table td:nth-child(2) {
  color: #0f1726;
  font-weight: 700;
}

body.stats-page .stats-table td.count {
  color: #0f1726;
  font-weight: 700;
  padding-left: 6px;
  white-space: nowrap;
}

body.stats-page .stats-table th:nth-child(2) {
  padding-left: 6px;
}

body.stats-page .stats-table th:nth-child(3),
body.stats-page .stats-table td:nth-child(3) {
  padding-left: 6px;
}

body.rankings-page .stats-table td.count {
  color: #ffd96a;
  font-weight: 700;
  padding-left: 6px;
}

/* Remove cards only on index page */
body.index-page .log-item,
body.index-page .log-header {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

body.index-page .log-item::before {
  display: none !important;
}

body.index-page .log-item {
  padding: 8px 0 !important;
}

body.index-page .log-item a {
  padding-left: 0 !important;
  display: inline-flex !important;
  flex-direction: column;
  align-items: flex-start;
  width: auto !important;
}

body.index-page .log-header {
  display: inline-flex !important;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start !important;
}

/* Remove any divider lines */
hr,
.header,
.header *,
.log-list h2,
.log-list h2::after,
.log-list hr,
.header hr,
.nav hr,
.container hr {
  border: none !important;
  box-shadow: none !important;
}



/* Party public list background */
body.party-public-page {
  background:
    linear-gradient(180deg, rgba(8, 12, 20, 0.02), rgba(8, 12, 20, 0.06)),
    url(/pbs/assets/party-public-bg.png) center center / cover no-repeat fixed;
}

/* Mobile (iPhone 13) background positioning */
@media (max-width: 430px) {
  body.stats-page {
    --page-bg-pos: 60% center;
  }

  body.rankings-page {
    --page-bg-pos: 60% 98%;
  }

  body.index-page {
    --page-bg-pos: 50% 60%;
  }

  body.auth-page {
    --page-bg-pos: 52% 50%;
  }

  body.party-public-page {
    background-attachment: scroll !important;
    background-position: center center !important;
    background-size: 260% 105% !important;
  }
}
