@import url("https://fonts.googleapis.com/css2?family=Baloo+2:wght@600;700;800&family=Nunito:wght@500;600;700;800;900&display=swap");

/* ------------------------------------------------------------------ tokens */
/* "paper" (stored theme value) is the default night-arena look; "classic" is the light look. */
:root {
  color-scheme: dark;
  --bg: #090e22;
  --bg-2: #141c44;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.11);
  --surface-solid: #151d45;
  --field: rgba(7, 11, 30, 0.55);
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.24);
  --text: #eef1ff;
  --muted: #a7b0da;
  --primary: #7c5cff;
  --primary-2: #4f7dff;
  --primary-edge: #4a2fc0;
  --gold: #ffcb3d;
  --gold-2: #ff9d1a;
  --gold-edge: #b8650a;
  --pink: #ff5fa2;
  --pink-2: #ff3d7f;
  --pink-edge: #b3245a;
  --teal: #1fd1b5;
  --teal-2: #0fa996;
  --teal-edge: #0a6e62;
  --blue: #3fa9ff;
  --blue-2: #2b6cf0;
  --blue-edge: #1a3fa3;
  --success: #2fd27a;
  --danger: #ff5b6b;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --glow-1: rgba(124, 92, 255, 0.45);
  --glow-2: rgba(31, 209, 181, 0.28);
  --glow-3: rgba(255, 95, 162, 0.3);
  --accent-text: var(--gold);
  --dot: rgba(255, 255, 255, 0.07);
  --display: "Baloo 2", "Nunito", system-ui, sans-serif;
  font-family: "Nunito", "Segoe UI", system-ui, sans-serif;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) {
  /* Light "candy" look: cream-pink background, lavender and mint accents, plum text.
     The match and result screens always use it so play stays bright in either theme. */
  color-scheme: light;
  --bg: #fff6fb;
  --bg-2: #ffe1f0;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-2: #ffffff;
  --surface-solid: #fffafd;
  --field: #fff7fb;
  --border: rgba(214, 120, 180, 0.2);
  --border-strong: rgba(170, 110, 200, 0.32);
  --text: #3a2958;
  --muted: #86739f;
  --accent-text: #e2477f;
  --primary: #8b6cff;
  --primary-2: #6f8dff;
  --primary-edge: #5b45c9;
  --shadow: 0 14px 34px rgba(214, 110, 170, 0.18), 0 2px 6px rgba(140, 90, 200, 0.08);
  --glow-1: rgba(190, 160, 255, 0.55);
  --glow-2: rgba(140, 236, 214, 0.5);
  --glow-3: rgba(255, 170, 205, 0.55);
  --dot: rgba(226, 71, 127, 0.1);
}

/* ------------------------------------------------------------------ base */
*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(1200px 600px at 10% -10%, var(--bg-2), transparent 60%) fixed, var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}
h1,
h2,
h3 {
  font-family: var(--display);
  line-height: 1.15;
  margin: 0 0 0.4em;
}
p {
  margin: 0 0 0.6em;
}
img {
  max-width: 100%;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
}
:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
a {
  color: inherit;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.muted {
  color: var(--muted);
}
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.backdrop i {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  filter: blur(80px);
  background: var(--glow-1);
  top: -18vmax;
  right: -12vmax;
  animation: drift 22s ease-in-out infinite alternate;
}
.backdrop i:nth-child(2) {
  background: var(--glow-2);
  top: auto;
  bottom: -20vmax;
  left: -14vmax;
  right: auto;
  animation-duration: 28s;
}
.backdrop i:nth-child(3) {
  background: var(--glow-3);
  width: 30vmax;
  height: 30vmax;
  top: 40%;
  left: 45%;
  animation-duration: 34s;
}
@keyframes drift {
  to {
    transform: translate(-6vmax, 5vmax) scale(1.08);
  }
}
.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* ------------------------------------------------------------------ buttons */
.btn,
button:not([class]),
.list button,
.invitation button {
  --top: var(--surface-2);
  --bottom: var(--surface);
  --edge: rgba(0, 0, 0, 0.35);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-height: 44px;
  padding: 0.6em 1.25em;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--top), var(--bottom));
  color: #fff;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  box-shadow:
    0 5px 0 var(--edge),
    0 10px 22px rgba(0, 0, 0, 0.25);
  transition:
    transform 0.08s ease,
    box-shadow 0.08s ease,
    filter 0.15s ease;
}
.btn:hover:not(:disabled),
button:not([class]):hover:not(:disabled) {
  filter: brightness(1.08);
}
.btn:active:not(:disabled),
button:not([class]):active:not(:disabled),
.list button:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 var(--edge),
    0 6px 14px rgba(0, 0, 0, 0.25);
}
.btn:disabled,
button:not([class]):disabled {
  opacity: 0.45;
  filter: grayscale(0.4);
}
.btn b {
  font-size: 1.2em;
  line-height: 1;
}
.btn-primary {
  --top: var(--primary);
  --bottom: var(--primary-2);
  --edge: var(--primary-edge);
}
.btn-gold {
  --top: var(--gold);
  --bottom: var(--gold-2);
  --edge: var(--gold-edge);
  color: #3a1d00;
}
.btn-pink {
  --top: var(--pink);
  --bottom: var(--pink-2);
  --edge: var(--pink-edge);
}
.btn-teal {
  --top: var(--teal);
  --bottom: var(--teal-2);
  --edge: var(--teal-edge);
  color: #032d27;
}
.btn-secondary,
button:not([class]),
.list button,
.invitation button {
  --top: var(--blue);
  --bottom: var(--blue-2);
  --edge: var(--blue-edge);
}
.btn-ghost {
  --top: var(--surface-2);
  --bottom: var(--surface);
  --edge: rgba(0, 0, 0, 0.3);
  color: var(--text);
  border-color: var(--border-strong);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .btn-ghost {
  --edge: rgba(30, 40, 90, 0.18);
}
.btn-danger {
  --top: #ff6b7a;
  --bottom: #e53950;
  --edge: #8f1a2b;
}
.btn-block {
  width: 100%;
}
.btn-wide {
  min-width: 220px;
}
.btn-small {
  min-height: 36px;
  padding: 0.35em 0.9em;
  font-size: 0.9rem;
}
.list button,
.invitation button {
  min-height: 34px;
  padding: 0.3em 0.85em;
  font-size: 0.88rem;
  box-shadow: 0 3px 0 var(--edge);
}
.link-button {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent-text);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.close-button {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
}
.close-button:hover {
  background: var(--danger);
  color: #fff;
}
.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.button-row.center {
  justify-content: center;
}
.button-column {
  display: grid;
  gap: 12px;
}

/* ------------------------------------------------------------------ forms */
.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.field > span {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
input:not([type="checkbox"]):not([type="range"]),
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.65em 0.9em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--field);
  color: var(--text);
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
textarea {
  resize: vertical;
}
select option {
  background: var(--surface-solid);
  color: var(--text);
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.35);
}
input::placeholder {
  color: var(--muted);
  opacity: 0.75;
}
input[type="date"] {
  color-scheme: inherit;
}
input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  flex: none;
}
input[type="range"] {
  accent-color: var(--gold);
  width: 100%;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}
