:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  background: #0b1020;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: var(--game-height, 100%);
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: var(--game-height, 100dvh);
}

#game {
  position: relative;
  width: 100%;
  height: var(--game-height, 100dvh);
  min-height: 0;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#game,
#game * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body {
  background:
    radial-gradient(circle at 50% -15%, rgba(67, 56, 202, 0.28), transparent 44%),
    linear-gradient(180deg, #11182d 0%, #080c17 100%);
}

canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-drag: none;
}

#ui-icons {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

#ui-icons img {
  position: absolute;
  display: block;
  object-fit: contain;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transform: translate(-50%, -50%);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-drag: none;
}

#hammer-strike {
  z-index: 2;
  visibility: hidden;
  opacity: 0;
  transform: rotate(0deg);
  transform-origin: 18% 82%;
  will-change: left, top, opacity, transform;
}

#tutorial-finger {
  z-index: 3;
  visibility: hidden;
  opacity: 0;
  transform: rotate(0deg);
  transform-origin: 65% 88%;
  will-change: left, top, opacity, transform;
}

#leaderboard-modal {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 11, 24, 0.82);
}

#leaderboard-modal[hidden] {
  display: none;
}

.leaderboard-dialog {
  display: flex;
  width: min(650px, 100%);
  max-height: min(820px, calc(100vh - 36px));
  flex-direction: column;
  overflow: hidden;
  border: 2px solid #4c78b7;
  border-radius: 26px;
  background: #17345f;
  box-shadow: 0 18px 55px rgba(3, 8, 20, 0.62);
}

.leaderboard-header {
  position: relative;
  padding: 26px 72px 16px;
  text-align: center;
}

.leaderboard-header h2 {
  margin: 0;
  color: #fff;
  font: 900 clamp(25px, 4.5vw, 36px)/1.1 "Arial Rounded MT Bold",
    "Trebuchet MS", Arial, sans-serif;
  text-shadow: 0 2px 0 rgba(4, 10, 26, 0.5);
}

.leaderboard-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 48px;
  height: 48px;
  padding: 0 0 4px;
  border: 1px solid #5e88c4;
  border-radius: 15px;
  color: #fff;
  background: #234a80;
  font: 800 34px/1 Arial, sans-serif;
  cursor: pointer;
}

.leaderboard-close:hover,
.leaderboard-auth:hover {
  background: #2d5d9d;
}

.leaderboard-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 22px 14px;
  padding: 6px;
  border: 1px solid #334f7b;
  border-radius: 17px;
  background: #10284b;
}

.leaderboard-tab {
  min-height: 50px;
  border: 0;
  border-radius: 12px;
  color: #b9d4ff;
  background: transparent;
  font: 900 clamp(16px, 3vw, 21px)/1 "Arial Rounded MT Bold",
    "Trebuchet MS", Arial, sans-serif;
  cursor: pointer;
}

.leaderboard-tab.is-active {
  color: #fff;
  background: #3d8ee8;
  box-shadow: 0 4px 12px rgba(4, 12, 29, 0.35);
}

.leaderboard-status {
  min-height: 28px;
  padding: 0 24px 10px;
  color: #c9dcf8;
  font: 700 15px/1.3 "Trebuchet MS", Arial, sans-serif;
  text-align: center;
}

.leaderboard-auth {
  align-self: center;
  padding: 12px 19px;
  border: 1px solid #76b8ff;
  border-radius: 13px;
  color: #fff;
  background: #234a80;
  font: 800 15px/1.1 "Trebuchet MS", Arial, sans-serif;
  cursor: pointer;
}

.leaderboard-auth-panel {
  flex: 0 0 auto;
  margin: 0 16px 16px;
  padding: 14px 16px;
  border: 1px solid #3f6395;
  border-radius: 16px;
  background: #10284b;
  text-align: center;
}

.leaderboard-auth-panel[hidden] {
  display: none;
}

.leaderboard-auth-note {
  margin-bottom: 11px;
  color: #d7e7ff;
  font: 800 clamp(14px, 2.7vw, 17px)/1.3 "Trebuchet MS", Arial, sans-serif;
}

.leaderboard-list {
  flex: 1 1 auto;
  min-height: 180px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 20px;
  scrollbar-color: #4f83c3 #10284b;
}

.leaderboard-section-title {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 8px 0;
  padding: 8px 12px;
  border-radius: 10px;
  color: #aecdff;
  background: rgba(16, 40, 75, 0.96);
  font: 900 14px/1 "Trebuchet MS", Arial, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.leaderboard-entry {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  min-height: 72px;
  margin-bottom: 8px;
  padding: 9px 14px;
  border: 1px solid #334f7b;
  border-radius: 16px;
  background: #101f3b;
}

.leaderboard-entry.is-current {
  border-color: #ffb34d;
  background: #294b73;
  box-shadow: inset 0 0 0 1px rgba(255, 179, 77, 0.4);
}

.leaderboard-avatar,
.leaderboard-avatar-placeholder {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #29466f;
  object-fit: cover;
}

.leaderboard-avatar-placeholder {
  display: grid;
  place-items: center;
  color: #fff;
  font: 900 22px/1 "Trebuchet MS", Arial, sans-serif;
}

.leaderboard-player {
  min-width: 0;
}

.leaderboard-name {
  overflow: hidden;
  color: #fff;
  font: 900 clamp(16px, 3vw, 21px)/1.15 "Arial Rounded MT Bold",
    "Trebuchet MS", Arial, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-rank {
  margin-top: 5px;
  color: #9fc2f1;
  font: 800 15px/1 "Trebuchet MS", Arial, sans-serif;
}

.leaderboard-score {
  padding-left: 10px;
  color: #fff;
  font: 900 clamp(20px, 4vw, 28px)/1 "Arial Rounded MT Bold",
    "Trebuchet MS", Arial, sans-serif;
  text-align: right;
}

#rank-notifications {
  position: absolute;
  z-index: 7;
  top: 12px;
  left: 50%;
  width: min(390px, calc(100% - 24px));
  pointer-events: none;
  transform: translateX(-50%);
}

.rank-notification {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 76px;
  margin: 0 0 10px;
  padding: 12px 18px 12px 14px;
  border: 1px solid #4c78b7;
  border-radius: 18px;
  color: #fff;
  background: #17345f;
  box-shadow: 0 8px 24px rgba(3, 8, 20, 0.48);
  opacity: 0;
  transform: translateY(calc(-100% - 24px));
  transition:
    transform 320ms cubic-bezier(0.2, 0.85, 0.25, 1),
    opacity 220ms ease;
}

.rank-notification.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.rank-notification-icon {
  font: 36px/1 "Segoe UI Emoji", "Apple Color Emoji", sans-serif;
  text-align: center;
}

.rank-notification-text {
  font: 900 clamp(16px, 3vw, 21px)/1.25 "Arial Rounded MT Bold",
    "Trebuchet MS", Arial, sans-serif;
  text-shadow: 0 2px 0 rgba(4, 10, 26, 0.45);
}

@media (max-width: 560px) {
  #leaderboard-modal {
    padding: 8px;
  }

  .leaderboard-dialog {
    max-height: calc(100vh - 16px);
    border-radius: 21px;
  }

  .leaderboard-header {
    padding: 23px 62px 14px;
  }

  .leaderboard-tabs {
    margin-inline: 13px;
  }

  .leaderboard-list {
    padding-inline: 10px;
  }

  .leaderboard-entry {
    grid-template-columns: 46px minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 64px;
    padding: 8px 10px;
  }

  .leaderboard-avatar,
  .leaderboard-avatar-placeholder {
    width: 46px;
    height: 46px;
  }
}
