:root {
  --bg: #05070d;
  --panel: rgba(12, 15, 22, 0.78);
  --line: rgba(255, 205, 85, 0.2);
  --gold: #f1c24d;
  --gold-strong: #ffdd7c;
  --text: #f4ecd3;
  --muted: #a8a091;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(255, 199, 75, 0.12), transparent 24%),
    linear-gradient(180deg, #090b12 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

body {
  touch-action: none;
}

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

.death-flash {
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  background:
    radial-gradient(circle at center, rgba(255, 90, 109, 0.28), rgba(255, 35, 76, 0.12) 34%, rgba(7, 9, 16, 0) 68%),
    rgba(255, 42, 72, 0.08);
  opacity: 0;
}

.death-flash.show {
  animation: deathFlash 700ms ease-out forwards;
}

.death-alert {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  z-index: 12;
  pointer-events: none;
  min-width: min(460px, calc(100vw - 32px));
  padding: 24px 28px;
  border-radius: 26px;
  border: 1px solid rgba(255, 99, 117, 0.36);
  background:
    radial-gradient(circle at top, rgba(255, 98, 116, 0.16), transparent 48%),
    rgba(16, 10, 16, 0.92);
  box-shadow:
    0 26px 60px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  text-align: center;
  opacity: 0;
}

.death-alert.show {
  animation: deathAlertIn 1100ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.death-alert-label {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: #ff97a4;
}

.death-alert-text {
  margin-top: 10px;
  font-size: 34px;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: #fff2ea;
  text-shadow: 0 10px 24px rgba(255, 58, 87, 0.24);
}

@keyframes deathFlash {
  0% {
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes deathAlertIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.82);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.03);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.98);
  }
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.brand,
.title,
.panel,
.pill,
.actions {
  position: fixed;
  z-index: 2;
}

.brand {
  top: 18px;
  left: 22px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.22em;
  color: var(--gold-strong);
}

.title {
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe085, #d89a07);
  color: #1c1300;
  border: 1px solid rgba(255, 239, 191, 0.6);
  box-shadow: 0 14px 34px rgba(159, 108, 0, 0.26);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.title::after {
  content: "snake trade arena";
  display: block;
  margin-top: 3px;
  font-size: 8px;
  letter-spacing: 0.18em;
  color: rgba(28, 19, 0, 0.7);
}

.panel,
.pill {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
}

.panel {
  border-radius: 22px;
  padding: 14px 16px;
}

.top-left {
  top: 64px;
  left: 22px;
  min-width: 220px;
}

.top-right {
  top: 64px;
  right: 22px;
  width: 240px;
}

.mini-map {
  top: 290px;
  right: 22px;
  width: 196px;
  padding: 12px;
}

#mini-map {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 8px;
  border-radius: 18px;
  background: rgba(6, 10, 18, 0.92);
  border: 1px solid rgba(255, 210, 92, 0.12);
}

.bottom-left {
  left: 22px;
  bottom: 22px;
}

.compact {
  max-width: 300px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.label {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 800;
}

.value {
  margin-top: 6px;
  font-size: 40px;
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1;
}

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

.meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 205, 85, 0.16);
  background: rgba(255, 255, 255, 0.03);
  font-size: 11px;
  color: var(--muted);
}

.meta-chip b {
  color: var(--text);
}

.pill {
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

#boost-indicator {
  min-width: 112px;
  text-align: center;
}

.leaderboard .label {
  margin-bottom: 10px;
}

#leaderboard-list {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: #efe4c2;
}

.leader-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  white-space: nowrap;
}

.leader-row.is-dead {
  color: #c9b8b8;
  opacity: 0.88;
}

.dead-cross {
  color: #ff4f5f;
  font-weight: 900;
}

.actions {
  right: 22px;
  bottom: 22px;
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.gold-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  height: 46px;
  padding: 0 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 219, 122, 0.24);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.gold-btn {
  background: linear-gradient(180deg, #ffdf7f, #d89a07);
  color: #1b1200;
  box-shadow:
    inset 0 1px 0 rgba(255, 247, 219, 0.6),
    0 14px 28px rgba(158, 107, 0, 0.24);
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.room-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 7, 12, 0.8);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.results-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 7, 12, 0.68);
  backdrop-filter: blur(10px);
  z-index: 11;
}

.room-overlay.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.room-panel {
  width: min(860px, 100%);
  padding: 26px;
  border-radius: 28px;
  border: 1px solid rgba(255, 205, 85, 0.2);
  background:
    radial-gradient(circle at top, rgba(255, 205, 85, 0.08), transparent 34%),
    rgba(10, 14, 22, 0.94);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.room-panel h1 {
  margin: 8px 0 8px;
  font-size: 38px;
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.room-panel p {
  margin: 0 0 16px;
  color: var(--muted);
  max-width: 700px;
  font-size: 13px;
  line-height: 1.45;
}

.room-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.display-name-panel {
  margin-bottom: 12px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 205, 85, 0.14);
  background: rgba(255, 255, 255, 0.03);
}

.display-name-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.display-name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.display-name-balance {
  min-width: 120px;
  text-align: right;
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 205, 85, 0.1);
  background: rgba(255, 255, 255, 0.025);
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 900;
}