.field-hint {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}
.form-status:empty {
  display: none;
}
.form-status {
  font-weight: 800;
  color: var(--success);
}
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.stack-form,
.inline-form {
  display: grid;
  gap: 12px;
}
.inline-form {
  grid-template-columns: 1fr auto;
  align-items: end;
}
#guildForm.inline-form {
  grid-template-columns: 1fr 120px auto;
}
.fold {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.fold summary {
  cursor: pointer;
  font-weight: 800;
}
.fold[open] {
  display: grid;
  gap: 12px;
}
.password-field {
  position: relative;
  display: block;
}
.password-field input {
  padding-right: 48px;
}
.reveal-password {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  opacity: 0.7;
}
.reveal-password[aria-pressed="true"] {
  opacity: 1;
  background: var(--surface-2);
}

/* ------------------------------------------------------------------ top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px clamp(12px, 3vw, 28px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.logo-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--gold), var(--pink) 55%, var(--primary));
  color: #fff;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.4rem;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
}
.small-brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, var(--gold), #fff 60%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .small-brand {
  background: linear-gradient(90deg, var(--primary), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
}
.chip-button {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}
.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 300px;
  padding: 5px 14px 5px 5px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  text-align: left;
}
.profile-chip:hover {
  background: var(--surface-2);
}
.profile-chip img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: block;
  object-fit: cover;
}
.profile-text {
  display: grid;
  min-width: 0;
  line-height: 1.2;
}
.profile-line {
  display: flex;
  gap: 6px;
  align-items: baseline;
  min-width: 0;
}
.profile-line strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#profileLevel {
  color: var(--accent-text);
  font-weight: 800;
  font-size: 0.82rem;
  white-space: nowrap;
}
.profile-chip .tier-badge {
  justify-self: start;
  margin: 2px 0;
}
.profile-chip small {
  color: var(--muted);
  font-size: 0.72rem;
}
.xp-track {
  display: block;
  height: 6px;
  border-radius: 6px;
  background: rgba(127, 127, 160, 0.25);
  overflow: hidden;
  margin: 3px 0;
}
.xp-track i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  transition: width 0.5s ease;
}
.status-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.icon-button {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.1rem;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}
.icon-button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}
.icon-button:hover {
  background: var(--primary);
  color: #fff;
}
.icon-button.gold {
  color: var(--accent-text);
}
.icon-button.gold:hover {
  background: var(--gold);
  color: #3a1d00;
}

/* ------------------------------------------------------------------ honor ticker */
.honor-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px clamp(12px, 3vw, 28px);
  background: linear-gradient(90deg, rgba(255, 203, 61, 0.14), transparent 70%);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.honor-bar > strong {
  flex: none;
  color: var(--accent-text);
  font-family: var(--display);
  letter-spacing: 0.04em;
}
.honor-window {
  position: relative;
  flex: 1;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.honor-bar #leaderboard {
  display: flex;
  width: max-content;
  animation: honor-enter var(--honor-duration, 45s) linear infinite;
}
.honor-window:hover #leaderboard {
  animation-play-state: paused;
}
.honor-group {
  display: flex;
  gap: 10px;
}
.honor-player {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.honor-player b {
  color: var(--accent-text);
}
.honor-player span {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.honor-player strong {
  color: var(--muted);
  font-weight: 700;
}
.honor-player.rank-1 {
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(255, 203, 61, 0.35);
}
@keyframes honor-enter {
  from {
    transform: translateX(var(--honor-start, 100vw));
  }
  to {
    transform: translateX(-100%);
  }
}

/* ------------------------------------------------------------------ layout */
main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 3vw, 30px) clamp(12px, 3vw, 28px) 110px;
}
.screen-title {
  margin: 4px 0 20px;
}
.screen-title h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin-bottom: 4px;
}
.screen-title p {
  color: var(--muted);
}
.panel {
  padding: clamp(16px, 2.5vw, 24px);
  display: grid;
  gap: 14px;
  align-content: start;
}
.panel h2 {
  font-size: 1.35rem;
  margin: 0;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

/* ------------------------------------------------------------------ auth */
.auth-screen {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: clamp(20px, 4vw, 48px);
  align-items: center;
  min-height: calc(100dvh - 190px);
}
.auth-hero {
  display: grid;
  gap: 18px;
  justify-items: start;
}
.brand-sign {
  display: grid;
  gap: 6px;
}
.brand-sign span {
  color: var(--accent-text);
  font-weight: 800;
  letter-spacing: 0.18em;
  font-size: 0.85rem;
}
.brand-sign h1 {
  font-size: clamp(3.4rem, 9vw, 6.2rem);
  line-height: 0.95;
  margin: 0;
  background: linear-gradient(100deg, #fff 10%, var(--gold) 45%, var(--pink) 75%, var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.3));
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .brand-sign h1 {
  background: linear-gradient(100deg, var(--primary), var(--pink) 60%, var(--gold-2));
  -webkit-background-clip: text;
  background-clip: text;
  filter: none;
}
.brand-sign small {
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.12em;
}
.site-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
}
.auth-art {
  width: min(420px, 80%);
  filter: drop-shadow(0 24px 40px rgba(0, 0, 0, 0.45));
  animation: float 6s ease-in-out infinite;
  border-radius: 28px;
}
@keyframes float {
  50% {
    transform: translateY(-12px);
  }
}
.auth-perks {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.auth-perks li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 700;
}
.auth-card {
  padding: clamp(20px, 3vw, 32px);
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 460px;
  justify-self: center;
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 5px;
  gap: 5px;
  border-radius: 16px;
  background: var(--field);
  border: 1px solid var(--border);
}
.auth-tab {
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1rem;
}
.auth-tab.active {
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 3px 0 var(--primary-edge);
}
.auth-title {
  font-size: 1.8rem;
  margin: 6px 0 0;
}
.auth-subtitle {
  color: var(--muted);
  margin: 0;
}
#authForm {
  display: grid;
  gap: 14px;
}
.register-fields {
  display: grid;
  gap: 14px;
}
.auth-switch {
  text-align: center;
  color: var(--muted);
  margin: 0;
}
#auth[data-mode="register"] .login-only,
#auth:not([data-mode="register"]) .register-only {
  display: none !important;
}

/* ------------------------------------------------------------------ home */
.home-screen {
  display: grid;
  gap: 22px;
}
.home-hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 20px;
  padding: clamp(20px, 4vw, 40px);
  overflow: hidden;
  background:
    radial-gradient(500px 260px at 85% 20%, rgba(255, 95, 162, 0.35), transparent 70%),
    radial-gradient(600px 300px at 10% 100%, rgba(124, 92, 255, 0.4), transparent 70%), var(--surface);
}
.eyebrow {
  color: var(--accent-text);
  font-weight: 800;
  letter-spacing: 0.16em;
  font-size: 0.8rem;
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  margin: 6px 0 8px;
}
.hero-copy p {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 520px;
}
.hero-rules {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.hero-rules span {
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--field);
  border: 1px solid var(--border);
  font-weight: 700;
  color: var(--muted);
}
.hero-rules b {
  color: var(--text);
  font-family: var(--display);
  margin-right: 4px;
}
.hero-mascot {
  width: clamp(130px, 18vw, 210px);
  border-radius: 50%;
  filter: drop-shadow(0 16px 30px rgba(0, 0, 0, 0.35));
  animation: float 5s ease-in-out infinite;
}
.mode-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.mode-tile {
  --accent: var(--primary);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
.mode-tile:hover {
  transform: translateY(-6px);
  box-shadow:
    0 24px 50px rgba(0, 0, 0, 0.45),
    0 0 0 2px var(--accent);
}
.mode-tile.pink {
  --accent: var(--pink);
}
.mode-tile.teal {
  --accent: var(--teal);
}
.tile-art {
  display: grid;
  place-items: center;
  height: 180px;
  background: radial-gradient(circle at 50% 60%, #fff 0 45%, color-mix(in srgb, var(--accent) 35%, #fff) 75%);
}
.tile-art img {
  height: 165px;
  object-fit: contain;
  transition: transform 0.25s ease;
}
.mode-tile:hover .tile-art img {
  transform: scale(1.06) rotate(-2deg);
}
.tile-body {
  display: grid;
  gap: 8px;
  padding: 18px;
  align-content: start;
}
.tile-body h2 {
  font-size: 1.35rem;
  margin: 0;
}
.tile-body p {
  color: var(--muted);
  min-height: 3em;
}
.home-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ------------------------------------------------------------------ topics */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.topic-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 6px;
  padding: 14px;
  text-align: left;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  transition:
    transform 0.15s ease,
    border-color 0.15s ease;
}
.topic-card:hover:not(:disabled) {
  transform: translateY(-4px);
  border-color: var(--primary);
}
.topic-art {
  display: grid;
  place-items: center;
  height: 110px;
  border-radius: 14px;
  font-size: 3.4rem;
  background:
    radial-gradient(circle at 30% 20%, hsl(var(--topic-hue, 255) 90% 75% / 0.9), transparent 55%),
    linear-gradient(135deg, hsl(var(--topic-hue, 255) 75% 55%), hsl(calc(var(--topic-hue, 255) + 40) 70% 38%));
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease;
}
.topic-card:hover:not(:disabled) .topic-art {
  transform: scale(1.03) rotate(-1deg);
}
.topic-card h2 {
  font-size: 1.15rem;
  margin: 6px 0 0;
}
.topic-card p {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0;
}
.topic-footer {
  font-weight: 800;
  font-size: 0.8rem;
  color: var(--teal);
}
.topic-card:disabled {
  opacity: 0.45;
}
.topic-card:disabled .topic-footer {
  color: var(--danger);
}
.selected-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--gold);
  color: #3a1d00;
  font-weight: 800;
  font-size: 0.75rem;
  opacity: 0;
  transform: scale(0.8);
  transition: 0.15s;
}
.topic-card.selected {
  border-color: var(--gold);
  box-shadow:
    0 0 0 3px rgba(255, 203, 61, 0.35),
    var(--shadow);
}
.topic-card.selected .selected-badge {
  opacity: 1;
  transform: scale(1);
}
.sticky-actions {
  position: sticky;
  bottom: 16px;
  display: flex;
  justify-content: center;
  margin-top: 22px;
  z-index: 5;
}

/* ------------------------------------------------------------------ lobby */
.lobby-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 20px;
  align-items: start;
}
.lobby-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--field);
}
.lobby-status p {
  margin: 0;
  font-weight: 800;
}
.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.lobby-status:has(#party[data-status="idle"]) .status-dot {
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}
.lobby-status:has(#party[data-status="queued"]) .status-dot {
  background: var(--gold);
  animation: pulse 1s ease-in-out infinite;
}
.lobby-status:has(#party[data-status="matched"]) .status-dot {
  background: var(--pink);
}
@keyframes pulse {
  50% {
    transform: scale(1.5);
    opacity: 0.6;
  }
}
.party-members {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.member-chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 700;
}
.queue-status:empty {
  display: none;
}
.queue-status {
  color: var(--accent-text);
  font-weight: 800;
  margin: 0;
}
.invite-form {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.invitation:empty {
  display: none;
}
.invitation {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 203, 61, 0.15);
  border: 1px solid var(--gold);
  font-weight: 800;
}
.private-room {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.22), rgba(255, 95, 162, 0.15));
  border: 1px solid var(--border-strong);
}
.private-room h3 {
  margin: 0;
}
.private-room p {
  color: var(--muted);
  margin: 0;
}
.duel-friend-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}
.room-code input {
  font-family: var(--display);
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  text-align: center;
}
.button-row.wrap .btn {
  flex: 1 1 auto;
}
/* A private 1v1 room has no team to build: team controls and the fixed mode/opponent hide. */
.lobby-screen.is-private :is(.party-actions, #inviteForm, #partyMembers),
.lobby-screen.is-private #queueForm label:has(#mode),
.lobby-screen.is-private #queueForm label:has(#opponent) {
  display: none;
}
.lobby-screen.is-private .field-grid {
  opacity: 0.8;
}

