/* Pokémon Royale hub and admin panel. Fonts and colours of the game. */
@font-face {
  font-family: RoyaleDisplay;
  src: url('/fonts/BricolageGrotesque-ExtraBold.ttf') format('truetype');
  font-weight: 800;
  font-display: swap;
}
@font-face {
  font-family: Royale;
  src: url('/fonts/Lexend-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Royale;
  src: url('/fonts/Lexend-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #090c1b;
  --panel: #10152b;
  --card: #151b35;
  --raised: #1c2444;
  --line: #262f55;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.66);
  --faint: rgba(255, 255, 255, 0.42);
  --crimson: #ff2e63;
  --crimson-deep: #c9134a;
  --yellow: #ffd23f;
  --ink: #0b0e1f;
  --ok: #3ddc97;
  --radius: 16px;
  --display: RoyaleDisplay, 'Arial Black', system-ui, sans-serif;
  --body: Royale, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --nav: 64px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 520px at 50% -260px, rgba(255, 46, 99, 0.22), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 400 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img {
  display: block;
  max-width: 100%;
}
button,
input {
  font: inherit;
  color: inherit;
}
a {
  color: var(--yellow);
}
h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 800;
  line-height: 1.05;
  margin: 0;
  letter-spacing: -0.01em;
}
h1 {
  font-size: clamp(30px, 7vw, 44px);
}
h2 {
  font-size: 22px;
}
h3 {
  font-size: 17px;
}
p {
  margin: 0;
}
[hidden] {
  display: none !important;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 60px;
  padding: 0 16px;
  background: rgba(9, 12, 27, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--display);
  font-size: 20px;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.brand b {
  color: var(--crimson);
  font-weight: 800;
}
.brand small {
  font-family: var(--body);
  font-weight: 600;
  font-size: 12px;
  color: var(--yellow);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.spacer {
  flex: 1;
}

.tabs {
  display: flex;
  gap: 4px;
}
.tabs a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
}
.tabs a:hover {
  color: var(--text);
}
.tabs a[aria-current='page'] {
  background: var(--raised);
  color: var(--text);
}
.tabs svg {
  width: 20px;
  height: 20px;
  flex: none;
}

/* Phones: the tabs become a bottom bar within reach of the thumb. */
@media (max-width: 719px) {
  /* A backdrop filter would make the header the containing block of the fixed bar. */
  .topbar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg);
  }
  .topbar .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--nav) + env(safe-area-inset-bottom));
    padding: 6px 8px env(safe-area-inset-bottom);
    background: rgba(12, 16, 34, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    justify-content: space-around;
  }
  .topbar .tabs a {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 4px 0;
    border-radius: 12px;
    font-size: 11px;
  }
  .topbar .tabs a[aria-current='page'] {
    background: none;
    color: var(--yellow);
  }
  body.has-nav main {
    padding-bottom: calc(var(--nav) + 32px + env(safe-area-inset-bottom));
  }
}

main {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

/* Buttons and fields */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 14px;
  background: var(--crimson);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover {
  background: #ff4a78;
}
.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.btn.yellow {
  background: var(--yellow);
  color: var(--ink);
}
.btn.ghost {
  background: var(--raised);
  color: var(--text);
}
.btn.ghost:hover {
  background: #26305a;
}
.btn.small {
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
  border-radius: 11px;
}
.btn.block {
  width: 100%;
}
.linkbtn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--yellow);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.field {
  display: grid;
  gap: 6px;
}
.field label {
  font-weight: 600;
  font-size: 14px;
}
.field .hint {
  color: var(--faint);
  font-size: 13px;
}
.input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus {
  border-color: var(--yellow);
}
.input.code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.form {
  display: grid;
  gap: 18px;
}
.error {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 46, 99, 0.14);
  border: 1px solid rgba(255, 46, 99, 0.5);
  color: #ffd0dc;
  font-size: 14px;
}
.notice {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(61, 220, 151, 0.12);
  border: 1px solid rgba(61, 220, 151, 0.45);
  color: #c9f7e2;
  font-size: 14px;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.stack {
  display: grid;
  gap: 16px;
}
.section-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 32px 0 14px;
}
.section-title h2 {
  white-space: nowrap;
}
.section-title:first-child {
  margin-top: 0;
}
.muted {
  color: var(--muted);
}
.faint {
  color: var(--faint);
}

/* Sign in */
.auth {
  max-width: 440px;
  margin: 4vh auto 0;
}
.auth-head {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 10px;
  margin-bottom: 24px;
}
.auth-portraits {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
}
.auth-portraits img {
  width: 72px;
  height: 72px;
  margin: 0 -10px;
  border-radius: 50%;
  background: var(--raised);
  border: 3px solid var(--bg);
  object-fit: contain;
}
.switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.switch button {
  min-height: 42px;
  border: 0;
  border-radius: 11px;
  background: none;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.switch button[aria-pressed='true'] {
  background: var(--raised);
  color: var(--text);
}
.below {
  margin-top: 18px;
  text-align: center;
  font-size: 15px;
}

/* Recovery code */
.codebox {
  display: block;
  padding: 18px 12px;
  border-radius: 14px;
  background: var(--ink);
  border: 2px dashed var(--yellow);
  color: var(--yellow);
  font: 600 clamp(19px, 5.6vw, 26px) / 1.2 ui-monospace, 'SF Mono', Menlo, monospace;
  letter-spacing: 0.05em;
  text-align: center;
  user-select: all;
}
.codebox span {
  display: inline-block;
  white-space: nowrap;
}
.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  font-size: 15px;
}
.check input {
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  accent-color: var(--crimson);
  flex: none;
}

