:root {
  color-scheme: dark;
  --ink: #231007;
  --paper: #fff3a9;
  --gold: #ffb300;
  --gold-hot: #ff6a00;
  --leaf: #41c63d;
  --vine: #7c1f3d;
  --shadow: rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(94, 197, 89, 0.26), transparent 24rem),
    linear-gradient(135deg, #13291b, #060b0a 58%, #1d1018);
  font-family: Impact, Haettenschweiler, "Arial Black", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  letter-spacing: 0;
}

.game-shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.stage {
  position: relative;
  width: min(100vw - 24px, calc((100vh - 24px) * 16 / 9), 1280px);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #1e9dea;
  border: 4px solid #100805;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.55), inset 0 0 0 3px rgba(255, 255, 255, 0.22);
}

.stage.hit-shake {
  animation: screen-hit-shake 360ms steps(2, end);
}

@keyframes screen-hit-shake {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }

  14% {
    transform: translate3d(-10px, 6px, 0) rotate(-0.35deg);
  }

  28% {
    transform: translate3d(12px, -7px, 0) rotate(0.4deg);
  }

  42% {
    transform: translate3d(-8px, -5px, 0) rotate(-0.28deg);
  }

  58% {
    transform: translate3d(9px, 5px, 0) rotate(0.24deg);
  }

  74% {
    transform: translate3d(-5px, 2px, 0) rotate(-0.15deg);
  }
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.title-layer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 270px);
  grid-template-rows: 1fr auto;
  gap: clamp(10px, 2vw, 22px);
  align-items: end;
  padding: clamp(12px, 3vw, 32px);
}

.title-art {
  grid-column: 1 / -1;
  grid-row: 1 / span 2;
  align-self: center;
  justify-self: start;
  z-index: 0;
  width: min(37.5vw, 358px);
  max-height: min(44vh, 260px);
  object-fit: contain;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.52));
  image-rendering: pixelated;
}