/* ------------------------------------------------------------------ arena */
.game-screen {
  position: relative;
  display: grid;
  gap: 14px;
  max-width: 920px;
  margin: 0 auto;
}
.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
}
.team {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.team-b {
  justify-content: flex-end;
  text-align: right;
}
.team .avatar img {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 3px solid var(--primary);
}
.team-b .avatar img {
  border-color: var(--pink);
}
.team-info {
  display: grid;
  min-width: 0;
}
.team-info span {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.team-info strong {
  font-family: var(--display);
  font-size: 2rem;
  line-height: 1;
}
.team-a .team-info strong {
  color: var(--blue);
}
.team-b .team-info strong {
  color: var(--pink);
}
.team-info small {
  font-weight: 800;
  min-height: 1.2em;
}
.good {
  color: var(--success) !important;
}
.bad {
  color: var(--danger) !important;
}
.versus {
  display: grid;
  justify-items: center;
  gap: 2px;
  text-align: center;
}
.versus small {
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
}
.timer {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.4rem;
  background: radial-gradient(circle, var(--surface-solid) 60%, transparent 62%),
    conic-gradient(var(--gold), var(--pink), var(--primary), var(--gold));
}
.match-kind {
  color: var(--accent-text) !important;
}
.time-track {
  height: 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
#timeBar {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--danger), var(--gold) 35%, var(--success));
  transition: width 0.1s linear;
}
.question-card {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: clamp(18px, 3vw, 30px);
  text-align: center;
  min-height: 130px;
  align-content: center;
}
#question {
  font-size: clamp(1.25rem, 3vw, 1.9rem);
  margin: 0;
  overflow-wrap: anywhere;
}
.question-media {
  max-width: min(100%, 360px);
  max-height: 210px;
  border-radius: 16px;
  background: #fff;
  padding: 6px;
  object-fit: contain;
}
.answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
#answers button {
  position: relative;
  overflow: hidden;
  --c: var(--danger);
  --edge: #8f1a2b;
  justify-content: center;
  text-align: center;
  white-space: normal;
  font-family: var(--display);
  min-height: 74px;
  padding: 14px 18px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 92%, #fff), var(--c));
  color: #fff;
  font-weight: 800;
  font-size: 1.08rem;
  text-align: left;
  box-shadow:
    0 6px 0 var(--edge),
    0 12px 24px rgba(0, 0, 0, 0.3);
  transition:
    transform 0.08s,
    box-shadow 0.08s,
    opacity 0.2s,
    filter 0.2s;
  overflow-wrap: anywhere;
}
#answers button:nth-child(2) {
  --c: var(--blue-2);
  --edge: var(--blue-edge);
}
#answers button:nth-child(3) {
  --c: #f0a500;
  --edge: #8a5b00;
}
#answers button:nth-child(4) {
  --c: #1fa968;
  --edge: #0d6339;
}
#answers button:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-2px);
}
#answers button:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--edge);
}
#answers button:disabled {
  opacity: 0.55;
  cursor: default;
}
#answers button.correct {
  opacity: 1;
  outline: 4px solid #fff;
  box-shadow:
    0 0 0 8px rgba(47, 210, 122, 0.55),
    0 6px 0 var(--edge);
  animation: correct-pop 0.5s ease;
}
@keyframes correct-pop {
  40% {
    transform: scale(1.04);
  }
}
#feedback {
  min-height: 1.6em;
  text-align: center;
  font-weight: 800;
  font-size: 1.05rem;
  margin: 0;
}
.game-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.answer-shortcuts {
  color: var(--muted);
}
.emote-controls {
  position: relative;
}
.emote-picker {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 20;
  width: min(300px, 86vw);
  padding: 14px;
  display: grid;
  gap: 10px;
  background: var(--surface-solid);
}
.emote-picker-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.emote-picker small {
  color: var(--muted);
}
.emote-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.emote-choice {
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}
.emote-display {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 40;
  pointer-events: none;
}
.emote-bubble {
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--surface-solid);
  border: 2px solid var(--gold);
  font-weight: 800;
  box-shadow: var(--shadow);
  animation: emote-pop 2.5s ease forwards;
}
@keyframes emote-pop {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.8);
  }
  15% {
    opacity: 1;
    transform: translateY(0) scale(1.05);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-30px);
  }
}
.start-countdown {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  text-align: center;
  background: radial-gradient(circle, rgba(124, 92, 255, 0.45), rgba(5, 8, 22, 0.88) 60%);
  backdrop-filter: blur(6px);
  color: #fff;
}
.start-countdown span {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--accent-text);
}
.start-countdown strong {
  font-family: var(--display);
  font-size: clamp(6rem, 22vw, 12rem);
  line-height: 1;
  text-shadow: 0 10px 0 rgba(0, 0, 0, 0.35);
}
.start-countdown small {
  color: #c9cff5;
  font-weight: 700;
}
.countdown-pop {
  animation: countdown-pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes countdown-pop {
  from {
    transform: scale(2.2);
    opacity: 0;
  }
}

/* ------------------------------------------------------------------ result */
.result-screen {
  display: grid;
  gap: 18px;
}
.result-title {
  text-align: center;
}
.result-title h1 {
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  background: linear-gradient(90deg, var(--gold), #fff, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .result-title h1 {
  background: linear-gradient(90deg, var(--gold-2), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
}
.result-duel {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: stretch;
}
.result-vs {
  align-self: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: 2rem;
  color: var(--accent-text);
}
.result-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 28px 18px 18px;
  text-align: center;
}
.result-card > img {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--primary);
}
#resultB > img {
  border-color: var(--pink);
}
.result-card h2 {
  font-size: 1.2rem;
  margin: 0;
  overflow-wrap: anywhere;
}
.result-score {
  margin: 0;
}
.result-score strong {
  font-family: var(--display);
  font-size: 2.8rem;
  line-height: 1;
  margin-right: 6px;
}
.result-score span {
  color: var(--muted);
}
.winner-ribbon {
  position: absolute;
  top: -14px;
  padding: 5px 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  color: #3a1d00;
  font-family: var(--display);
  font-weight: 800;
  box-shadow: 0 4px 0 var(--gold-edge);
}
.result-card:has(.winner-ribbon:not([hidden])) {
  border-color: var(--gold);
  box-shadow:
    0 0 0 2px rgba(255, 203, 61, 0.45),
    0 0 40px rgba(255, 203, 61, 0.25),
    var(--shadow);
}
.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}
.metrics > div {
  display: grid;
  gap: 2px;
  padding: 10px;
  border-radius: 14px;
  background: var(--field);
  border: 1px solid var(--border);
  text-align: left;
}
.metrics strong {
  font-family: var(--display);
  font-size: 1.2rem;
}
.metric-caption {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}
.metric-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  color: #fff;
  background: var(--primary);
}
.metric-icon svg {
  width: 15px;
  height: 15px;
}
.metric-icon.xp {
  background: var(--gold-2);
}
.metric-icon.gold {
  background: #d99a00;
}
.metric-icon.elo {
  background: var(--teal-2);
}
.settlement {
  text-align: center;
  font-weight: 800;
  margin: 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}
.rank-change {
  color: var(--accent-text);
  border-color: var(--gold);
}

