@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");
/* PowPaint-inspired theme */
:root {
  --bg: #1a1f2e;
  --panel-bg: linear-gradient(#2b3248, #1c2233);
  --panel-border: #3a425a;
  --panel-inner: #0e1117;
  --accent-bg: linear-gradient(#3e4b6d, #2c3654);
  --accent-border: #1e2433;
  --hover-bg: #2c3654;
  --highlight: #8899ff;
  --text: #e0e6ff;
  --active-scale: 0.97;
  --row-alt: #21283a;
  --skeleton-1: #2b3248;
  --skeleton-2: #1c2233;
  --rank-width: calc(3ch + 4px);
}

:root[data-theme="light"] {
  --bg: #f5f7fa;
  --panel-bg: linear-gradient(#ffffff, #e8edf5);
  --panel-border: #cfd8e3;
  --panel-inner: #e2e8f0;
  --accent-bg: linear-gradient(#e4e9f2, #d4dae6);
  --accent-border: #c0c8d8;
  --hover-bg: #d7deeb;
  --highlight: #556cd6;
  --text: #1a202c;
  --row-alt: #eef2f7;
  --skeleton-1: #e4e9f2;
  --skeleton-2: #cfd8e3;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--highlight) var(--panel-inner);
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: var(--panel-inner);
}

*::-webkit-scrollbar-thumb {
  background-color: var(--highlight);
  border-radius: 4px;
  border: 2px solid var(--panel-inner);
}
html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  line-height: 1.2;
  color: var(--text);
  transition:
    background 0.3s,
    color 0.3s;
  touch-action: manipulation;
}

body.leaderboard-page {
  overflow: hidden;
}

body.leaderboard-page .table-wrap {
  overscroll-behavior: contain;
}
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: var(--bg);
}
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--highlight);
  outline-offset: 2px;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border-bottom: 2px solid var(--panel-border);
  background: var(--panel-bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--accent-bg);
  border: 2px solid var(--accent-border);
  border-radius: 4px;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.brand-name {
  font-size: 10px;
}

.tabs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 8px;
  width: clamp(120px, 33%, 220px);
  background: var(--panel-bg);
  border-right: 2px solid var(--panel-border);
  box-shadow: inset -2px 0 0 var(--panel-inner);
  flex-shrink: 0;
}
.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 4px;
  border: 2px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  font-size: 12px;
  transition:
    background 0.2s,
    transform 0.1s;
  width: 100%;
  justify-content: flex-start;
}
.tab:hover {
  background: var(--hover-bg);
}
.tab:active {
  transform: scale(var(--active-scale));
}
.tab.active {
  background: var(--panel-inner);
  border-color: var(--panel-border);
  box-shadow: inset 2px 0 0 var(--highlight);
}

.skill-emoji {
  font-size: 16px;
  line-height: 1;
}
.skill-emoji img {
  width: 1em;
  height: 1em;
}
.skill-name {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search {
  background: var(--panel-inner);
  border: 2px solid var(--panel-border);
  border-radius: 4px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 12px;
  font-family: inherit;
  width: 240px;
  max-width: 100%;
  box-shadow: 0 0 0 2px transparent;
  transition:
    background 0.2s,
    border-color 0.2s,
    box-shadow 0.2s;
}
.search:hover {
  background: var(--hover-bg);
}
.search:focus {
  border-color: var(--highlight);
  background: var(--panel-inner);
  box-shadow: 0 0 0 2px var(--highlight);
}

@media (max-width: 900px), (orientation: portrait) {
  .search {
    font-size: 16px;
  }
}

.search-wrap {
  position: relative;
  height: 100%;
}

.search-selection {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  padding: 4px;
  background: var(--panel-inner);
  border: 2px solid var(--panel-border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  box-sizing: border-box;
}

.search-selection .selection-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: var(--hover-bg);
  border-radius: 4px;
}

.search-selection .clear {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  width: 16px;
  height: 16px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  font-size: 12px;
  line-height: 1;
}

.search-selection .clear:hover {
  background: var(--panel-border);
}

.search-wrap.has-selection .search {
  visibility: hidden;
}

.search-wrap.has-selection .search-selection {
  display: flex;
}

.search-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--panel-inner);
  border: 2px solid var(--panel-border);
  border-radius: 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.search-suggestions .suggestion {
  padding: 4px 8px;
  cursor: pointer;
}