.title-actions {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
  display: flex;
  gap: 10px;
  align-self: end;
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

.primary-button,
.plain-button {
  min-width: clamp(92px, 12vw, 150px);
  min-height: clamp(42px, 6vw, 58px);
  padding: 0 18px;
  border-radius: 6px;
  color: #160701;
  text-shadow: 0 2px rgba(255, 255, 255, 0.34);
  box-shadow: 0 6px 0 #160701, 0 10px 22px rgba(0, 0, 0, 0.32);
}

.primary-button {
  background: linear-gradient(#ffd841 0 48%, var(--gold) 49% 100%);
  outline: 3px solid #fff7cf;
}

.plain-button {
  background: linear-gradient(#fdf9dc 0 48%, #bfe151 49% 100%);
  outline: 3px solid #160701;
}

.primary-button:active,
.plain-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #160701, 0 5px 14px rgba(0, 0, 0, 0.32);
}

.score-table {
  position: relative;
  z-index: 1;
  align-self: end;
  justify-self: end;
  min-width: min(100%, 250px);
  padding: 12px 14px 14px;
  border-radius: 6px;
  background: rgba(255, 244, 178, 0.94);
  color: var(--ink);
  box-shadow: 0 8px 0 #150704, 0 18px 34px rgba(0, 0, 0, 0.35);
  outline: 3px solid #fffef0;
  pointer-events: auto;
}

.score-table h2 {
  margin: 0 0 8px;
  font-size: clamp(18px, 2.5vw, 26px);
  line-height: 1;
  color: #f26a00;
  -webkit-text-stroke: 1px #150704;
  text-shadow: 2px 2px 0 #fff7c1;
}

.score-row {
  display: grid;
  grid-template-columns: 2ch 1fr auto;
  gap: 8px;
  align-items: baseline;
  padding: 4px 0;
  border-top: 2px solid rgba(35, 16, 7, 0.16);
  font-size: clamp(14px, 2.1vw, 19px);
}

.score-row:first-of-type {
  border-top: 0;
}

.title-layer .score-table {
  grid-column: 2 / 3;
  grid-row: 1 / span 2;
}

.score-row span {
  min-width: 0;
}

.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  display: flex;
  gap: 10px;
  pointer-events: none;
}

.meter {
  min-width: 110px;
  padding: 7px 10px 8px;
  border-radius: 6px;
  background: rgba(255, 243, 169, 0.94);
  color: var(--ink);
  box-shadow: 0 5px 0 #150704;
  outline: 2px solid #fff7cf;
}

.meter span,
.final-score span {
  display: block;
  font-size: 12px;
  line-height: 1;
  color: #5f2307;
}

.meter strong,
.final-score strong {
  display: block;
  font-size: clamp(24px, 4vw, 42px);
  line-height: 0.94;
}

.jump-button {
  position: absolute;
  right: clamp(12px, 3vw, 26px);
  bottom: clamp(12px, 3vw, 26px);
  z-index: 3;
  width: clamp(82px, 12vw, 132px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #fff8b8 0 14%, #ffd232 15% 48%, #f45c00 49% 100%);
  color: #1a0701;
  border: 4px solid #fff7cf;
  box-shadow: 0 8px 0 #150704, 0 16px 28px rgba(0, 0, 0, 0.32);
}

.jump-button:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #150704, 0 9px 18px rgba(0, 0, 0, 0.32);
}

.jump-button.swim-mode {
  background: radial-gradient(circle at 35% 28%, #e5fdff 0 14%, #55ddf8 15% 48%, #057cc4 49% 100%);
  color: #041b25;
}

.jump-button.buggy-mode {
  background: radial-gradient(circle at 35% 28%, #fff7d8 0 14%, #ff5a2d 15% 48%, #a71912 49% 100%);
  color: #1a0701;
}

.fullscreen-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 6;
  min-width: 64px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 6px;
  background: linear-gradient(#fdf9dc 0 48%, #bfe151 49% 100%);
  color: #160701;
  border: 0;
  outline: 3px solid #150704;
  box-shadow: 0 5px 0 #150704, 0 12px 20px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
}

.fullscreen-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #150704, 0 7px 16px rgba(0, 0, 0, 0.28);
}

.game-over-layer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 280px);
  align-content: center;
  align-items: center;
  gap: clamp(12px, 3vw, 30px);
  padding: clamp(14px, 3vw, 34px);
  background: linear-gradient(rgba(4, 16, 14, 0.24), rgba(4, 16, 14, 0.46));
}

.end-logo {
  width: min(52%, 280px);
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.5));
}

.final-score,
.score-form,
.end-actions {
  grid-column: 1 / 2;
  justify-self: start;
}

.final-score {
  padding: 12px 16px;
  border-radius: 6px;
  background: rgba(255, 243, 169, 0.95);
  color: var(--ink);
  box-shadow: 0 7px 0 #150704;
  outline: 3px solid #fff7cf;
}

.score-form {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.score-form input {
  width: 88px;
  min-height: 52px;
  border: 3px solid #150704;
  border-radius: 6px;
  background: #fff8c9;
  color: #231007;
  text-align: center;
  text-transform: uppercase;
  box-shadow: 0 5px 0 #150704;
}

.end-actions {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.game-over-layer .score-table {
  grid-column: 2 / 3;
  grid-row: 1 / span 4;
}

[hidden] {
  display: none !important;
}

@media (max-width: 740px) {
  .title-layer,
  .game-over-layer {
    grid-template-columns: 1fr;
  }

  .title-art {
    width: min(46vw, 345px);
  }

  .score-table,
  .game-over-layer .score-table {
    grid-column: 1;
    grid-row: auto;
    justify-self: stretch;
  }

  .title-actions,
  .end-actions {
    justify-content: flex-start;
  }

  .score-table {
    padding: 9px 10px 10px;
  }
}

@media (max-height: 460px) {
  .title-art {
    width: min(37vw, 320px);
    max-height: 44vh;
  }

  .score-table {
    max-height: 45vh;
    overflow: hidden;
  }
}
