/* Shared components: menus, lobby cards, panels, tables, chat, toasts, modal. */

/* ---------- Dropdown menus ---------- */
.dropdown {
  position: relative;
}
.menu {
  display: none;
  position: absolute;
  top: calc(100% + var(--s2));
  z-index: 60;
  padding: var(--s2);
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  box-shadow: var(--shadow-2);
  animation: menu-in 0.14s ease-out;
}
@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}
.dropdown.open > .menu {
  display: block;
}
.menu-right {
  right: 0;
}
.menu a,
.menu .menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: var(--s2) 10px;
  border-radius: 6px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: left;
}
.menu a:hover,
.menu .menu-item:hover {
  background: var(--surface-3);
  color: var(--text);
}
.menu .icon {
  width: 16px;
  height: 16px;
}
.menu-sep {
  height: 1px;
  margin: 6px 0;
  background: var(--line);
}
.games-menu {
  width: 460px;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}
.dropdown.open > .games-menu {
  display: grid;
}
.thumb {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 7px;
  overflow: hidden;
}
.thumb svg {
  width: 100%;
  height: 100%;
}
.wallet-menu {
  width: 280px;
  padding: var(--s4);
}
.wallet-menu .big {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin: 2px 0 var(--s2);
}
.wallet-menu .btn {
  width: 100%;
  margin-top: var(--s2);
}
.wallet-menu a.btn,
.wallet-menu a.btn:hover {
  color: inherit;
}
.wallet-menu a.btn:not(.btn-ghost):not(.btn-secondary) {
  color: #1d1505;
}
.user-menu {
  width: 220px;
}

/* ---------- Section headers ---------- */
.page-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-wrap: wrap;
  margin-bottom: var(--s4);
}
.page-head .icon {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
}
.section-head {
  display: flex;
  align-items: center;
  gap: var(--s4);
  flex-wrap: wrap;
  margin: var(--s2) 0 var(--s4);
}
.search {
  position: relative;
  max-width: 300px;
  flex: 1;
}
.search .icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-dim);
}
.search .input {
  padding-left: 36px;
}

/* ---------- Hero cards ---------- */
.heroes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s4);
  margin-bottom: var(--s6);
}
.hero {
  position: relative;
  overflow: hidden;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s5);
  padding-right: calc(var(--s5) + 112px);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, var(--surface-2), var(--surface-1));
}
.hero.wallet-hero,
.stat-card {
  padding-right: var(--s5);
}
.hero h3 {
  font-size: var(--fs-xl);
}
.hero .actions {
  margin-top: auto;
  padding-top: var(--s2);
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.hero-art {
  position: absolute;
  right: var(--s4);
  top: var(--s5);
  width: 104px;
  height: 104px;
  pointer-events: none;
}
.hero-art svg {
  width: 100%;
  height: 100%;
}
.profile-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
}
.rank-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.progress {
  height: 8px;
  border-radius: var(--r-pill);
  overflow: hidden;
  background: var(--surface-0);
}
.progress > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  transition: width 0.4s;
}
.stat-big {
  font-size: var(--fs-3xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s4);
  margin-bottom: var(--s4);
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding: var(--s4) var(--s5);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-1);
  min-width: 0;
}
.stat-card .stat-big {
  font-size: var(--fs-2xl);
}