/* ------------------------------------------------------------------ lists */
.list {
  display: grid;
  gap: 8px;
}
.entry {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--field);
  border: 1px solid var(--border);
}
.entry > span {
  flex: 1 1 180px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.friend-code-line strong {
  font-family: var(--display);
  font-size: 1.3rem;
  color: var(--accent-text);
  letter-spacing: 0.08em;
}

/* ------------------------------------------------------------------ tiers */
[data-tier] {
  --tier: #8c8170;
  --tier-2: #c9bfae;
}
[data-tier="bronze"] {
  --tier: #b86d33;
  --tier-2: #e8a86f;
}
[data-tier="silver"] {
  --tier: #8796a4;
  --tier-2: #e3eaf0;
}
[data-tier="gold"] {
  --tier: #d6a20e;
  --tier-2: #ffe28a;
}
[data-tier="platinum"] {
  --tier: #2fb3a7;
  --tier-2: #a7f0e6;
}
[data-tier="diamond"] {
  --tier: #4b7ff0;
  --tier-2: #b9d2ff;
}
[data-tier="master"] {
  --tier: #9a4fe0;
  --tier-2: #e3c2ff;
}
[data-tier="tier_all"] {
  --tier: #e2336f;
  --tier-2: #ffd43b;
}
@property --tier-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
.tier-frame {
  display: inline-grid;
  place-items: center;
  flex: none;
  padding: 3px;
  border-radius: 50%;
  background: conic-gradient(var(--tier), var(--tier-2), var(--tier));
}
.tier-frame:is([data-tier="platinum"], [data-tier="diamond"], [data-tier="master"], [data-tier="tier_all"]) {
  background: conic-gradient(from var(--tier-angle), var(--tier), var(--tier-2), var(--tier), var(--tier-2), var(--tier));
  animation: tier-spin 4s linear infinite;
  box-shadow: 0 0 12px var(--tier-2);
}
.tier-frame[data-tier="tier_all"] {
  animation-duration: 2.2s;
  box-shadow:
    0 0 14px var(--tier-2),
    0 0 26px var(--tier);
}
@keyframes tier-spin {
  to {
    --tier-angle: 360deg;
  }
}
.tier-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--tier);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 900;
  white-space: nowrap;
}
.rank-card {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--tier, var(--border));
  background: linear-gradient(135deg, color-mix(in srgb, var(--tier-2, #fff) 18%, transparent), transparent);
}
.rank-card strong {
  font-family: var(--display);
  font-size: 1.35rem;
  color: var(--tier-2, var(--gold));
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .rank-card strong {
  color: var(--tier, var(--primary));
}
.rank-card span,
.rank-card small {
  color: var(--muted);
}
.rank-card .xp-track i {
  background: linear-gradient(90deg, var(--tier), var(--tier-2));
}

/* ------------------------------------------------------------------ dialogs */
.modal {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: clamp(18px, 3vw, 28px);
  border-radius: 24px;
  border: 1px solid var(--border-strong);
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.55);
}
.modal[open] {
  animation: modal-in 0.22s cubic-bezier(0.2, 1.3, 0.4, 1);
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
}
.modal::backdrop {
  background: rgba(4, 6, 18, 0.7);
  backdrop-filter: blur(5px);
}
.small-modal {
  width: min(460px, calc(100vw - 24px));
  display: grid;
  gap: 12px;
}
.small-modal:not([open]),
.modal:not([open]) {
  display: none;
}
.dialog-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.dialog-heading h2 {
  margin: 0;
  flex: 1;
  font-size: 1.5rem;
}
.mode-dialog {
  width: min(1060px, calc(100vw - 24px));
}
.mode-count {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 800;
  font-size: 0.8rem;
}
.mode-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}
.mode-card {
  --accent: var(--primary);
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 6px;
  padding: 12px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
}
.mode-card.pink {
  --accent: var(--pink);
}
.mode-card.teal {
  --accent: var(--teal);
}
.mode-card.gold {
  --accent: var(--gold);
}
.mode-card.blue {
  --accent: var(--blue);
}
.mode-card small {
  justify-self: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: #10132b;
  font-weight: 900;
  font-size: 0.7rem;
}
.mode-card img {
  height: 110px;
  width: 100%;
  object-fit: contain;
  border-radius: 14px;
  background: radial-gradient(circle, #fff 55%, color-mix(in srgb, var(--accent) 30%, #fff));
}
.mode-card h3 {
  font-size: 1.1rem;
  margin: 4px 0 0;
}
.mode-card p {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0;
}
.settings-dialog {
  width: min(620px, calc(100vw - 24px));
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row h3 {
  font-size: 1.05rem;
  margin: 0;
}
.settings-row p {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}
.slider-row label {
  flex: 0 0 160px;
  font-weight: 700;
}
.slider-row output {
  flex: 0 0 46px;
  text-align: right;
  font-weight: 800;
}
.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: 14px;
  background: var(--field);
  border: 1px solid var(--border);
  flex: none;
}
.segmented button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}
.segmented button.selected {
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  color: #fff;
}
#doneSettings {
  margin-top: 16px;
}
#settingsSaved {
  margin: 12px 0 0;
}

/* ranking */
.ranking-dialog {
  width: min(820px, calc(100vw - 24px));
}
.rank-intro {
  color: var(--muted);
}
.rank-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.rank-tabs button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
}
.rank-tabs button.selected {
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  color: #3a1d00;
  border-color: transparent;
}
.rank-bracket {
  max-width: 320px;
  margin-bottom: 12px;
}
#rankStatus:empty {
  display: none;
}
#rankStatus {
  color: var(--muted);
  text-align: center;
}
.rank-podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
.podium-card {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 14px 10px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
}
.podium-card.podium-1 {
  padding-top: 26px;
  background: linear-gradient(180deg, rgba(255, 203, 61, 0.28), var(--surface));
  border-color: var(--gold);
}
.podium-medal {
  font-size: 1.8rem;
  line-height: 1;
}
.podium-card img,
.rank-row img {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
}
.podium-card b {
  overflow-wrap: anywhere;
}
.podium-card small,
.rank-row small {
  color: var(--muted);
}
.podium-card[data-tier] small,
.rank-row[data-tier] small {
  color: var(--tier-2);
  font-weight: 800;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .podium-card[data-tier] small,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .rank-row[data-tier] small {
  color: var(--tier);
}
.podium-card strong {
  font-family: var(--display);
  color: var(--accent-text);
}
.rank-list {
  display: grid;
  gap: 8px;
}
.rank-columns {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 0 12px;
  white-space: pre;
}
.rank-row,
.rank-history {
  display: grid;
  grid-template-columns: 60px 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.rank-row img {
  width: 40px;
  height: 40px;
}
.rank-row > div {
  display: grid;
  min-width: 0;
}
.rank-row > div b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rank-row strong {
  font-family: var(--display);
  color: var(--accent-text);
}
.rank-history {
  grid-template-columns: 1fr auto;
}
.rank-history small {
  grid-column: 1;
  color: var(--muted);
}
.rank-history span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.85rem;
}
.rank-history strong {
  grid-row: 1;
  grid-column: 2;
  font-family: var(--display);
  font-size: 1.2rem;
}

/* ------------------------------------------------------------------ toast & floating */
#message {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 80;
  display: none;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 20px;
  border-radius: 16px;
  background: var(--surface-solid);
  border: 1px solid var(--gold);
  color: var(--text);
  font-weight: 800;
  text-align: center;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
}
.waiting-button {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  color: #3a1d00;
  font-family: var(--display);
  font-weight: 800;
  box-shadow:
    0 5px 0 var(--gold-edge),
    0 10px 24px rgba(0, 0, 0, 0.35);
  animation: pulse-soft 1.6s ease-in-out infinite;
}
@keyframes pulse-soft {
  50% {
    transform: scale(1.05);
  }
}

/* ------------------------------------------------------------------ view-specific chrome */
body:not([data-view]) .honor-bar {
  border-bottom: 0;
}
body[data-view="arena"] .honor-bar {
  display: none;
}

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1000px) {
  .mode-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .mode-tiles {
    grid-template-columns: 1fr;
  }
  .mode-tile {
    grid-template-columns: 200px 1fr;
    grid-template-rows: none;
  }
  .tile-art {
    height: 100%;
    min-height: 160px;
  }
  .tile-body p {
    min-height: 0;
  }
}
@media (max-width: 820px) {
  .auth-screen {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .auth-hero {
    justify-items: center;
    text-align: center;
  }
  .brand-sign {
    justify-items: center;
  }
  .auth-art {
    width: 150px;
  }
  .auth-perks {
    justify-content: center;
  }
  .lobby-grid,
  .card-grid {
    grid-template-columns: 1fr;
  }
  .status-pill {
    display: none;
  }
}
@media (max-width: 640px) {
  body {
    font-size: 14px;
  }
  /* On phones the sign-in form comes first; the decorative hero shrinks. */
  .auth-screen {
    gap: 14px;
  }
  .auth-art,
  .auth-perks {
    display: none;
  }
  .brand-sign h1 {
    font-size: 3rem;
  }
  .topbar {
    padding: 8px 10px;
    gap: 6px;
  }
  .small-brand {
    display: none;
  }
  .topbar-right {
    gap: 6px;
  }
  .icon-button {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }
  .profile-chip {
    max-width: 170px;
    padding-right: 10px;
  }
  .profile-chip small,
  .profile-chip .xp-track {
    display: none;
  }
  .honor-bar > strong {
    display: none;
  }
  .home-hero {
    grid-template-columns: 1fr;
  }
  .hero-mascot {
    display: none;
  }
  .mode-tile {
    grid-template-columns: 110px 1fr;
  }
  .tile-art img {
    height: 100px;
  }
  .tile-body {
    padding: 14px;
  }
  .mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .field-grid {
    grid-template-columns: 1fr;
  }
  .scoreboard {
    padding: 10px;
    gap: 6px;
  }
  .team .avatar {
    display: none;
  }
  .team-info strong {
    font-size: 1.6rem;
  }
  .timer {
    width: 54px;
    height: 54px;
    font-size: 1.15rem;
  }
  .answers {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  #answers button {
    min-height: 58px;
  }
  .answer-shortcuts {
    display: none;
  }
  .game-footer {
    justify-content: flex-end;
  }
  .result-duel {
    grid-template-columns: 1fr;
  }
  .result-vs {
    justify-self: center;
  }
  .rank-row {
    grid-template-columns: 44px 36px 1fr auto;
    gap: 8px;
  }
  .rank-podium {
    gap: 6px;
  }
  .settings-row {
    flex-wrap: wrap;
  }
  .slider-row label {
    flex-basis: 100%;
  }
  .inline-form,
  #guildForm.inline-form,
  .duel-friend-row {
    grid-template-columns: 1fr;
  }
  .btn-wide {
    min-width: 0;
    flex: 1 1 auto;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .honor-bar #leaderboard {
    animation: none;
  }
}

/* Segmented controls and tabs are flat: no 3D edge from the generic button style. */
.segmented button,
.rank-tabs button {
  box-shadow: none;
  font-family: var(--display);
  letter-spacing: 0;
}
.segmented button:active:not(:disabled),
.rank-tabs button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: none;
}
.rank-tabs button:not(.selected) {
  background: var(--surface);
}

