:root {
  --panel: rgba(70, 91, 173, 0.92);
  --panel-dark: rgba(36, 49, 130, 0.94);
  --line: #90d7ff;
  --text: #ffffff;
  --gold: #ffd45c;
  --shadow: rgba(17, 24, 72, 0.52);
}

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

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #7abcef;
  color: var(--text);
  font-family: "Trebuchet MS", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  touch-action: none;
}

button {
  font: inherit;
  color: inherit;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #7abcef;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hud {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: 8px;
  right: 8px;
  z-index: 5;
  min-height: 62px;
  display: grid;
  grid-template-columns: 76px minmax(86px, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 3px solid #283585;
  border-bottom-width: 5px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 6px 0 var(--shadow);
}

.scoreBox {
  height: 54px;
  display: grid;
  place-items: center;
  border: 2px solid #283585;
  border-radius: 10px;
  background: var(--panel-dark);
  line-height: 1;
}

.scoreBox span {
  font-size: 10px;
  letter-spacing: 0.08em;
}

.scoreBox strong {
  font-size: 28px;
}

.titleBox {
  text-align: center;
  line-height: 0.82;
  text-shadow: 3px 3px 0 #27317c;
  white-space: nowrap;
}

.titleVopl {
  display: block;
  color: var(--gold);
  font-weight: 900;
  font-size: clamp(22px, 7vw, 42px);
}

.titleBird {
  display: block;
  font-weight: 900;
  font-size: clamp(20px, 6.5vw, 38px);
}

.buttons {
  display: flex;
  gap: 6px;
}

.iconBtn,
.leaderboardToggle,
.primaryBtn {
  border: 2px solid #27317c;
  border-bottom-width: 4px;
  background: #536ac7;
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--shadow);
}

.iconBtn {
  min-width: 45px;
  height: 45px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 900;
}

.iconBtn.off {
  opacity: 0.55;
}

.menu,
.panel,
.leaderboard {
  position: fixed;
  z-index: 6;
}

.menu {
  left: 20px;
  right: 20px;
  top: 22%;
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 18px;
  text-align: center;
  border: 3px solid #27317c;
  border-bottom-width: 6px;
  border-radius: 22px;
  background: rgba(67, 85, 172, 0.88);
  box-shadow: 0 7px 0 var(--shadow);
}

.menuLogo {
  width: min(150px, 36vw);
  height: auto;
  filter: drop-shadow(3px 4px 0 rgba(0, 0, 0, 0.45));
}

.menu h1,
.panel h2 {
  margin: 0;
  font-size: 30px;
  color: var(--gold);
  text-shadow: 3px 3px 0 #27317c;
}

.menu p {
  margin: 0;
  max-width: 300px;
  font-size: 14px;
  line-height: 1.35;
}

.primaryBtn {
  width: min(220px, 70vw);
  padding: 13px 18px;
  margin-top: 8px;
  font-size: 20px;
  font-weight: 900;
  background: #f2b941;
  color: #26326f;
}

.panel {
  left: 22px;
  right: 22px;
  top: 25%;
  padding: 18px;
  display: grid;
  gap: 14px;
  place-items: center;
  border: 3px solid #27317c;
  border-bottom-width: 6px;
  border-radius: 22px;
  background: rgba(67, 85, 172, 0.94);
  box-shadow: 0 7px 0 var(--shadow);
}

.resultGrid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 26px;
  min-width: 180px;
  font-size: 16px;
}

.resultGrid strong {
  color: var(--gold);
}

.leaderboard {
  left: 12px;
  right: 12px;
  bottom: max(10px, env(safe-area-inset-bottom));
  padding: 8px 10px 10px;
  border: 3px solid #27317c;
  border-bottom-width: 6px;
  border-radius: 18px;
  background: rgba(67, 85, 172, 0.9);
  box-shadow: 0 7px 0 var(--shadow);
  transform: translateY(calc(100% - 48px));
  transition: transform 140ms ease;
}

.leaderboard.open {
  transform: translateY(0);
}

.leaderboardHeader {
  display: grid;
  place-items: center;
  margin-bottom: 8px;
}

.leaderboardToggle {
  height: 34px;
  min-width: 160px;
  padding: 0 18px;
  font-weight: 900;
  background: #536ac7;
}

#leaderboardList {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

#leaderboardList li {
  min-height: 38px;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 2px solid #27317c;
  border-radius: 10px;
  background: rgba(37, 49, 134, 0.9);
  font-weight: 900;
}

.rank {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #26326f;
  border-radius: 50%;
  background: #dce4ff;
}

.rank.top1 {
  background: var(--gold);
}

.scoreValue {
  color: var(--gold);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 30%;
  z-index: 9;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 14px;
  border: 2px solid #27317c;
  background: rgba(37, 49, 134, 0.94);
  font-size: 14px;
  text-align: center;
}

.hidden {
  display: none !important;
}

@media (max-width: 360px) {
  .hud {
    grid-template-columns: 62px minmax(70px, 1fr) auto;
    gap: 5px;
    padding: 6px;
  }

  .scoreBox {
    height: 48px;
  }

  .scoreBox strong {
    font-size: 22px;
  }

  .iconBtn {
    min-width: 38px;
    height: 38px;
    padding: 0 6px;
    font-size: 10px;
  }

  .menu {
    top: 20%;
  }
}
