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

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  touch-action: none;
}

body {
  background: linear-gradient(180deg, #78c7ff, #b7e4ff 60%, #5fac4e);
}

button {
  font: inherit;
}

.game-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #78c7ff;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: grab;
}

#game:active {
  cursor: grabbing;
}

.hud {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.hud > div {
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(15, 18, 22, 0.76);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(12px);
}

.hud > div {
  display: grid;
  min-width: 108px;
  padding: 6px 12px;
}

.label {
  color: rgba(247, 242, 232, 0.64);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hud strong {
  color: #fff8dc;
  font-size: 18px;
  line-height: 1.1;
}

.touch-pad {
  position: fixed;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 4;
  width: 132px;
  height: 132px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02)),
    rgba(13, 16, 19, 0.42);
  box-shadow: inset 0 0 36px rgba(255, 255, 255, 0.04);
  opacity: 0;
  pointer-events: none;
}

.thumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  background: rgba(241, 183, 72, 0.76);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -50%);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 6;
  width: min(560px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(15, 18, 22, 0.82);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
  color: rgba(255, 248, 220, 0.92);
  font-size: 14px;
  line-height: 1.35;
  text-align: center;
  transform: translateX(-50%);
  transition: opacity 260ms ease;
}

.toast.hidden {
  opacity: 0;
}

.game-over {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 10, 13, 0.18);
  pointer-events: auto;
}

.game-over.hidden {
  display: none;
}

.game-over-panel {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(380px, calc(100vw - 36px));
  padding: 20px 18px 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(15, 18, 22, 0.88);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px);
}

.game-over-panel strong {
  color: #fff8dc;
  font-size: 46px;
  line-height: 1;
}

.score-entry {
  display: grid;
  gap: 8px;
  width: 100%;
}

.score-entry.hidden {
  display: none;
}

.score-entry label {
  color: #fff8dc;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.score-entry div {
  display: grid;
  grid-template-columns: 1fr 82px;
  gap: 8px;
}

.score-entry input {
  min-width: 0;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: #21180d;
  font: inherit;
  font-weight: 750;
  padding: 0 12px;
}

.leaderboard {
  display: grid;
  gap: 6px;
  width: 100%;
  margin: 2px 0 4px;
}

.leaderboard-heading,
.leaderboard li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.leaderboard-heading {
  color: rgba(247, 242, 232, 0.6);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.leaderboard ol {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 26px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard li {
  min-height: 28px;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 248, 220, 0.9);
  font-size: 13px;
  font-weight: 750;
}

.leaderboard li.current-score {
  background: rgba(241, 183, 72, 0.22);
  color: #fff8dc;
}

.leaderboard .empty-score {
  justify-content: center;
  color: rgba(247, 242, 232, 0.56);
  font-weight: 700;
}

.game-over-panel button {
  min-height: 46px;
  width: 100%;
  border: 1px solid rgba(245, 176, 68, 0.58);
  border-radius: 8px;
  background: #f1b748;
  color: #21180d;
  font-weight: 800;
}

@media (max-width: 700px) {
  .hud {
    gap: 8px;
  }

  .hud > div {
    min-width: 88px;
  }

  .hud strong {
    font-size: 16px;
  }

  .touch-pad {
    width: 112px;
    height: 112px;
  }

  .toast {
    bottom: max(144px, calc(env(safe-area-inset-bottom) + 138px));
    width: min(356px, calc(100vw - 32px));
  }

  .game-over {
    align-items: center;
    padding-bottom: 132px;
  }

  .game-over-panel strong {
    font-size: 40px;
  }

  .leaderboard li {
    min-height: 26px;
    font-size: 12px;
  }
}