/* ================================================================== cute layer */
/* Polka dots behind everything, floating sparkles (added by effects.js) and soft motion. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(var(--dot) 2px, transparent 2.5px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, #000, transparent 85%);
}
.floaty {
  position: absolute;
  bottom: -40px;
  color: var(--float-color, #fff);
  font-size: var(--float-size, 18px);
  opacity: 0;
  animation: floaty var(--float-time, 16s) linear var(--float-delay, 0s) infinite;
  text-shadow: 0 0 12px currentColor;
}
@keyframes floaty {
  0% {
    transform: translate(0, 0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: var(--float-alpha, 0.55);
  }
  50% {
    transform: translate(var(--float-sway, 30px), -55vh) rotate(180deg);
  }
  90% {
    opacity: var(--float-alpha, 0.55);
  }
  100% {
    transform: translate(0, -110vh) rotate(360deg);
    opacity: 0;
  }
}

/* Buttons: light sweep on hover and a squishy press. */
.btn {
  overflow: hidden;
  isolation: isolate;
  transition:
    transform 0.18s cubic-bezier(0.3, 1.6, 0.5, 1),
    box-shadow 0.12s ease,
    filter 0.15s ease;
}
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.45) 50%, transparent 70%);
  transform: translateX(-120%);
  pointer-events: none;
}
.btn:hover:not(:disabled)::after {
  transform: translateX(120%);
  transition: transform 0.7s ease;
}
.btn:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
}
.btn:active:not(:disabled) {
  transform: translateY(3px) scale(0.97);
}
.btn-primary,
.btn-pink,
.btn-teal,
.btn-gold {
  border-radius: 999px;
}
.ripple {
  position: absolute;
  z-index: 0;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  pointer-events: none;
  animation: ripple 0.6s ease-out forwards;
}
@keyframes ripple {
  to {
    transform: scale(28);
    opacity: 0;
  }
}

/* Screens slide up softly, children staggered. */
[data-panel]:not([hidden]) > *,
#auth:not([hidden]) > * {
  animation: rise-in 0.5s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}
[data-panel]:not([hidden]) > :nth-child(2),
#auth:not([hidden]) > :nth-child(2) {
  animation-delay: 0.07s;
}
[data-panel]:not([hidden]) > :nth-child(3) {
  animation-delay: 0.14s;
}
[data-panel]:not([hidden]) > :nth-child(n + 4) {
  animation-delay: 0.2s;
}
.mode-tiles > *,
.topic-grid > *,
.mode-grid > * {
  animation: rise-in 0.55s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}
.mode-tiles > :nth-child(2),
.topic-grid > :nth-child(2),
.mode-grid > :nth-child(2) {
  animation-delay: 0.06s;
}
.mode-tiles > :nth-child(3),
.topic-grid > :nth-child(3),
.mode-grid > :nth-child(3) {
  animation-delay: 0.12s;
}
.topic-grid > :nth-child(4),
.mode-grid > :nth-child(4) {
  animation-delay: 0.18s;
}
.topic-grid > :nth-child(n + 5),
.mode-grid > :nth-child(5) {
  animation-delay: 0.24s;
}
@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
}

/* Cards: jelly hover and a gentle 3D tilt driven by effects.js (--rx/--ry). */
.mode-tile,
.topic-card,
.mode-card {
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease,
    border-color 0.2s ease;
}
.mode-tile:hover,
.topic-card:hover:not(:disabled),
.mode-card:hover {
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-6px);
}
.mode-tile:hover .tile-art img,
.mode-card:hover img {
  animation: wiggle 0.6s ease;
}
.topic-card:hover:not(:disabled) .topic-art {
  animation: jelly 0.6s ease;
}
@keyframes wiggle {
  25% {
    transform: rotate(-4deg) scale(1.06);
  }
  60% {
    transform: rotate(3deg) scale(1.06);
  }
}
@keyframes jelly {
  30% {
    transform: scale(1.08, 0.92);
  }
  50% {
    transform: scale(0.95, 1.05);
  }
  70% {
    transform: scale(1.03, 0.97);
  }
}
.logo-mark {
  animation: logo-bob 4s ease-in-out infinite;
}
@keyframes logo-bob {
  0%,
  80%,
  100% {
    transform: rotate(0);
  }
  85% {
    transform: rotate(-10deg) scale(1.08);
  }
  92% {
    transform: rotate(8deg) scale(1.08);
  }
}
.hero-mascot,
.auth-art {
  transform-origin: 50% 90%;
  animation: sway 5s ease-in-out infinite;
}
@keyframes sway {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-12px) rotate(2deg);
  }
}

.hero-mascot {
  border-radius: 0;
}

/* Arena feedback. */
.timer.urgent {
  color: #fff;
  background:
    radial-gradient(circle, var(--danger) 60%, transparent 62%),
    conic-gradient(var(--danger), #ffb0b8, var(--danger));
  animation: urgent 0.5s ease-in-out infinite;
}
@keyframes urgent {
  50% {
    transform: scale(1.12) rotate(-4deg);
  }
}
.bump {
  display: inline-block;
  animation: bump 0.5s cubic-bezier(0.2, 1.8, 0.4, 1);
}
@keyframes bump {
  40% {
    transform: scale(1.45);
  }
}
#answers button.shake {
  animation: shake 0.45s ease;
}
@keyframes shake {
  20%,
  60% {
    transform: translateX(-8px) rotate(-1deg);
  }
  40%,
  80% {
    transform: translateX(8px) rotate(1deg);
  }
}
#feedback.good,
#feedback.bad {
  animation: rise-in 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.fx-layer {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  overflow: hidden;
}
.fx-spark {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 18px;
  line-height: 1;
  will-change: transform, opacity;
}
.fx-confetti {
  position: fixed;
  inset: 0;
  z-index: 95;
  pointer-events: none;
}

/* Result: the winner card floats and the ribbon shimmers. */
.result-title h1 {
  animation: title-pop 0.7s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
@keyframes title-pop {
  from {
    transform: scale(0.4) rotate(-6deg);
    opacity: 0;
  }
}
.result-card:has(.winner-ribbon:not([hidden])) {
  animation: winner-float 3s ease-in-out infinite;
}
@keyframes winner-float {
  50% {
    transform: translateY(-8px);
  }
}
.winner-ribbon {
  overflow: hidden;
}
.winner-ribbon::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, 0.7) 50%, transparent 65%);
  animation: shimmer 2.4s ease-in-out infinite;
}
@keyframes shimmer {
  from {
    transform: translateX(-120%);
  }
  60%,
  to {
    transform: translateX(120%);
  }
}
#message {
  animation: toast-bounce 0.45s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes toast-bounce {
  from {
    opacity: 0;
    transform: translate(-50%, 24px) scale(0.85);
  }
}

