*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #7ec9ff;
  --text: #ffffff;
  --font: "Avenir Next", "SF Pro Rounded", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

#game-root {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-drag: none;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 65%),
    linear-gradient(180deg, #8fd8ff 0%, #7dc8ff 45%, #66b7ef 100%);
}

#game-root::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 46%),
    radial-gradient(circle at 50% 92%, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0) 48%);
  z-index: 1;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  transition: filter 0.4s ease, opacity 0.4s ease;
}

#game-canvas:active {
  cursor: grabbing;
}

/* Match planet-destroyer: grid HUD, pause on row 2 right */
#hud {
  position: absolute;
  top: 48px;
  left: calc(20px + env(safe-area-inset-left, 0px));
  right: calc(20px + env(safe-area-inset-right, 0px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  row-gap: 4px;
  align-items: center;
  text-align: center;
  color: var(--text);
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 3;
  transition: opacity 0.4s ease;
}

#hud-center {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  align-self: center;
}

#hud-lives-spacer {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  min-height: 38px;
  min-width: 38px;
  visibility: hidden;
  pointer-events: none;
}

#depth-display {
  display: block;
  font-variant-numeric: tabular-nums;
}

#pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#pause-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

#pause-overlay-label {
  font-size: clamp(1.1rem, 4.2vw, 1.35rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
}

#pause-wrap {
  grid-column: 3;
  grid-row: 2;
  justify-self: end;
  align-self: start;
  position: relative;
  z-index: 4;
  pointer-events: auto;
}

#pause-btn {
  width: 36px;
  height: 36px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}

#pause-btn:active {
  transform: scale(0.96);
  opacity: 0.92;
}

#pause-btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

#pause-btn .icon-play {
  display: none;
}

#pause-btn.is-paused .icon-pause {
  display: none;
}

#pause-btn.is-paused .icon-play {
  display: block;
}

#game-root.is-game-over #pause-wrap {
  opacity: 0.4;
  pointer-events: none;
}

/* Hidden but focusable for WebView auto-start injection */
#play-btn {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* Frozen blurred frame while host app shows its own game-over UI (postMessage score). */
#game-root.is-game-over #game-canvas {
  filter: blur(3px) saturate(0.98);
  pointer-events: none;
}

#game-root.is-game-over #hud {
  opacity: 0.78;
}
