* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #10151f;
  font-family: "Segoe UI", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overscroll-behavior: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hidden {
  display: none !important;
}

#hud {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: calc(14px + env(safe-area-inset-left, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px));
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.hud-item {
  background: rgba(0, 0, 0, 0.45);
  color: #ffd464;
  font-weight: bold;
  font-size: 18px;
  padding: 8px 16px;
  border-radius: 20px;
  border: 2px solid #ffd464;
}

#power-meter {
  position: absolute;
  right: calc(18px + env(safe-area-inset-right, 0px));
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 220px;
  border: 2px solid #ffd464;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
  pointer-events: none;
}

#power-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(180deg, #ff5252, #ffd464);
  transition: height 0.05s linear;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(30, 20, 60, 0.85), rgba(5, 5, 15, 0.95));
  z-index: 10;
}

.panel {
  background: #1c2333;
  border: 2px solid #ffd464;
  border-radius: 16px;
  padding: 28px 32px;
  width: min(360px, 88vw);
  max-height: 86vh;
  max-height: 86dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  text-align: center;
  color: #f2f2f2;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  margin: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

.panel h1 {
  margin: 0 0 6px;
  color: #ffd464;
  font-size: 28px;
  letter-spacing: 1px;
}

.panel h2 {
  margin: 0 0 6px;
  color: #ffd464;
}

.panel h3 {
  margin: 18px 0 8px;
  font-size: 15px;
  color: #9fb0d0;
}

.panel p {
  margin: 6px 0 14px;
  font-size: 14px;
  color: #cdd6e8;
}

#name-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid #445;
  margin-bottom: 12px;
  outline: none;
  touch-action: manipulation;
}

button {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  font-weight: bold;
  color: #1c2333;
  background: linear-gradient(180deg, #ffe08a, #ffb347);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
}

button:active {
  filter: brightness(0.92);
}

.error {
  color: #ff6b6b;
  font-size: 13px;
  min-height: 16px;
}

.leaderboard {
  list-style: decimal;
  text-align: left;
  padding-left: 22px;
  margin: 0 0 16px;
  font-size: 14px;
  color: #e8edf7;
}

.leaderboard li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
}

.leaderboard .lb-score {
  color: #ffd464;
  font-weight: bold;
}

.leaderboard-empty {
  font-size: 13px;
  color: #8a93a8;
  margin: 0 0 16px;
}