/* ------------------------------------------------------------------ light theme details */
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) {
  background:
    radial-gradient(900px 500px at 0% 0%, #ffe1f0, transparent 60%) fixed,
    radial-gradient(800px 500px at 100% 10%, #e7e0ff, transparent 60%) fixed,
    radial-gradient(900px 600px at 50% 110%, #d9f8ef, transparent 60%) fixed,
    var(--bg);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .topbar {
  background: rgba(255, 250, 253, 0.82);
  border-bottom-color: rgba(226, 71, 127, 0.12);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .honor-bar {
  background: linear-gradient(90deg, #ffe3ef, #f1eaff 70%, transparent);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .glass,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .mode-tile,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .topic-card,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .mode-card {
  border: 2px solid #fff;
  background: rgba(255, 255, 255, 0.86);
  box-shadow:
    var(--shadow),
    inset 0 -4px 0 rgba(226, 71, 127, 0.05);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .topic-card.selected {
  border-color: #ffb347;
  box-shadow:
    0 0 0 4px rgba(255, 179, 71, 0.3),
    var(--shadow);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .home-hero {
  background:
    radial-gradient(420px 240px at 88% 30%, #ffd2e6, transparent 70%),
    radial-gradient(520px 280px at 0% 100%, #e3dbff, transparent 70%),
    linear-gradient(135deg, #fffafd, #fff1f8);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .hero-rules span,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .auth-perks li,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .status-pill,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .honor-player,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .chip-button,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .member-chip {
  background: #fff;
  border-color: rgba(226, 71, 127, 0.18);
  box-shadow: 0 3px 10px rgba(214, 110, 170, 0.12);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .icon-button {
  background: #fff;
  color: #8b6cff;
  border-color: rgba(139, 108, 255, 0.25);
  box-shadow: 0 3px 0 rgba(139, 108, 255, 0.22);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .icon-button.gold {
  color: #f08a00;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .icon-button:hover {
  background: #8b6cff;
  color: #fff;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .auth-tabs,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .segmented {
  background: #f7eefb;
  border-color: rgba(170, 110, 200, 0.18);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .timer:not(.urgent) {
  background:
    radial-gradient(circle, #fff 60%, transparent 62%),
    conic-gradient(#ff8fbf, #8b6cff, #5fd8c0, #ff8fbf);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .time-track {
  background: #fff;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .question-card {
  background: linear-gradient(180deg, #fff, #fff6fb);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) #answers button {
  --c: #ff6f91;
  --edge: #d24470;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) #answers button:nth-child(2) {
  --c: #6f8dff;
  --edge: #4b61cf;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) #answers button:nth-child(3) {
  --c: #ffa53a;
  --edge: #c9761a;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) #answers button:nth-child(4) {
  --c: #33c495;
  --edge: #1f8d69;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .team-a .team-info strong {
  color: #6f8dff;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .team-b .team-info strong {
  color: #ff5c95;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .metrics > div,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .entry,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .lobby-status,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .rank-row,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .rank-history,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .podium-card {
  background: #fff8fc;
  border-color: rgba(226, 71, 127, 0.14);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .podium-card.podium-1 {
  background: linear-gradient(180deg, #fff1c9, #fff8fc);
  border-color: #ffc94d;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .result-vs {
  color: #ff8fbf;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .modal {
  background: linear-gradient(180deg, #fffafd, #fff3f9);
  border: 2px solid #fff;
  box-shadow: 0 40px 90px rgba(180, 90, 150, 0.3);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .modal::backdrop {
  background: rgba(120, 70, 130, 0.28);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .start-countdown {
  background: radial-gradient(circle, rgba(255, 190, 220, 0.9), rgba(150, 120, 230, 0.9) 70%);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .floaty {
  text-shadow: none;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .btn-ghost {
  background: #fff;
  border-color: rgba(170, 110, 200, 0.3);
  color: #6a4fbf;
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .private-room {
  background: linear-gradient(135deg, #f0eaff, #ffe8f2);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .tile-art {
  background: radial-gradient(circle at 50% 60%, #fff 0 45%, color-mix(in srgb, var(--accent) 22%, #fff) 80%);
}
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) .settlement,
body:is([data-theme="classic"], [data-view="arena"], [data-view="result"]) #message {
  background: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .floaty,
  .fx-layer,
  .fx-confetti {
    display: none;
  }
}

/* ================================================================== community: chat, guild, tournaments */
.chat-nav {
  position: relative;
}
.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface-solid);
  animation: bump 0.4s ease;
}
.badge.inline {
  position: static;
  box-shadow: none;
  flex: none;
}
.role-pill {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent-text);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.panel h3 {
  margin: 4px 0 0;
  font-size: 1.05rem;
}
.my-guild {
  grid-column: 1 / -1;
  background:
    radial-gradient(400px 200px at 100% 0%, rgba(255, 203, 61, 0.16), transparent 70%),
    var(--surface);
}

/* chat */
.chat-dialog {
  width: min(900px, calc(100vw - 24px));
  height: min(680px, calc(100dvh - 32px));
  display: none;
  flex-direction: column;
}
.chat-dialog[open] {
  display: flex;
}
.chat-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 14px;
}
.chat-list {
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 6px;
  padding-right: 4px;
}
#chatConversations {
  display: grid;
  gap: 6px;
}
.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--text);
  text-align: left;
}
.chat-item:hover,
.chat-item.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 14%, var(--field));
}
.chat-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--primary));
  color: #fff;
  font-family: var(--display);
  font-weight: 800;
}
.chat-avatar.guild {
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
}
.chat-item-body {
  display: grid;
  min-width: 0;
  flex: 1;
}
.chat-item-body strong,
.chat-item-body small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item-body small {
  color: var(--muted);
}
.chat-room {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--field);
  overflow: hidden;
}
.chat-room-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
#chatBack {
  display: none;
}
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
}
.chat-msg {
  align-self: flex-start;
  max-width: 78%;
  display: grid;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 16px 16px 16px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  animation: rise-in 0.25s ease;
}
.chat-msg.mine {
  align-self: flex-end;
  border-radius: 16px 16px 4px 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent;
  color: #fff;
}
.chat-msg p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-msg time {
  font-size: 0.68rem;
  opacity: 0.7;
  justify-self: end;
}
.chat-sender {
  font-weight: 800;
  color: var(--accent-text);
}
.chat-older {
  align-self: center;
}
.chat-empty {
  margin: auto;
  text-align: center;
}
.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
}
.chat-room .field-hint {
  padding: 0 12px 8px;
  font-size: 0.74rem;
}

/* tournaments */
.tournament-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.tournament-card {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--text);
  text-align: left;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease;
}
.tournament-card:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
}
.t-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.t-card-top strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.t-status {
  flex: none;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  color: #fff;
  background: var(--muted);
}
.t-status.open {
  background: var(--teal-2);
}
.t-status.live {
  background: var(--pink-2);
  animation: pulse-soft 1.6s ease-in-out infinite;
}
.t-status.done {
  background: var(--gold-2);
}
.t-champion {
  color: var(--accent-text);
  font-weight: 800;
}
.t-registered {
  color: var(--success);
  font-weight: 800;
}
.tournament-dialog {
  width: min(1000px, calc(100vw - 24px));
}
#tournamentBody {
  display: grid;
  gap: 14px;
}
#tournamentBody h3 {
  margin: 6px 0 0;
}
.t-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.t-champion-banner {
  display: grid;
  justify-items: center;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 203, 61, 0.35), rgba(255, 95, 162, 0.2));
  border: 2px solid var(--gold);
  text-align: center;
}
.t-champion-banner span {
  font-size: 2.2rem;
  animation: sway 3s ease-in-out infinite;
}
.t-champion-banner strong {
  font-family: var(--display);
  font-size: 1.6rem;
}
.t-info {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.t-info-item {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--field);
  border: 1px solid var(--border);
}
.t-info-item small {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.t-text p {
  margin: 4px 0 0;
  white-space: pre-wrap;
  color: var(--muted);
}
.t-actions .btn {
  flex: 0 0 auto;
}
.t-my-match {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: 18px;
  border: 2px solid var(--pink);
  background: color-mix(in srgb, var(--pink) 12%, var(--surface));
}
.bracket {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.bracket-round {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 10px;
}
.bracket-round h4 {
  margin: 0;
  text-align: center;
  font-family: var(--display);
  color: var(--accent-text);
  letter-spacing: 0.04em;
}
.t-match {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 14px;
  background: var(--field);
  border: 1px solid var(--border);
}
.t-match.live {
  border-color: var(--pink);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--pink) 35%, transparent);
}
.t-player {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 8px;
}
.t-player span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.t-player.won {
  background: color-mix(in srgb, var(--success) 20%, transparent);
  font-weight: 900;
}
.t-player.me span::after {
  content: " (bạn)";
  color: var(--accent-text);
  font-size: 0.8em;
}
:lang(en) .t-player.me span::after {
  content: " (you)";
}
:lang(zh) .t-player.me span::after {
  content: "（你）";
}
.t-match-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}
.t-match-foot .chip-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.78rem;
}
.chip-button.danger {
  color: var(--danger);
}
.t-live {
  color: var(--pink);
  font-weight: 900;
  font-size: 0.8rem;
  animation: pulse-soft 1.4s ease-in-out infinite;
}
.t-waiting {
  text-align: center;
}
.t-players {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.t-player-chip {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--field);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.86rem;
}
.t-player-chip.out {
  opacity: 0.55;
}
.t-player-chip.champion {
  border-color: var(--gold);
  color: var(--accent-text);
}

/* spectator link in the private room */
.watch-share {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--gold);
  background: color-mix(in srgb, var(--gold) 10%, transparent);
}

/* ================================================================== spectator page */
.watch-main {
  width: min(960px, 100%);
}
.watch-head {
  text-align: center;
  margin-bottom: 18px;
}
.watch-head h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin: 4px 0;
}
.live-pill {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-weight: 900;
  font-size: 0.8rem;
  animation: pulse-soft 1.6s ease-in-out infinite;
}
.live-pill.off {
  background: var(--muted);
  animation: none;
}
.lang-select {
  width: auto !important;
  min-height: 38px !important;
  padding: 0 10px !important;
  border-radius: 12px !important;
}
.watch-answers .watch-answer {
  --c: #ff6f91;
  --edge: #d24470;
  display: grid;
  place-items: center;
  min-height: 70px;
  padding: 12px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 90%, #fff), var(--c));
  color: #fff;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.08rem;
  text-align: center;
  box-shadow: 0 6px 0 var(--edge);
  overflow-wrap: anywhere;
  transition:
    opacity 0.3s,
    transform 0.3s;
}
.watch-answers .watch-answer:nth-child(2) {
  --c: #6f8dff;
  --edge: #4b61cf;
}
.watch-answers .watch-answer:nth-child(3) {
  --c: #ffa53a;
  --edge: #c9761a;
}
.watch-answers .watch-answer:nth-child(4) {
  --c: #33c495;
  --edge: #1f8d69;
}
.watch-answer.correct {
  outline: 4px solid #fff;
  box-shadow:
    0 0 0 8px rgba(47, 210, 122, 0.55),
    0 6px 0 var(--edge);
  animation: correct-pop 0.5s ease;
}
.watch-answer.dim {
  opacity: 0.4;
  transform: scale(0.97);
}
#wFeedback {
  min-height: 1.6em;
  text-align: center;
  font-weight: 800;
}
.watch-waiting,
.watch-result {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 30px 20px;
  text-align: center;
}
.watch-waiting img {
  width: 170px;
  animation: sway 5s ease-in-out infinite;
}
.watch-final {
  display: grid;
  grid-template-columns: minmax(0, 220px) auto minmax(0, 220px);
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
}
.watch-final > b {
  font-family: var(--display);
  color: var(--accent-text);
  font-size: 1.6rem;
}
.watch-final-team {
  display: grid;
  justify-items: center;
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: center;
  padding: 16px 20px;
  border-radius: 18px;
  background: var(--field);
  border: 2px solid var(--border);
}
.watch-final-team strong {
  font-family: var(--display);
  font-size: 2.6rem;
  line-height: 1;
}
.watch-final-team.won {
  border-color: var(--gold);
  box-shadow: 0 0 30px rgba(255, 203, 61, 0.35);
  animation: winner-float 3s ease-in-out infinite;
}

