:root {
  color-scheme: dark;
  --paper: #f9f7e8;
  --ink: #182231;
  --gold: #ffb22d;
  --red: #e94225;
  --blue: #ff6b2c;
  --green: #5fbf71;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 93, 32, 0.28), transparent 30%),
    radial-gradient(circle at 18% 82%, rgba(255, 178, 45, 0.16), transparent 28%),
    linear-gradient(180deg, #110506 0%, #2a0d10 48%, #080506 100%);
  color: var(--paper);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

button {
  font: inherit;
}

.site-layout {
  width: min(calc(100vw - 24px), 990px);
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 742px);
  gap: 14px;
  align-items: center;
}

.site-leaderboard {
  align-self: stretch;
  min-height: 0;
  padding: 14px 12px;
  border: 3px solid #07101d;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 130, 42, 0.17) 0 2px, transparent 2px calc(100% - 2px), rgba(255, 130, 42, 0.17) calc(100% - 2px)),
    linear-gradient(180deg, rgba(64, 24, 16, 0.96), rgba(13, 5, 7, 0.98));
  box-shadow:
    0 18px 54px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -5px 0 rgba(0, 0, 0, 0.24);
}

.leaderboard-board + .leaderboard-board {
  margin-top: 18px;
}

.site-leaderboard h2 {
  margin: 0 0 7px;
  color: #ffe27c;
  font-size: 17px;
  line-height: 1;
  text-align: center;
  text-shadow: 2px 2px 0 #050202;
  -webkit-text-stroke: 0;
}

.site-leaderboard table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.site-leaderboard th,
.site-leaderboard td {
  padding: 5px 4px;
  border-bottom: 1px solid rgba(255, 178, 45, 0.18);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-leaderboard th {
  color: #ffb22d;
  font-size: 9px;
  letter-spacing: 0;
}

.site-leaderboard td {
  color: #fff1bc;
  text-shadow: 1px 1px 0 #050202;
}

.site-leaderboard th:nth-child(1),
.site-leaderboard td:nth-child(1) {
  width: 20px;
  color: #ff8f26;
  text-align: center;
}

.site-leaderboard th:nth-child(2),
.site-leaderboard td:nth-child(2) {
  width: auto;
}

.site-leaderboard th:nth-child(3),
.site-leaderboard td:nth-child(3) {
  width: 58px;
  text-align: right;
}

.shell {
  position: relative;
  width: min(100%, 742px, calc(100vh * 371 / 240));
  aspect-ratio: 371 / 240;
  display: grid;
  place-items: center;
}

#game {
  width: 100%;
  height: 100%;
  aspect-ratio: 371 / 240;
  border: 5px solid #07101d;
  border-radius: 8px;
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.62),
    0 0 0 2px rgba(255, 111, 42, 0.2),
    inset 0 0 0 2px rgba(255, 255, 255, 0.12);
  image-rendering: auto;
  background: #1a0b0c;
}

.hud {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  pointer-events: none;
}

.hud > div {
  min-width: 0;
}

.hud-label {
  display: block;
  color: #b8d8ee;
  font-size: 11px;
  line-height: 1;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  overflow: hidden;
  color: var(--paper);
  font-size: clamp(18px, 5vw, 28px);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 2px 2px 0 #111827;
}

.icon-button,
.touch-button,
.secondary-button,
.primary-button {
  border: 2px solid #07101d;
  color: var(--paper);
  background: linear-gradient(180deg, #4a2018 0%, #120708 100%);
  box-shadow:
    0 3px 0 #03070d,
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -2px 0 rgba(0, 0, 0, 0.28);
  cursor: pointer;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  color: #f9f7e8;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 18px;
  font-weight: 900;
}

.volume-control {
  display: grid;
  gap: 3px;
  min-width: 150px;
  color: #ffd2a3;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.volume-control input {
  width: 150px;
  accent-color: var(--gold);
  filter: drop-shadow(0 1px 0 #050912);
}

.icon-button:active,
.touch-button:active,
.secondary-button:active,
.primary-button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #111827;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 26px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 34%, rgba(255, 95, 32, 0.2), transparent 28%),
    rgba(11, 5, 7, 0.76);
  text-align: center;
  backdrop-filter: blur(4px);
}

.overlay.hidden {
  display: none;
}

.overlay:not(.hidden) ~ .hud,
.overlay:not(.hidden) ~ .touch-pad {
  display: none;
}

.pause-menu {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(8, 4, 5, 0.52);
  backdrop-filter: blur(2px);
}

.pause-menu.hidden {
  display: none;
}

.pause-menu:not(.hidden) ~ .touch-pad {
  display: none;
}

.pause-card {
  display: grid;
  gap: 22px;
  justify-items: center;
  min-width: 250px;
  padding: 26px 30px;
  border: 2px solid rgba(255, 138, 54, 0.48);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 178, 45, 0.12) 0 3px, transparent 3px),
    linear-gradient(180deg, rgba(61, 27, 20, 0.96), rgba(12, 6, 8, 0.96));
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.13),
    inset 0 -4px 0 rgba(0, 0, 0, 0.3);
}

