:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #586878;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.93);
  --line: rgba(23, 33, 43, 0.16);
  --accent: #f05d4f;
  --accent-dark: #a63434;
  --sun: #ffd166;
  --grass: #4d9f71;
  --sky: #98d8ee;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--sky);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  font: inherit;
}

.game-shell {
  position: fixed;
  inset: 0;
  min-width: 320px;
  min-height: 360px;
  overflow: hidden;
  background: #98d8ee;
  touch-action: manipulation;
  user-select: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  z-index: 3;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: minmax(158px, auto) minmax(140px, 260px) 44px 44px;
  gap: 10px;
  align-items: start;
  pointer-events: none;
}

.score-cluster {
  display: flex;
  gap: 10px;
  min-width: 0;
}

.score-box,
.power-wrap,
.icon-button,
.overlay-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(23, 33, 43, 0.08);
  backdrop-filter: blur(10px);
}

.score-box {
  min-width: 74px;
  height: 48px;
  padding: 7px 10px;
  border-radius: 8px;
}

.label,
#powerLabel {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.1;
  text-transform: uppercase;
}

.score-box strong {
  display: block;
  min-width: 46px;
  margin-top: 2px;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.power-wrap {
  display: none;
  min-width: 0;
  height: 48px;
  padding: 8px 10px;
  border-radius: 8px;
}

.power-wrap.is-active {
  display: block;
}

.power-meter {
  height: 10px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(23, 33, 43, 0.14);
}

.power-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2fbf71, #ffd166, #f05d4f);
  transition: width 120ms linear;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  pointer-events: auto;
}

.icon-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.icon-button:active,
.primary-button:active {
  transform: translateY(0);
}

.overlay {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: linear-gradient(
    rgba(152, 216, 238, 0.1),
    rgba(84, 159, 113, 0.16)
  );
}

.overlay.is-hidden {
  display: none;
}

.overlay-panel {
  width: min(92vw, 430px);
  padding: clamp(20px, 4vw, 32px);
  border-radius: 8px;
  text-align: center;
}

.overlay-panel h1 {
  margin: 0;
  font-size: clamp(40px, 10vw, 76px);
  line-height: 0.94;
  letter-spacing: 0;
}

.overlay-panel p {
  margin: 14px auto 20px;
  max-width: 26rem;
  color: var(--muted);
  font-size: clamp(15px, 3.8vw, 18px);
  line-height: 1.45;
}

.primary-button {
  min-width: 150px;
  height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 22px rgba(240, 93, 79, 0.28);
  cursor: pointer;
  font-size: 17px;
  font-weight: 800;
}

@media (max-width: 620px) {
  .hud {
    grid-template-columns: 1fr 44px 44px;
    gap: 8px;
  }

  .score-cluster {
    grid-column: 1 / 2;
  }

  .power-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
    height: 40px;
    padding-top: 6px;
  }

  .score-box {
    flex: 1 1 0;
    min-width: 0;
  }

  .score-box strong {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .icon-button,
  .primary-button {
    transition: none;
  }
}