@media (max-width: 720px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }
  .chat-layout[data-pane="list"] .chat-room,
  .chat-layout[data-pane="room"] .chat-list {
    display: none;
  }
  #chatBack {
    display: inline-flex;
  }
  .chat-msg {
    max-width: 88%;
  }
  .watch-page .topbar-right .status-pill {
    display: inline-block;
  }
  .watch-page #playLink {
    display: none;
  }
}

/* Narrow phones: the sound switch stays in Settings so the top bar fits. */
@media (max-width: 480px) {
  #soundToggle {
    display: none;
  }
  .topbar-right {
    gap: 5px;
  }
  .topbar .icon-button {
    width: 36px;
    height: 36px;
  }
  .profile-chip {
    max-width: 150px;
  }
}

/* ================================================================== voice calls */
.chat-room-head #chatCall {
  margin-left: auto;
}
.call-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 85;
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(380px, calc(100vw - 24px));
  padding: 14px 16px;
  border-radius: 22px;
  background: var(--surface-solid);
  border: 2px solid var(--teal);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  animation: toast-bounce 0.4s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.call-panel[data-state="ended"] {
  border-color: var(--border-strong);
  opacity: 0.92;
}
.call-avatar {
  position: relative;
  flex: none;
  width: 56px;
  height: 56px;
}
.call-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.call-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid var(--teal);
  opacity: 0;
}
.call-panel:is([data-state="ringing"], [data-state="calling"]) .call-ring {
  animation: call-ring 1.4s ease-out infinite;
}
.call-panel[data-state="live"] .call-ring {
  opacity: 1;
  border-color: var(--success);
}
@keyframes call-ring {
  from {
    transform: scale(0.9);
    opacity: 0.9;
  }
  to {
    transform: scale(1.5);
    opacity: 0;
  }
}
.call-info {
  display: grid;
  flex: 1;
  min-width: 0;
}
.call-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--display);
  font-size: 1.1rem;
}
.call-info span {
  color: var(--muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.call-actions {
  display: flex;
  gap: 8px;
}
.call-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  background: var(--surface-2);
  font-size: 1.3rem;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}
.call-btn.accept {
  background: var(--success);
  animation: call-glow 1.2s ease-in-out infinite;
}
@keyframes call-glow {
  50% {
    box-shadow:
      0 0 0 8px rgba(47, 210, 122, 0.35),
      0 4px 0 rgba(0, 0, 0, 0.25);
  }
}
.call-btn.end {
  background: var(--danger);
}
.call-btn[aria-pressed="true"] {
  background: var(--gold);
}
.chat-msg {
  position: relative;
}
.chat-report {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-solid);
  color: var(--danger);
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.chat-msg:hover .chat-report,
.chat-report:focus-visible {
  opacity: 1;
}
.chat-report:disabled {
  opacity: 0.4;
}
@media (hover: none) {
  .chat-report {
    opacity: 0.6;
  }
}
@media (max-width: 480px) {
  .call-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 12px;
  }
}

/* Features closed in xpanel (Chat & gọi thoại) disappear everywhere they are offered. */
body[data-chat-guild="off"] .needs-chat-guild,
body[data-chat-direct="off"] .needs-chat-direct,
body[data-calls-friends="off"] .needs-calls-friends,
body[data-calls-guild="off"] .needs-calls-guild {
  display: none !important;
}

/* ================================================================== decorations */
/* Frames bought in the shop: an animated ring around any avatar wrapper with data-deco. */
[data-deco] {
  display: inline-grid;
  place-items: center;
  flex: none;
  padding: 4px;
  border-radius: 50%;
  background: conic-gradient(from var(--tier-angle), var(--d1), var(--d2), var(--d3), var(--d1));
  animation: tier-spin var(--deco-speed, 4s) linear infinite;
  box-shadow: 0 0 14px var(--deco-glow, transparent);
}
[data-deco] img {
  border-radius: 50%;
  display: block;
}
.tier-frame[data-deco],
.avatar[data-deco],
.result-avatar[data-deco] {
  background: conic-gradient(from var(--tier-angle), var(--d1), var(--d2), var(--d3), var(--d1));
}
[data-deco="frame-rainbow"] {
  --d1: #ff5f6d;
  --d2: #ffd166;
  --d3: #5ce1e6;
  background: conic-gradient(from var(--tier-angle), #ff5f6d, #ffc371, #f9f871, #5ce1e6, #8e7dff, #ff5f6d) !important;
  --deco-speed: 3s;
}
[data-deco="frame-sakura"] {
  --d1: #ffb7d5;
  --d2: #ffffff;
  --d3: #ff6fa8;
  --deco-glow: rgba(255, 111, 168, 0.55);
  --deco-speed: 6s;
}
[data-deco="frame-ocean"] {
  --d1: #00c6ff;
  --d2: #0072ff;
  --d3: #6ef0e0;
  --deco-glow: rgba(0, 170, 255, 0.5);
  --deco-speed: 5s;
}
[data-deco="frame-flame"] {
  --d1: #ffd000;
  --d2: #ff6a00;
  --d3: #ff1e56;
  --deco-glow: rgba(255, 106, 0, 0.7);
  --deco-speed: 1.6s;
  animation:
    tier-spin 1.6s linear infinite,
    flame-flicker 0.9s ease-in-out infinite alternate;
}
@keyframes flame-flicker {
  to {
    box-shadow:
      0 0 22px rgba(255, 106, 0, 0.85),
      0 -4px 18px rgba(255, 208, 0, 0.6);
  }
}
[data-deco="frame-galaxy"] {
  --d1: #2b1055;
  --d2: #c471f5;
  --d3: #5f9cff;
  --deco-glow: rgba(196, 113, 245, 0.7);
  --deco-speed: 7s;
  position: relative;
}
[data-deco="frame-galaxy"]::after {
  content: "✦";
  position: absolute;
  top: -4px;
  right: -2px;
  color: #fff;
  font-size: 0.8em;
  text-shadow: 0 0 6px #c471f5;
  animation: twinkle 1.6s ease-in-out infinite;
}
@keyframes twinkle {
  50% {
    opacity: 0.2;
    transform: scale(0.6);
  }
}
[data-deco="frame-gold"] {
  --d1: #fff1a8;
  --d2: #ffc83d;
  --d3: #b8860b;
  --deco-glow: rgba(255, 200, 61, 0.9);
  --deco-speed: 2.4s;
  box-shadow:
    0 0 18px rgba(255, 200, 61, 0.9),
    0 0 36px rgba(255, 160, 0, 0.45);
}

/* Titles: a gradient badge under the player's name. */
.badge-line {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}
.title-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: linear-gradient(90deg, #8b6cff, #ff6f91);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}
.title-badge[data-title-style="title-mint"] {
  background: linear-gradient(90deg, #1fd1b5, #6be3a0);
  color: #053b31;
}
.title-badge[data-title-style="title-sky"] {
  background: linear-gradient(90deg, #3fa9ff, #6fd3ff);
}
.title-badge[data-title-style="title-violet"] {
  background: linear-gradient(90deg, #7c5cff, #c471f5);
}
.title-badge[data-title-style="title-sunset"] {
  background: linear-gradient(90deg, #ff6a3d, #ff3d7f, #b84dff);
}
.title-badge[data-title-style="title-gold"] {
  background: linear-gradient(90deg, #b8860b, #ffd700, #fff3b0, #ffd700, #b8860b);
  background-size: 200% 100%;
  color: #3a2400;
  animation: title-shine 2.5s linear infinite;
}
@keyframes title-shine {
  to {
    background-position: -200% 0;
  }
}

/* Avatars in matches and results take decoration frames too. */
.team .avatar[data-deco] img {
  border: 0;
  width: 54px;
  height: 54px;
}
.result-avatar {
  display: inline-grid;
  border-radius: 50%;
}
.result-avatar img {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--primary);
}
#resultB .result-avatar img {
  border-color: var(--pink);
}
.result-avatar[data-deco] img {
  border: 0;
}
.rank-row [data-deco] img,
.podium-card [data-deco] img {
  border: 0;
}

/* ================================================================== shop */
.shop-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.gold-pill {
  padding: 8px 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  color: #3a1d00;
  font-weight: 900;
  box-shadow: 0 4px 0 var(--gold-edge);
}
.gold-pill b {
  font-family: var(--display);
  font-size: 1.15rem;
}
.shop-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 16px;
}
.shop-preview img,
.avatar-editor img {
  width: 64px;
  height: 64px;
  object-fit: cover;
}
.shop-preview > div {
  display: grid;
  gap: 2px;
  justify-items: start;
}
.shop-preview strong {
  font-family: var(--display);
  font-size: 1.3rem;
}
.shop-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.shop-filters button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
}
.shop-filters button.selected {
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  color: #fff;
  border-color: transparent;
}
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.shop-card {
  --rarity: #56c6a9;
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 6px;
  padding: 14px;
  border-radius: 20px;
  background: var(--surface);
  border: 2px solid color-mix(in srgb, var(--rarity) 45%, transparent);
  box-shadow: var(--shadow);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
.shop-card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--rarity) 40%, transparent),
    var(--shadow);
}
.shop-card.rarity-rare {
  --rarity: #5b7cfa;
}
.shop-card.rarity-epic {
  --rarity: #9b5de5;
}
.shop-card.rarity-legendary {
  --rarity: #ff9f1c;
  background:
    radial-gradient(160px 90px at 50% 0%, color-mix(in srgb, #ffc83d 25%, transparent), transparent 70%),
    var(--surface);
}
.shop-card.equipped {
  border-color: var(--success);
}
.shop-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.shop-card-head small {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
}
.rarity-badge {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--rarity);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 900;
}
.shop-card-preview {
  display: grid;
  place-items: center;
  gap: 6px;
  height: 120px;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--rarity) 22%, transparent), transparent 70%), var(--field);
}
.shop-card-preview img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 50%;
}
.shop-card-preview.frame img {
  width: 70px;
  height: 70px;
}
.shop-card-preview.title {
  align-content: center;
}
.shop-card-preview.title strong {
  font-family: var(--display);
  font-size: 1.05rem;
}
.shop-card-preview .title-badge {
  font-size: 0.85rem;
  padding: 3px 12px;
}
.shop-emote {
  font-size: 3.4rem;
  line-height: 1;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.2));
}
.shop-card:hover .shop-emote,
.shop-card:hover .shop-card-preview.avatar img {
  animation: wiggle 0.6s ease;
}
.shop-card h3 {
  margin: 4px 0 0;
  font-size: 1.1rem;
}
.shop-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.shop-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
}
.shop-price {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--accent-text);
}
.owned-tag {
  font-weight: 800;
  font-size: 0.8rem;
  color: var(--success);
}