/* Profile */
.hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: center;
  padding: 22px;
  background:
    radial-gradient(420px 220px at 0% 0%, rgba(255, 46, 99, 0.25), transparent 70%),
    var(--card);
}
.hero .portrait {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #2a3566, #141a35 70%);
  border: 3px solid var(--yellow);
  object-fit: contain;
  padding: 6px;
}
.hero-name {
  font-size: clamp(26px, 6vw, 38px);
  overflow-wrap: anywhere;
}
.level-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.level-badge {
  display: inline-grid;
  place-items: center;
  min-width: 54px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
}
.bar {
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: var(--ink);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--crimson), var(--yellow));
  transition: width 0.5s ease;
}
.xp-text {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}
@media (max-width: 479px) {
  .hero {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .hero .portrait {
    width: 112px;
    height: 112px;
  }
  .hero-info {
    width: 100%;
  }
}

.numbers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.number {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
}
.number b {
  display: block;
  font-family: var(--display);
  font-size: 28px;
  line-height: 1.1;
}
.number span {
  font-size: 13px;
  color: var(--muted);
}
.number.accent b {
  color: var(--yellow);
}
@media (max-width: 479px) {
  .numbers {
    grid-template-columns: 1fr 1fr;
  }
  .number b {
    font-size: 24px;
  }
}

.name-form {
  display: flex;
  gap: 10px;
}
.name-form .input {
  flex: 1;
  min-width: 0;
}

.companions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
}
.companion {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 10px 6px 12px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.companion:hover:not(:disabled) {
  border-color: #3a4680;
}
.companion img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}
.companion span {
  font-size: 13px;
  font-weight: 600;
}
.companion[aria-pressed='true'] {
  border-color: var(--yellow);
  background: #2a2a2c;
  background: linear-gradient(180deg, rgba(255, 210, 63, 0.16), rgba(255, 210, 63, 0.04)), var(--card);
}
.companion[aria-pressed='true']::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--yellow) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b0e1f' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.companion:disabled {
  cursor: not-allowed;
}
.companion:disabled img {
  filter: grayscale(1) brightness(0.45);
}
.companion:disabled span {
  color: var(--faint);
}
.lock {
  position: absolute;
  top: 42px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(11, 14, 31, 0.9);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
}
@media (max-width: 479px) {
  .companions {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .companion img {
    width: 60px;
    height: 60px;
  }
  .lock {
    top: 36px;
  }
}

/* Match history */
.matches {
  display: grid;
  gap: 10px;
}
.match {
  display: grid;
  grid-template-columns: 64px 56px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
}
.place {
  display: grid;
  place-items: center;
  height: 56px;
  border-radius: 14px;
  background: var(--raised);
  font-family: var(--display);
  font-size: 26px;
}
.place small {
  display: block;
  margin-top: -4px;
  font-family: var(--body);
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.place.win {
  background: var(--yellow);
  color: var(--ink);
}
.place.win small {
  color: rgba(11, 14, 31, 0.7);
}
.match img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}
.match-main {
  min-width: 0;
}
.match-main h3 {
  font-family: var(--body);
  font-weight: 600;
  font-size: 16px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
}
.chips b {
  color: var(--text);
  font-weight: 600;
}
.xp {
  font-family: var(--display);
  font-size: 22px;
  color: var(--yellow);
  white-space: nowrap;
}
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 46, 99, 0.18);
  color: #ffc2d2;
  font-size: 12px;
  font-weight: 600;
}
@media (max-width: 559px) {
  .match {
    grid-template-columns: 56px 1fr auto;
    gap: 12px;
    padding: 12px;
  }
  .match img {
    display: none;
  }
  .place {
    height: 52px;
    font-size: 22px;
  }
  .xp {
    font-size: 18px;
  }
}

/* Leaderboard */
.seg {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.seg button {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 11px;
  background: none;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.seg button[aria-pressed='true'] {
  background: var(--crimson);
  color: #fff;
}
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
th,
td {
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
}
th {
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line);
}
td {
  border-bottom: 1px solid rgba(38, 47, 85, 0.6);
}
tr:last-child td {
  border-bottom: 0;
}
td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
td.name {
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
}
.rank {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--raised);
  font-weight: 600;
  font-size: 14px;
}
.rank.r1 {
  background: var(--yellow);
  color: var(--ink);
}
.rank.r2 {
  background: #d8dce8;
  color: var(--ink);
}
.rank.r3 {
  background: #d9925a;
  color: var(--ink);
}
tr.me td {
  background: rgba(255, 46, 99, 0.12);
}
@media (max-width: 479px) {
  th,
  td {
    padding: 11px 8px;
  }
  th {
    font-size: 11px;
    letter-spacing: 0;
  }
  .rank {
    width: 28px;
    height: 28px;
  }
  .hide-sm {
    display: none;
  }
  .seg {
    display: grid;
    width: 100%;
  }
  .seg button {
    padding: 0 8px;
  }
}

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.loading {
  padding: 60px 0;
  text-align: center;
  color: var(--faint);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--raised);
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media (max-width: 719px) {
  body.has-nav .toast {
    bottom: calc(var(--nav) + 16px + env(safe-area-inset-bottom));
  }
}
