:root {
  --chrome: 94px;
  --ink: #f8fafc;
  --panel: rgba(15, 23, 42, .72);
  --line: rgba(255, 255, 255, .18);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #10151f;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
  justify-items: center;
  padding: max(10px, env(safe-area-inset-top)) 10px 0;
  background:
    radial-gradient(circle at 30% 0%, rgba(255, 214, 117, .32), transparent 34%),
    linear-gradient(180deg, #102238 0%, #172032 58%, #111827 100%);
}

.stage-wrap {
  position: relative;
  width: min(100%, calc((100dvh - var(--chrome) - env(safe-area-inset-top)) * .5625));
  max-width: 520px;
  aspect-ratio: 9 / 16;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #75d3ff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .46);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
}

.top-bar {
  position: absolute;
  left: 10px;
  right: 10px;
  top: max(10px, env(safe-area-inset-top));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  pointer-events: none;
}

.top-bar span {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12);
  color: #fff8dc;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  letter-spacing: 0;
  white-space: nowrap;
}

.top-bar span:first-child {
  text-align: left;
}

.top-bar span:last-child {
  text-align: right;
}

.mute-button {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 36px);
  right: 10px;
  z-index: 3;
  min-width: 78px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12);
  color: #fff8dc;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
}

.mute-button[aria-pressed="true"] {
  color: #cbd5e1;
  background: rgba(15, 23, 42, .52);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: min(86%, 380px);
  transform: translateX(-50%);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 23, 42, .78);
  color: #fff8dc;
  font-size: 14px;
  font-weight: 750;
  text-align: center;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.toast.hide {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
}

.end-panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(2, 6, 23, .54);
}

.end-panel.hidden {
  display: none;
}

.end-card {
  width: min(92%, 390px);
  max-height: calc(100% - 28px);
  overflow: auto;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 8px;
  background: rgba(15, 23, 42, .92);
  box-shadow: 0 18px 45px rgba(0, 0, 0, .38), inset 0 1px 0 rgba(255, 255, 255, .1);
}

.end-kicker,
.score-board p {
  margin: 0 0 8px;
  color: #ffd76a;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0;
}

.end-card h1 {
  margin: 0;
  color: #fff8dc;
  font-size: clamp(26px, 7vw, 38px);
  line-height: 1.05;
  letter-spacing: 0;
}

.end-score {
  margin: 12px 0 0;
  color: #ffffff;
  font-size: 22px;
  font-weight: 950;
}

.end-message {
  margin: 8px 0 14px;
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.35;
}

.high-score-form {
  margin: 0 0 14px;
}

.high-score-form[hidden],
.play-again-button[hidden],
.decline-score-button[hidden] {
  display: none;
}

.high-score-form label {
  display: block;
  margin: 0 0 6px;
  color: #fff8dc;
  font-size: 12px;
  font-weight: 900;
}

.name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 8px;
}

.name-row input {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 8px;
  background: rgba(255, 255, 255, .95);
  color: #111827;
  font: 900 18px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  text-transform: uppercase;
  padding: 0 10px;
}

.name-row button,
.decline-score-button,
.play-again-button {
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff3a6 0%, #ffd05d 60%, #f7ad3e 100%);
  color: #172032;
  font-weight: 950;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .24), inset 0 1px 0 rgba(255, 255, 255, .52);
}

.score-board {
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 8px;
  background: rgba(2, 6, 23, .28);
}

.score-board ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.score-board li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 850;
}

.score-board .empty-score {
  grid-template-columns: 1fr;
  color: #cbd5e1;
}

.score-board .score-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-board .score-eur {
  color: #fff8dc;
}

.play-again-button {
  width: 100%;
  font-size: 17px;
}

.decline-score-button {
  width: 100%;
  margin: 0 0 14px;
  font-size: 15px;
}

.controls {
  width: 100%;
  max-width: 560px;
  display: grid;
  grid-template-columns: 64px minmax(150px, 1fr) 64px;
  gap: 12px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(17, 24, 39, 0), rgba(17, 24, 39, .96) 22%);
}

.jump-button,
.icon-button {
  height: 58px;
  border: 0;
  border-radius: 8px;
  color: #172032;
  font-weight: 950;
  letter-spacing: 0;
  box-shadow: 0 7px 0 rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255, 255, 255, .52);
}

.jump-button {
  background: linear-gradient(180deg, #fff3a6 0%, #ffd05d 60%, #f7ad3e 100%);
  font-size: 20px;
}

.icon-button {
  background: linear-gradient(180deg, #f8fafc 0%, #cbd5e1 100%);
  font-size: 18px;
}

.jump-button:active,
.icon-button:active {
  transform: translateY(3px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .2), inset 0 1px 0 rgba(255, 255, 255, .45);
}

@media (min-width: 820px) and (pointer: fine) {
  :root {
    --chrome: 20px;
  }

  .game-shell {
    padding: 10px;
  }

  .controls {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 270px;
    grid-template-columns: 48px 1fr 48px;
    padding: 0;
    background: transparent;
  }

  .jump-button,
  .icon-button {
    height: 48px;
  }
}

@media (max-width: 360px) {
  .controls {
    grid-template-columns: 54px minmax(130px, 1fr) 54px;
    gap: 9px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .top-bar span {
    padding: 7px 8px;
    font-size: 12px;
  }
}