/* Profile picture editor. */
.avatar-panel {
  grid-column: 1 / -1;
}
.avatar-editor {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.avatar-editor img {
  width: 96px;
  height: 96px;
}
.avatar-editor-body {
  flex: 1 1 260px;
  display: grid;
  gap: 8px;
}
.file-button {
  cursor: pointer;
}
.file-button:focus-within {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ virtual pets */
.pet-dock {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  margin-bottom: 14px;
  border-radius: var(--radius);
}
.pet-dock-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 3px;
}
.pet-dock-body small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pet-sprite {
  display: inline-grid;
  place-items: center;
  border: 0;
  background: radial-gradient(circle at 50% 35%, #fff, #ffe3f1 70%);
  border-radius: 50%;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(255, 95, 162, 0.22);
  cursor: pointer;
  user-select: none;
}
.pet-sprite.dock {
  width: 58px;
  height: 58px;
  font-size: 34px;
  flex: none;
  animation: pet-bob 2.6s ease-in-out infinite;
}
.pet-sprite.small {
  width: 44px;
  height: 44px;
  font-size: 26px;
  flex: none;
  cursor: default;
}
.pet-sprite.big {
  width: 132px;
  height: 132px;
  font-size: 78px;
}
.pet-sprite.big[data-stage="baby"] {
  font-size: 54px;
}
.pet-sprite.big[data-stage="teen"] {
  font-size: 66px;
}
.pet-sprite[data-mood="sleeping"] {
  filter: saturate(0.6) brightness(0.92);
  animation: pet-breathe 3.5s ease-in-out infinite;
}
.pet-sprite[data-mood="sick"] {
  filter: hue-rotate(60deg) saturate(0.7);
}
.pet-sprite[data-stage="egg"] {
  animation: pet-wobble 2s ease-in-out infinite;
}
.pet-sprite.acting {
  animation: pet-jump 0.6s ease;
}
@keyframes pet-bob {
  50% {
    transform: translateY(-4px);
  }
}
@keyframes pet-breathe {
  50% {
    transform: scale(1.04);
  }
}
@keyframes pet-wobble {
  25% {
    transform: rotate(-7deg);
  }
  75% {
    transform: rotate(7deg);
  }
}
@keyframes pet-jump {
  40% {
    transform: translateY(-18px) scale(1.06);
  }
}
.pet-mini-bars {
  display: flex;
  gap: 6px;
}
.pet-mini-bars .pet-stat {
  flex: 1;
  grid-template-columns: auto 1fr;
  font-size: 0.75rem;
}
.pet-stats {
  display: grid;
  gap: 9px;
  margin-bottom: 12px;
}
.pet-stat {
  display: grid;
  grid-template-columns: 9.5em 1fr 2.2em;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}
.pet-stat b {
  text-align: right;
}
.pet-stat-track {
  height: 10px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}
.pet-stat-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--success));
  transition: width 0.5s ease;
}
.pet-stat.mid .pet-stat-track i {
  background: linear-gradient(90deg, var(--gold-2), var(--gold));
}
.pet-stat.low .pet-stat-track i {
  background: linear-gradient(90deg, var(--danger), var(--pink));
}
.pet-empty {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.pet-home {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 16px;
  margin-bottom: 16px;
}
.pet-stage {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  padding: 20px;
  border-radius: var(--radius);
  text-align: center;
}
.pet-stage h2 {
  margin: 4px 0 0;
}
.pet-scene {
  position: relative;
  width: 100%;
  display: grid;
  place-items: center;
  padding: 26px 0 10px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #e9f7ff, #fff1f8 70%, #e7f9ec 70%);
}
.pet-bubble {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 99px;
  background: #fff;
  color: #3a2a55;
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  opacity: 0;
  pointer-events: none;
}
.pet-bubble.show {
  animation: pet-bubble 2.2s ease forwards;
}
@keyframes pet-bubble {
  10%,
  75% {
    opacity: 1;
    transform: translate(-50%, -6px);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -14px);
  }
}
.pet-xp {
  width: 100%;
  max-width: 260px;
}
.pet-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.pet-actions .btn[hidden] {
  display: none;
}
.pet-list {
  display: grid;
  gap: 10px;
}
.pet-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.pet-row.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(31, 209, 181, 0.18);
}
.pet-row-body {
  flex: 1;
  min-width: 0;
  display: grid;
}
.supply-grid {
  display: grid;
  gap: 8px;
}
.supply-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.supply-emoji {
  font-size: 28px;
}
.supply-body {
  flex: 1;
  min-width: 0;
  display: grid;
}
.species-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.species-card .shop-card-preview {
  display: grid;
  place-items: center;
  padding: 10px 0;
}
.adopt-preview {
  display: grid;
  place-items: center;
}
@media (max-width: 760px) {
  .pet-home {
    grid-template-columns: 1fr;
  }
  .pet-dock {
    flex-wrap: wrap;
  }
  .pet-stat {
    grid-template-columns: 7.5em 1fr 2em;
  }
  .pet-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (prefers-reduced-motion: reduce) {
  .pet-sprite,
  .pet-sprite.acting,
  .pet-bubble.show {
    animation: none !important;
  }
  .pet-bubble.show {
    opacity: 1;
  }
}

/* pet gear, bonuses and owner boosts */
.pet-sprite {
  position: relative;
}
.pet-gear {
  position: absolute;
  line-height: 1;
  pointer-events: none;
  font-size: 0.42em;
}
.pet-sprite.big .pet-gear {
  font-size: 34px;
}
.pet-gear.slot-hat {
  top: -0.35em;
  left: 50%;
  transform: translateX(-50%) rotate(-8deg);
}
.pet-gear.slot-glasses {
  top: 36%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.34em;
}
.pet-sprite.big .pet-gear.slot-glasses {
  font-size: 28px;
}
.pet-gear.slot-collar {
  bottom: 4%;
  left: 50%;
  transform: translateX(-50%);
}
.pet-gear.slot-wings {
  top: 30%;
  left: -0.45em;
  transform: scaleX(-1);
  z-index: -1;
}
.pet-gear.slot-aura {
  top: 0;
  right: -0.2em;
}
.pet-sprite[data-aura="on"] {
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--aura, #fde047) 55%, transparent),
    0 0 26px 6px color-mix(in srgb, var(--aura, #fde047) 60%, transparent);
}
.pet-power {
  display: grid;
  gap: 4px;
  width: 100%;
  margin-top: 6px;
}
.pet-power-line,
.pet-perk {
  display: block;
  padding: 5px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--gold) 16%, transparent);
  font-weight: 700;
  font-size: 0.82rem;
}
.pet-subheading {
  margin: 16px 0 8px;
  font-size: 1rem;
}
.pet-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}
.pet-slot {
  display: grid;
  gap: 4px;
  font-size: 0.85rem;
}
.pet-slot select {
  width: 100%;
}
.boost-active {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 14px;
}
.boost-chip {
  padding: 6px 12px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--teal) 22%, transparent);
  border: 1px solid var(--teal);
  font-weight: 700;
  font-size: 0.85rem;
}
.bonus-line {
  color: var(--gold-edge);
  font-weight: 800;
}