.search-suggestions .suggestion:hover,
.search-suggestions .suggestion.active {
  background: var(--hover-bg);
}

.theme-toggle {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--accent-bg);
  border: 2px solid var(--accent-border);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background 0.2s,
    transform 0.1s;
}
.theme-toggle:hover {
  background: var(--hover-bg);
}
.theme-toggle:active {
  transform: scale(var(--active-scale));
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.panel {
  padding: 8px;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 8px;
}
.panel-title {
  margin: 0;
  font-size: 14px;
}
.panel-title img {
  width: 1em;
  height: 1em;
  vertical-align: middle;
}
.muted {
  color: var(--highlight);
}

#panel-meta button {
  background: none;
  border: none;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  padding: 0;
  margin-left: 4px;
}

.table-wrap {
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px var(--panel-inner);
  overflow: auto;
  flex: 1;
  position: relative;
  padding-right: 8px;
}
.board {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  table-layout: fixed;
}
.board thead th {
  background: var(--panel-inner);
  color: var(--text);
  padding: 6px;
  text-align: left;
  border-bottom: 2px solid var(--panel-border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.board thead th.rank,
.board thead th.level,
.board thead th.xp {
  text-align: right;
}
.board thead th.levels {
  padding-left: 4px;
  width: 418px;
}
.board thead th.levels .levels-label {
  display: block;
  width: max-content;
  /* Align label with first skill chip */
  margin-left: calc(100% - 338px);
}
.board tbody tr {
  border-top: 2px solid var(--panel-border);
  background: transparent;
  cursor: pointer;
  transition: background 0.2s;
}
.board tbody tr:nth-child(even) {
  background: var(--row-alt);
}
.board tbody tr:hover {
  background: var(--hover-bg);
}
.board tbody tr.selected {
  background: var(--panel-inner);
  border-color: var(--panel-border);
  box-shadow: inset 2px 0 0 var(--highlight);
}
.board td {
  padding: 6px;
  vertical-align: middle;
}

.board col.col-rank,
.board th.rank,
.board td.rank {
  width: var(--rank-width);
}
.board col.col-player {
  width: 30%;
}
.board col.col-level {
  width: 13ch;
}
.board col.col-xp {
  width: 15%;
}
.board col.col-levels {
  width: auto;
}

.board th.rank,
.board td.rank {
  padding-left: 0;
  padding-right: 4px;
  text-align: right;
}
.board td.username {
  display: flex;
  align-items: center;
  gap: 8px;
}
.board td.username .user-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.username {
  font-weight: 700;
}
.level,
.xp {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.board td.level {
  padding-right: 4px;
}
.leaderboard-page .board td.level .level-value {
  margin-top: 0;
  font-size: inherit;
  color: inherit;
}

@media (max-width: 700px) {
  .leaderboard-page .board td.level .level-value {
    font-size: 8px;
    color: var(--highlight);
  }
}
.board td.xp {
  padding-left: 4px;
  padding-right: 4px;
}
.board td.levels {
  padding-left: 4px;
}

.board td.rank::before {
  content: "";
}

.board td.level .label,
.board td.xp .label {
  display: none;
}

.board td.level .xp-sub {
  display: none;
}
.skeleton-list {
  padding: 8px;
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  background: var(--panel-bg);
}
.skeleton-row {
  height: 40px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--skeleton-1),
    var(--skeleton-2) 50%,
    var(--skeleton-1)
  );
  background-size: 180% 100%;
  animation: sk 1.4s ease-in-out infinite;
  margin: 4px 0;
}
@keyframes sk {
  0% {
    background-position: 0% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.error {
  padding: 8px;
  color: var(--text);
  background: var(--panel-inner);
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, 32px);
  gap: 2px;
  justify-content: end;
}

.show-skills {
  display: none;
  background: none;
  border: none;
  color: var(--highlight);
  font-family: inherit;
  cursor: pointer;
  line-height: 1;
  width: 1em;
  text-align: center;
}

.show-skills:active {
  transform: scale(var(--active-scale));
}
.level-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 32px;
  height: 32px;
  padding: 2px;
  border-radius: 4px;
  background: var(--panel-inner);
  border: 2px solid var(--panel-border);
  font-size: 8px;
  text-align: center;
}
.level-chip.hl {
  border-color: var(--highlight);
}
.level-chip .e {
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  width: 100%;
  height: 1em;
}
.level-chip .e img {
  display: block;
  width: 1em;
  height: 1em;
}
.level-chip .v {
  width: 100%;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

@media (max-aspect-ratio: 3/4) {
  .tabs {
    width: clamp(60px, 25vw, 160px);
  }
  .tab {
    gap: 4px;
    padding: 6px 8px;
    font-size: 10px;
  }
  .skill-emoji {
    font-size: 14px;
  }
  .skill-name {
    font-size: 10px;
  }
}

@media (max-aspect-ratio: 2/3) {
  .tab {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 2px;
  }
  .skill-emoji {
    font-size: 24px;
  }
  .skill-name {
    white-space: normal;
    font-size: 8px;
  }
}

@media (max-width: 600px), (orientation: portrait) {
  .actions {
    flex-basis: 100%;
    order: 2;
    justify-content: space-between;
  }
  .search-wrap {
    flex: 1;
  }
  .search {
    width: 100%;
  }
}

@media (max-width: 700px), (orientation: portrait) {
  .board colgroup,
  .board thead {
    display: none;
  }
  .board tbody tr {
    display: grid;
    grid-template-areas:
      "rank username level"
      "rank xp xp"
      "rank skills skills";
    grid-template-columns: var(--rank-width) 1fr auto;
    align-items: center;
    border-top: 2px solid var(--panel-border);
  }
  .board td {
    padding: 6px 8px;
  }
  .board td.rank {
    grid-area: rank;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    align-self: center;
    padding-left: 0;
    padding-right: 4px;
  }
  .board td.username {
    grid-area: username;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .board td.username .user-text {
    display: block;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .board td.level {
    grid-area: level;
    text-align: right;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
  .board td.xp {
    grid-area: xp;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: var(--rank-width);
    font-size: 8px;
    color: var(--highlight);
    cursor: pointer;
  }
  .board td.xp .xp-text {
    margin-left: auto;
  }
  .board td.xp .label {
    display: inline;
  }
  .board td.levels {
    display: contents;
  }
  .board .level-grid {
    grid-area: skills;
    padding-left: var(--rank-width);
    grid-template-columns: repeat(5, 40px);
    gap: 4px;
    justify-content: flex-start;
  }
  .board td.rank::before {
    content: none;
  }
  .board td.level .label {
    display: inline;
  }
  .av {
    width: 36px;
    height: 36px;
    margin-right: 8px;
  }
}

@media (orientation: portrait) {
  :root {
    --rank-width: calc(3ch + 8px);
  }
  .board tbody tr {
    grid-template-areas:
      "rank username level"
      "rank skills skills";
  }
  .board td.rank {
    align-self: center;
    padding-left: 4px;
  }
  .board td.level {
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    align-self: center;
  }
  .leaderboard-page .board td.level .level-value {
    color: var(--text);
    font-size: inherit;
  }
  .board td.level .xp-sub {
    display: block;
    font-size: 8px;
    color: var(--highlight);
    margin-top: 2px;
    cursor: pointer;
    text-align: right;
  }
  .board td.level .xp-sub .label {
    display: inline;
  }
  .board td.xp {
    display: none;
  }
  .board .level-grid {
    display: none;
    margin-top: 4px;
    padding: 0;
  }
  .board .level-grid.show {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 40px;
    gap: 4px;
    width: max-content;
    padding: 4px;
  }
  .show-skills {
    display: inline-block;
    padding: 2px;
    font-size: 10px;
    margin-top: 0;
  }
}

@media (orientation: portrait) {
  .panel-head {
    display: none;
  }

  .body {
    flex-direction: column;
  }

  .tabs {
    flex-direction: row;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 2px solid var(--panel-border);
    box-shadow: inset 0 -2px 0 var(--panel-inner);
  }

  .tab {
    flex: 0 0 auto;
    width: auto;
  }
}

/* Profile page */
.profile-main {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px;
  background: radial-gradient(circle at top, var(--panel-bg), var(--bg));
  min-height: 100vh;
}
.profile-card {
  text-align: center;
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 8px;
  padding: 24px;
  box-shadow:
    0 0 15px var(--highlight),
    0 4px 0 var(--panel-border);
  animation: float 6s ease-in-out infinite;
  width: 100%;
  max-width: 650px;
  transform-style: preserve-3d;
  transition: transform 0.3s;
}
.profile-card:hover {
  transform: rotateX(2deg) rotateY(-2deg) scale(1.02);
}
@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 2px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--text);
  text-decoration: none;
  font-size: 10px;
  transition:
    background 0.2s,
    transform 0.1s;
}
.back-link:hover {
  background: var(--hover-bg);
}
.back-link:active {
  transform: scale(var(--active-scale));
}
.back-link .back-icon {
  width: 12px;
  height: 12px;
}
.profile-render {
  --clip-hex: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  display: block;
  width: 200px;
  height: 200px;
  margin: 0 auto;
  overflow: hidden;
  border: 4px solid var(--accent-border);
  box-shadow: 0 0 10px var(--highlight);
  position: relative;
  clip-path: var(--clip-hex);
}
.profile-render::after {
  content: "";
  position: absolute;
  inset: -4px;
  clip-path: var(--clip-hex);
  background: conic-gradient(var(--highlight), transparent, var(--highlight));
  animation: spin 6s linear infinite;
  mix-blend-mode: overlay;
}
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
.profile-render img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.profile-name {
  margin-top: 16px;
  font-size: 24px;
  font-weight: 700;
}
.profile-levels {
  margin: 24px auto 0;
  display: flex;
  gap: 16px;
  justify-content: center;
}
.level-badge {
  background: var(--accent-bg);
  border: 2px solid var(--accent-border);
  border-radius: 8px;
  padding: 12px 16px;
  width: 100px;
  cursor: pointer;
  box-shadow:
    0 4px 0 var(--panel-border),
    0 0 10px var(--highlight);
  text-align: center;
  transition: transform 0.2s;
}
.level-badge:hover {
  transform: translateY(-4px) scale(1.05);
}
.level-icon {
  font-size: 24px;
  line-height: 1;
}
.level-icon img {
  width: 1em;
  height: 1em;
}
.level-label {
  margin-top: 4px;
  font-size: 10px;
}
.level-value {
  margin-top: 4px;
  font-size: 18px;
  color: var(--highlight);
}
.profile-skills {
  margin: 32px auto;
  display: grid;
  gap: 12px;
  max-width: 400px;
}
.profile-ranks {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  align-items: flex-start;
  max-width: 650px;
  margin-left: auto;
  margin-right: auto;
}

.reveal-item {
  opacity: 0;
  /* Reduce initial offset/scale so elements pop in with less bounce */
  transform: translateY(4px) scale(0.98);
}

.reveal-item.revealed {
  /* Quicker animation for the non-badge content */
  animation: badge-pop 0.2s forwards;
  animation-delay: var(--delay);
}

.profile-stats-heading {
  margin: 24px 0 8px;
  font-size: 20px;
  font-weight: 600;
  color: var(--highlight);
}

.profile-ranks .badge-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rank-badge {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 140px;
  padding: 16px 12px;
  background: var(--accent-bg);
  border: 5px solid var(--accent-border);
  border-radius: 20px;
  font-size: 16px;
  box-shadow:
    0 6px 0 var(--panel-border),
    0 0 20px rgba(0, 0, 0, 0.4);
  text-align: center;
  overflow: hidden;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  opacity: 0;
  transform: translateY(10px) scale(0.9);
  cursor: pointer;
}

.rank-badge.badge-ready {
  animation: badge-pop 0.4s forwards;
  animation-delay: var(--delay);
}

.rank-badge:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow:
    0 8px 0 var(--panel-border),
    0 4px 20px rgba(0, 0, 0, 0.4);
}

.rank-badge::after {
  content: "";
  position: absolute;
  top: -40%;
  left: -40%;
  width: 80%;
  height: 200%;
  background: linear-gradient(
    130deg,
    rgba(255, 255, 255, 0) 40%,
    rgba(255, 255, 255, 0.6) 50%,
    rgba(255, 255, 255, 0) 60%
  );
  transform: translateX(-100%) rotate(25deg);
  animation: shine 4s ease-in-out infinite;
}

@keyframes shine {
  from {
    transform: translateX(-100%) rotate(25deg);
  }
  to {
    transform: translateX(200%) rotate(25deg);
  }
}

@keyframes badge-pop {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.rank-badge .badge-icon {
  font-size: 40px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rank-badge .badge-icon img {
  width: 1em;
  height: 1em;
  display: block;
}

.rank-badge .badge-rank {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.rank-badge .badge-label {
  margin-top: 8px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.rank-badge.rank-1 {
  background: radial-gradient(circle at 30% 30%, #fff8b0, #ffd700);
  border-color: #e6c200;
  color: #000;
  box-shadow:
    0 6px 0 var(--panel-border),
    0 0 25px rgba(255, 215, 0, 0.7);
}

.rank-badge.rank-2 {
  background: radial-gradient(circle at 30% 30%, #f0f0f0, #c0c0c0);
  border-color: #9c9c9c;
  color: #000;
  box-shadow:
    0 6px 0 var(--panel-border),
    0 0 25px rgba(192, 192, 192, 0.7);
}

.rank-badge.rank-3 {
  background: radial-gradient(circle at 30% 30%, #ffddb5, #cd7f32);
  border-color: #8a5a1e;
  color: #000;
  box-shadow:
    0 6px 0 var(--panel-border),
    0 0 25px rgba(205, 127, 50, 0.7);
}

.rank-badge.rank-other {
  color: var(--text);
}

.medal-badge {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 180px;
  height: 64px;
  padding: 8px 10px;
  background: linear-gradient(145deg, var(--panel-bg), var(--accent-bg));
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  font-size: 12px;
  box-shadow:
    0 2px 0 var(--panel-border),
    0 0 8px rgba(0, 0, 0, 0.2);
  text-align: left;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  opacity: 0;
  transform: translateY(6px) scale(0.95);
  cursor: pointer;
}

.medal-badge.badge-ready {
  animation: badge-pop 0.4s forwards;
  animation-delay: var(--delay);
}

.medal-badge:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow:
    0 4px 0 var(--panel-border),
    0 2px 10px rgba(0, 0, 0, 0.3);
}

.medal-badge .medal-icon {
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.medal-badge .medal-icon img {
  width: 1em;
  height: 1em;
  display: block;
}

.medal-badge .medal-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.medal-badge .medal-tier {
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.medal-badge .medal-label {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.2;
}

.medal-badge.tier-5 {
  background: radial-gradient(circle at 30% 30%, #ff6b6b, #b30000);
  border-color: #7d0000;
  color: #000;
}

/* Responsive badge adjustments */
@media (max-width: 600px) {
  .rank-badge {
    width: 140px;
    height: 110px;
    padding: 12px 8px;
    font-size: 14px;
  }
  .rank-badge .badge-icon {
    font-size: 32px;
  }
  .rank-badge .badge-rank {
    font-size: 22px;
  }
  .rank-badge .badge-label {
    font-size: 12px;
  }
  .medal-badge {
    width: 140px;
    height: 49px;
    padding: 6px 8px;
  }
  .medal-badge .medal-icon {
    font-size: 20px;
  }
  .medal-badge .medal-tier {
    font-size: 14px;
  }
  .medal-badge .medal-label {
    font-size: 10px;
  }
}

@media (max-width: 360px) {
  .profile-ranks {
    flex-direction: column;
    align-items: center;
  }
  .rank-badge {
    width: 100%;
    max-width: 240px;
  }
  .medal-badge {
    width: 100%;
    max-width: 240px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .rank-badge {
    width: 150px;
    height: 110px;
  }
  .medal-badge {
    width: 150px;
    height: 49px;
  }
}
.skill {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
}
.skill-label {
  display: flex;
  align-items: center;
  gap: 4px;
}
.skill-label .icon img {
  width: 1em;
  height: 1em;
}
.skill-bar {
  position: relative;
  height: 16px;
  background: var(--panel-inner);
  border: 2px solid var(--panel-border);
  border-radius: 8px;
  overflow: hidden;
}
.skill-bar-fill {
  height: 100%;
  background: var(--highlight);
  transition: width 0.3s;
}
.skill-bar-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: bold;
  color: var(--text);
  text-shadow: 0 0 2px var(--panel-inner);
}

.invert {
  filter: invert(1);
}

:root[data-theme="light"] .invert-light {
  filter: invert(1);
}

:root[data-theme="dark"] .medal-badge .invert,
:root[data-theme="dark"]
  .rank-badge:not(.rank-1):not(.rank-2):not(.rank-3)
  .invert {
  filter: none;
}

/* Removed portrait-specific hiding of XP column to retain background */
