:root {
  color-scheme: light;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  background: #0b0b0b;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #0b0b0b;
}

.game-screen {
  position: relative;
  width: min(100vw, 56.25dvh);
  height: min(177.7778vw, 100dvh);
  max-width: 480px;
  max-height: 853px;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.38), transparent 18%),
    linear-gradient(180deg, #d80018 0%, #a90013 44%, #f23821 100%);
}

.promo-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.top-actions {
  position: absolute;
  z-index: 2;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  display: flex;
  gap: 8px;
}

.top-button {
  min-height: 32px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  appearance: none;
  backdrop-filter: blur(8px);
}

.leaderboard-card {
  width: min(92vw, 390px);
  max-height: min(78dvh, 620px);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 8px;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 211, 61, 0.28), transparent 28%),
    linear-gradient(180deg, rgba(196, 18, 48, 0.96), rgba(105, 0, 13, 0.96));
  color: #ffffff;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.42);
}

.leaderboard-topline {
  display: grid;
  grid-template-columns: 1fr 34px;
  align-items: center;
  gap: 8px;
}

.leaderboard-title {
  overflow: hidden;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.26);
  color: #ffffff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.my-count {
  overflow: hidden;
  margin-top: 10px;
  padding: 7px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  color: #ffd33d;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-summary {
  margin-top: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  background: rgba(255, 211, 61, 0.18);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}

.rank-summary strong {
  color: #ffd33d;
  font-size: 14px;
}

.leaderboard-list {
  display: grid;
  align-content: start;
  gap: 5px;
  margin-top: 9px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.leaderboard-row,
.leaderboard-empty {
  display: grid;
  grid-template-columns: 34px 1fr 48px;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
}

.leaderboard-row.is-me {
  outline: 2px solid rgba(255, 211, 61, 0.95);
  background: rgba(255, 211, 61, 0.28);
  color: #ffffff;
}

.leaderboard-empty {
  grid-template-columns: 1fr;
  text-align: center;
}

.leaderboard-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  color: #ffd33d;
  text-align: right;
}

.actions {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(86%, 360px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  transform: translateX(-50%);
}

.action-button {
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.54);
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  backdrop-filter: blur(8px);
  cursor: pointer;
  appearance: none;
}

.jump-link {
  display: grid;
  place-items: center;
  background: rgba(196, 18, 48, 0.86);
}

.action-button:active {
  transform: scale(0.97);
}

.toast {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 66px);
  width: min(78%, 300px);
  padding: 12px 16px;
  transform: translateX(-50%) translateY(10px);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.74);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.modal {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.62);
}

.modal.hidden {
  display: none;
}

.rename-panel {
  width: min(88vw, 320px);
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  background: #ffffff;
  color: #1f1f1f;
}

.rename-title {
  font-size: 18px;
  font-weight: 900;
}

.rename-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 2px solid #d9d9d9;
  border-radius: 8px;
  font-size: 16px;
  outline: none;
}

.rename-input:focus {
  border-color: #c41230;
}

.rename-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.rename-cancel,
.rename-save {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}

.rename-cancel {
  background: #eeeeee;
  color: #222222;
}

.rename-save {
  background: #c41230;
  color: #ffffff;
}

@media (min-width: 768px) {
  .game-screen {
    border-radius: 8px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  }
}