.pause-card h2 {
  font-size: clamp(46px, 11vw, 72px);
}

.pause-settings {
  display: grid;
  grid-template-columns: 44px auto;
  gap: 14px;
  align-items: center;
}

.title-wrap {
  display: grid;
  gap: 10px;
  text-shadow: 4px 4px 0 #050202, 0 0 24px rgba(255, 94, 32, 0.34);
}

h1,
h2 {
  margin: 0;
  color: var(--gold);
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  font-size: clamp(58px, 16vw, 94px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.92;
  text-transform: uppercase;
  -webkit-text-stroke: 2px #07101d;
}

h2 {
  font-size: clamp(48px, 14vw, 78px);
}

.best-line {
  color: var(--paper);
  font-size: clamp(18px, 5vw, 28px);
  font-weight: 900;
  text-shadow: 2px 2px 0 #050912;
}

.leaderboard-form {
  display: grid;
  gap: 8px;
  justify-items: center;
  min-width: min(420px, 84%);
}

.leaderboard-form.hidden {
  display: none;
}

.leaderboard-form label {
  color: #ffe27c;
  font-size: clamp(16px, 3vw, 22px);
  font-weight: 900;
  text-shadow: 2px 2px 0 #050202;
  text-transform: uppercase;
}

.leaderboard-form input {
  width: min(320px, 100%);
  height: 42px;
  border: 2px solid #07101d;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff1bc, #ffbd59);
  color: #182231;
  font: 900 24px "Segoe UI", Arial, sans-serif;
  text-align: center;
  text-transform: uppercase;
  box-shadow:
    0 4px 0 #03070d,
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.leaderboard-status {
  min-height: 18px;
  color: #ffd2a3;
  font-size: 13px;
  font-weight: 800;
  text-shadow: 1px 1px 0 #050202;
}

.leaderboard-list {
  display: grid;
  gap: 3px;
  min-width: min(440px, 88%);
  max-height: 96px;
  margin: -6px 0 0;
  padding: 0;
  overflow: hidden;
  color: #fff1bc;
  font-size: clamp(12px, 2.2vw, 16px);
  font-weight: 850;
  list-style-position: inside;
  text-align: left;
  text-shadow: 1px 1px 0 #050202;
}

.primary-button {
  min-width: 176px;
  min-height: 52px;
  padding: 10px 22px;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffe27c 0%, #ffb22d 42%, #e34a1f 100%);
  color: #182231;
  font-size: 22px;
  font-weight: 900;
  text-transform: uppercase;
}

.secondary-button {
  min-width: 150px;
  min-height: 46px;
  padding: 8px 16px;
  border-radius: 8px;
  background: linear-gradient(180deg, #4a2018 0%, #211011 100%);
  color: #ffe27c;
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
}

.secondary-button.hidden {
  display: none;
}

.primary-button:disabled {
  opacity: 0.45;
  filter: grayscale(0.45);
}

.game-over-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.touch-pad {
  position: absolute;
  left: calc(50% - 350px);
  right: calc(50% - 350px);
  bottom: 16px;
  display: none;
  grid-template-columns: 58px 58px 1fr 72px;
  gap: 10px;
  pointer-events: none;
}

.touch-button {
  width: 58px;
  height: 54px;
  border-radius: 8px;
  background: rgba(249, 247, 232, 0.9);
  color: #111827;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  pointer-events: auto;
  touch-action: none;
}

.touch-button.jump {
  grid-column: 4;
  width: 72px;
  background: var(--red);
  color: var(--paper);
}

@media (pointer: coarse), (max-width: 760px) {
  .touch-pad {
    display: grid;
  }
}
