:root {
  color-scheme: light;
  --sky: #47acf0;
  --ink: #1d2939;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.94);
  --line: rgba(29, 41, 57, 0.16);
  --gold: #f4b740;
  --coral: #f36f5f;
  --green: #5cae3f;
  --shadow: rgba(31, 54, 75, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  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 {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0)),
    var(--sky);
}

.hud {
  width: min(100%, 1120px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 10px 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 28px var(--shadow);
  backdrop-filter: blur(10px);
}

.brand {
  min-width: 0;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0;
  color: #203245;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-meters {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(58px, auto);
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 800;
}

.hud-meters span {
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

#coinCount::before {
  content: "";
  width: 12px;
  height: 12px;
  margin-right: 6px;
  display: inline-block;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff5a7 0 18%, #ffca2e 19% 60%, #d98100 61% 100%);
  vertical-align: -1px;
}

#lifeCount::before {
  content: "";
  width: 12px;
  height: 12px;
  margin-right: 6px;
  display: inline-block;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd7c7 0 18%, var(--coral) 19% 70%, #b54866 71% 100%);
  vertical-align: -1px;
}

.icon-button,
.touch-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(35, 56, 76, 0.12);
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.icon-button {
  width: 38px;
  height: 38px;
  font-size: 1.2rem;
  font-weight: 900;
}

.icon-button:active,
.touch-button:active,
.touch-button.is-held {
  transform: translateY(1px);
  background: #fff7d6;
}

.stage-wrap {
  width: min(100%, 1120px);
  min-height: 0;
  margin: 0 auto;
  display: grid;
  align-items: center;
}

canvas {
  width: 100%;
  height: auto;
  max-height: calc(100svh - 154px);
  display: block;
  border: 1px solid rgba(18, 42, 68, 0.22);
  border-radius: 8px;
  background: #7bc8ff;
  box-shadow: 0 18px 40px var(--shadow);
}

.touch-controls {
  width: min(100%, 1120px);
  min-height: 66px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.touch-cluster {
  display: grid;
  grid-template-columns: repeat(2, 58px);
  gap: 10px;
}

.touch-button {
  width: 58px;
  height: 58px;
  font-size: 2rem;
  font-weight: 900;
}

.touch-button.jump {
  width: 72px;
  height: 58px;
}

@media (pointer: fine) and (min-width: 760px) {
  .touch-controls {
    opacity: 0;
    pointer-events: none;
  }

  canvas {
    max-height: calc(100svh - 84px);
  }
}

@media (max-width: 620px) {
  .game-shell {
    gap: 8px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .hud {
    grid-template-columns: minmax(74px, 1fr) auto auto;
    min-height: 46px;
    padding: 6px 8px;
  }

  .brand {
    font-size: 0.78rem;
  }

  .hud-meters {
    grid-auto-columns: minmax(42px, auto);
    gap: 5px;
    font-size: 0.74rem;
  }

  .hud-meters span {
    min-height: 30px;
    padding: 0 7px;
  }

  #stageState {
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  canvas {
    max-height: calc(100svh - 132px);
  }
}