/* ---------- Lobby game cards ---------- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--s4);
}
.game-card {
  position: relative;
  display: block;
  aspect-ratio: 200 / 268;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  transition: transform 0.18s, box-shadow 0.18s;
  isolation: isolate;
}
.game-card svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition: transform 0.35s;
}
.game-card:hover svg {
  transform: scale(1.03);
}
.game-card .label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: var(--s5) var(--s3) var(--s3);
  background: linear-gradient(180deg, transparent, rgba(11, 12, 14, 0.78));
  text-transform: none;
  letter-spacing: 0;
  color: #fff;
}
.game-card .name {
  display: block;
  font-size: var(--fs-lg);
  font-weight: 650;
}
.game-card .tag {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.72);
}
.empty-note {
  margin-top: var(--s4);
}

/* ---------- Panels and tables ---------- */
.panel {
  padding: var(--s4) var(--s5);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-1);
  box-shadow: inset 0 1px 0 var(--hairline);
}
.panel + .panel {
  margin-top: var(--s4);
}
.panel-title {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s3);
  font-size: var(--fs-lg);
  font-weight: 650;
}
.panel-title .icon {
  color: var(--text-muted);
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s4);
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 10px var(--s3);
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}
td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
tr.me td {
  background: var(--gold-soft);
  font-weight: 650;
}
.place {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-3);
  font-weight: 700;
  font-size: var(--fs-xs);
}
.place.p1 {
  background: linear-gradient(180deg, #f8d77a, #d29a24);
  color: #1d1505;
}
.place.p2 {
  background: linear-gradient(180deg, #e8eaee, #a3a8b2);
  color: #16181b;
}
.place.p3 {
  background: linear-gradient(180deg, #f0a46a, #b0612b);
  color: #2a1200;
}
.empty {
  padding: var(--s5);
  text-align: center;
  color: var(--text-muted);
}
.copy-row {
  display: flex;
  gap: var(--s2);
}
.code-big {
  font-size: var(--fs-3xl);
  font-weight: 700;
  color: var(--gold-2);
  letter-spacing: 0.06em;
  word-break: break-all;
}

/* ---------- Chat ---------- */
.rain-card {
  margin: 0 var(--s3) var(--s3);
  padding: var(--s3);
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: radial-gradient(120% 90% at 50% 0%, rgba(127, 178, 230, 0.12) 0%, transparent 70%), var(--surface-2);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.rain-card .rain-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}
.rain-card .rain-head .icon {
  width: 16px;
  height: 16px;
  color: var(--info);
}
.rain-card .rain-pool {
  justify-content: center;
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--text);
  margin: 2px 0;
}
.rain-card .rain-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.rain-card .rain-actions {
  display: flex;
  gap: var(--s2);
  margin-top: var(--s2);
}
.rain-card .rain-actions .btn {
  flex: 1;
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: var(--s2) var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.chat-msg {
  font-size: var(--fs-sm);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.chat-msg .time {
  margin-right: 6px;
  font-size: 11px;
  color: var(--text-dim);
}
.chat-msg .author {
  margin-right: 4px;
  font-weight: 600;
  color: var(--text);
}
.chat-msg.mine .author {
  color: var(--gold-2);
}
.chat-event {
  display: flex;
  gap: var(--s2);
  align-items: flex-start;
  padding: var(--s2) 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  font-size: var(--fs-xs);
}
.chat-event .icon {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  color: var(--gold-2);
}
.chat-event b {
  color: var(--text);
}
.chat-input {
  padding: var(--s3);
  border-top: 1px solid var(--line);
}
.chat-input .row {
  display: flex;
  gap: 6px;
}
.chat-input .meta {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}
.online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  right: var(--s4);
  bottom: var(--s4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  pointer-events: none;
}
.toast {
  max-width: 340px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--text-dim);
  background: var(--surface-2);
  box-shadow: var(--shadow-2);
  font-weight: 550;
  animation: toast-in 0.25s;
}
.toast.win {
  border-left-color: var(--green);
}
.toast.loss,
.toast.error {
  border-left-color: var(--red);
}
@keyframes toast-in {
  from {
    transform: translateX(40px);
    opacity: 0;
  }
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s4);
  background: rgba(4, 5, 6, 0.7);
  backdrop-filter: blur(4px);
}
.modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: var(--s5);
  border-radius: var(--r-lg);
  border: 1px solid var(--line-strong);
  background: linear-gradient(170deg, var(--surface-2), var(--surface-1));
  box-shadow: var(--shadow-2);
}
.modal .close {
  position: absolute;
  right: var(--s3);
  top: var(--s3);
}
.modal-brand {
  display: flex;
  justify-content: center;
  margin-bottom: var(--s3);
}
.modal-brand svg {
  width: 64px;
  height: 64px;
}
.tabs {
  display: flex;
  gap: var(--s1);
  padding: var(--s1);
  margin-bottom: var(--s4);
  border-radius: var(--r-sm);
  background: var(--surface-0);
}
.tabs button {
  flex: 1;
  padding: var(--s2);
  border-radius: 6px;
  font-weight: 600;
  color: var(--text-muted);
}
.tabs button.active {
  background: var(--surface-3);
  color: var(--text);
}
.form-error {
  min-height: 18px;
  margin-top: var(--s3);
  font-size: var(--fs-sm);
  font-weight: 550;
  color: #f7a3ac;
}
.modal .btn-block {
  margin-top: var(--s2);
}

@media (max-width: 1400px) {
  .game-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
@media (max-width: 1180px) {
  .game-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .heroes {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 760px) {
  .game-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--s3);
  }
  .heroes,
  .grid-2,
  .stat-row {
    grid-template-columns: 1fr;
  }
  .hero {
    padding-right: calc(var(--s4) + 88px);
  }
  .hero-art {
    width: 80px;
    height: 80px;
    right: var(--s3);
    top: var(--s4);
  }
  .games-menu {
    width: 300px;
    grid-template-columns: 1fr;
  }
}
@media (max-width: 480px) {
  .game-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