.display-name-balance strong {
  font: inherit;
}

.display-name-balance span {
  color: inherit;
  font: inherit;
}

.account-link-btn {
  min-width: 132px;
  height: 42px;
  border-radius: 14px;
  font-size: 12px;
}

.wallet-gate,
.users-panel {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 205, 85, 0.14);
  background: rgba(255, 255, 255, 0.03);
}

.wallet-name-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 205, 85, 0.16);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  outline: none;
}

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

.wallet-gate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.wallet-gate-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.wallet-gate-status.is-connected {
  color: #9ef0b8;
}

.wallet-gate-btn {
  min-width: 220px;
  height: 44px;
}

.users-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.room-payment-note {
  margin: 12px 0 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 205, 85, 0.14);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.room-payment-note.is-paid {
  color: #9ef0b8;
  border-color: rgba(46, 203, 120, 0.24);
  background: rgba(46, 203, 120, 0.08);
}

.user-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 12px;
}

.user-row span:last-child {
  color: var(--muted);
  white-space: nowrap;
}

.room-card {
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 205, 85, 0.15);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  min-height: 122px;
}

.room-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 221, 124, 0.4);
}

.room-card.active {
  border-color: rgba(255, 221, 124, 0.56);
  background: rgba(255, 205, 85, 0.08);
}

.room-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.room-card .room-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.room-start-btn {
  margin-top: 16px;
  width: 100%;
}

.results-panel {
  width: min(860px, 100%);
  padding: 26px;
  border-radius: 28px;
  border: 1px solid rgba(255, 205, 85, 0.2);
  background:
    radial-gradient(circle at top, rgba(255, 205, 85, 0.1), transparent 34%),
    rgba(10, 14, 22, 0.96);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.results-panel h2 {
  margin: 10px 0 6px;
  font-size: 42px;
  line-height: 1;
}

.results-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.results-card {
  padding: 16px;
  border-radius: 22px;
  border: 1px solid rgba(255, 205, 85, 0.14);
  background: rgba(255, 255, 255, 0.03);
}

.results-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.results-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 13px;
}

.results-row.winner {
  border: 1px solid rgba(255, 221, 124, 0.24);
}

.results-row.loser {
  opacity: 0.82;
}

.results-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.results-actions .gold-btn,
.results-actions .ghost-btn {
  flex: 1;
}

.lobby-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.lobby-list {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.lobby-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 205, 85, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

.lobby-row.self {
  border-color: rgba(255, 221, 124, 0.34);
  background: rgba(255, 205, 85, 0.07);
}

.lobby-name {
  font-size: 15px;
  font-weight: 800;
}

.lobby-role {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.lobby-badge {
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 205, 85, 0.18);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}

.lobby-badge.joining {
  color: #f2cf75;
  background: rgba(255, 201, 86, 0.08);
}

.lobby-badge.ready {
  color: #83f0b5;
  background: rgba(46, 203, 120, 0.12);
  border-color: rgba(46, 203, 120, 0.26);
}

.lobby-status {
  margin-top: 16px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.lobby-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.lobby-actions .gold-btn,
.lobby-actions .ghost-btn {
  flex: 1;
}

@media (max-width: 768px) {
  .brand {
    top: 12px;
    left: 12px;
    font-size: 12px;
  }

  .title {
    top: 12px;
    padding: 8px 12px;
    font-size: 11px;
  }

  .top-left,
  .top-right {
    top: 52px;
  }

  .top-left {
    left: 12px;
    right: 12px;
    min-width: 0;
  }

  .top-right {
    display: none;
  }

  .mini-map {
    top: auto;
    right: 12px;
    bottom: 70px;
    width: 120px;
    padding: 9px;
  }

  #mini-map {
    border-radius: 14px;
  }

  .bottom-left {
    left: 12px;
    right: 12px;
    bottom: 72px;
    max-width: none;
    font-size: 10px;
  }

  .actions {
    left: 12px;
    right: 12px;
    bottom: 12px;
    justify-content: space-between;
  }

  .gold-btn,
  .ghost-btn {
    flex: 1;
    min-width: 0;
    height: 42px;
  }

  .value {
    font-size: 28px;
  }

  .room-panel {
    padding: 18px;
  }

  .room-panel h1 {
    font-size: 28px;
  }

  .room-list {
    grid-template-columns: 1fr;
  }

  .display-name-head {
    flex-direction: column;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .display-name-row {
    grid-template-columns: 1fr;
  }

  .display-name-balance {
    text-align: left;
    min-width: 0;
  }

  .account-link-btn {
    width: 100%;
    min-width: 0;
  }

  .wallet-gate {
    flex-direction: column;
    align-items: stretch;
  }

  .wallet-gate-btn {
    min-width: 0;
    width: 100%;
  }

  .lobby-actions {
    flex-direction: column;
  }

  .results-columns {
    grid-template-columns: 1fr;
  }

  .results-actions {
    flex-direction: column;
  }

  .death-alert {
    min-width: min(360px, calc(100vw - 24px));
    padding: 18px 18px;
  }

  .death-alert-text {
    font-size: 26px;
  }
}
