:root {
  color-scheme: dark;
  --ink: #0b0d0f;
  --panel: #121417;
  --line: #f2a51b;
  --hot: #f0321d;
  --gold: #ffd34a;
  --cream: #f7f0d0;
  --grass: #6fa51f;
  --sky: #62c5d8;
}

* {
  box-sizing: border-box;
  -webkit-user-drag: none;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(9, 11, 12, 0.25), rgba(9, 11, 12, 0.9)),
    radial-gradient(circle at 50% 10%, #2c4150, #08090b 68%);
  font-family: "Trebuchet MS", Arial, sans-serif;
  color: var(--cream);
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

img,
input,
canvas,
button {
  -webkit-user-drag: none;
  user-drag: none;
}

.shell {
  width: min(100vw, 1340px);
  padding: 16px;
}

.page-layout {
  display: grid;
  grid-template-columns: minmax(0, 1040px) 260px;
  align-items: start;
  gap: 16px;
}

.game-frame {
  position: relative;
  overflow: hidden;
  border: 6px solid var(--line);
  background: var(--ink);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.topbar,
.bottombar {
  display: grid;
  align-items: center;
  gap: 16px;
  background: #0d1013;
  border-color: var(--line);
  text-shadow: 3px 3px 0 #000;
}

.topbar {
  grid-template-columns: 74px 150px 1fr 150px;
  min-height: 110px;
  padding: 14px 22px;
  border-bottom: 5px solid var(--line);
}

.portrait,
.bonus-face {
  position: relative;
  image-rendering: pixelated;
}

.portrait {
  width: 66px;
  height: 66px;
  border-radius: 8px;
  background:
    #090a0c url("../assets/rotbart-avatar.png") center / contain no-repeat;
  border: 3px solid #222;
}

.stats {
  display: grid;
  gap: 6px;
  font-size: 28px;
  font-weight: 900;
  color: var(--cream);
}

#lives {
  color: var(--hot);
  letter-spacing: 2px;
}

.brand {
  text-align: center;
  line-height: 0.9;
}

.brand strong {
  display: block;
  font-size: clamp(32px, 5vw, 58px);
  font-weight: 1000;
  color: #fff;
}

.brand strong span {
  color: var(--hot);
}

.brand small,
.unlock strong,
.scoreboard span {
  color: var(--gold);
  font-size: 24px;
  font-weight: 1000;
}

.scoreboard {
  display: grid;
  justify-items: end;
  gap: 6px;
  font-size: 32px;
  font-weight: 1000;
}

.leaderboard-mobile-open {
  display: none;
}

#game {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--sky);
}

#game canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

.touch-controls {
  display: none;
}

.bottombar {
  grid-template-columns: 170px 1fr;
  min-height: 94px;
  padding: 12px 20px;
  border-top: 5px solid var(--line);
}

.bonus,
.unlock {
  min-height: 66px;
  border: 4px solid #777;
  background: #12161a;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  font-size: 26px;
  font-weight: 1000;
}

.bonus-face {
  width: 38px;
  height: 38px;
  background: #e8692d;
  border-radius: 4px;
  border-top: 10px solid #050505;
}

.unlock {
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  border-color: var(--line);
  text-align: center;
  line-height: 1;
}

.unlock span {
  font-size: 24px;
}

.message {
  position: absolute;
  inset: 110px 0 94px;
  z-index: 4;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: rgba(5, 7, 8, 0.44);
  text-align: center;
  text-shadow: 4px 4px 0 #000;
}

.message strong {
  max-width: 880px;
  color: var(--gold);
  font-size: clamp(44px, 8vw, 92px);
  font-weight: 1000;
}

.message span {
  color: #8cf13c;
  font-size: clamp(26px, 4vw, 46px);
  font-weight: 1000;
}

.message button {
  min-height: 48px;
  padding: 0 22px;
  border: 3px solid var(--cream);
  background: var(--hot);
  color: #fff;
  font: inherit;
  font-size: 22px;
  font-weight: 1000;
  cursor: pointer;
}

.start-screen {
  position: absolute;
  inset: 110px 0 94px;
  z-index: 8;
  display: grid;
  place-content: center;
  background: rgba(5, 7, 8, 0.72);
  text-align: center;
  text-shadow: 3px 3px 0 #000;
}

.name-panel {
  width: min(420px, calc(100vw - 40px));
  border: 5px solid var(--line);
  background: #101418;
  padding: 22px;
  display: grid;
  gap: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}

.name-panel strong {
  color: #fff;
  font-size: 42px;
  font-weight: 1000;
}

.name-panel label {
  color: var(--gold);
  font-size: 22px;
  font-weight: 1000;
}

.name-panel input {
  min-height: 54px;
  border: 3px solid #777;
  background: #050607;
  color: #fff;
  padding: 0 14px;
  font: inherit;
  font-size: 24px;
  font-weight: 900;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}

.name-panel button,
.leaderboard-close,
.leaderboard-mobile-open {
  border: 3px solid var(--cream);
  background: var(--hot);
  color: #fff;
  font: inherit;
  font-weight: 1000;
  cursor: pointer;
}

.name-panel button {
  min-height: 52px;
  font-size: 24px;
}

.leaderboard-panel,
.leaderboard-dialog {
  border: 6px solid var(--line);
  background: #0d1013;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

.leaderboard-panel {
  min-height: 360px;
  padding: 14px;
}

.leaderboard-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 4px solid var(--line);
  padding-bottom: 10px;
  text-shadow: 3px 3px 0 #000;
}

.leaderboard-head strong {
  color: var(--gold);
  font-size: 24px;
  font-weight: 1000;
}

.leaderboard-head span {
  color: #8cf13c;
  font-size: 13px;
  font-weight: 900;
}

.leaderboard-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.leaderboard-list li {
  min-height: 36px;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  border: 3px solid #2f363d;
  background: #14191e;
  padding: 6px 8px;
  font-size: 16px;
  font-weight: 1000;
}

.leaderboard-list li.empty {
  display: block;
  text-align: center;
  color: #aaa;
}

.leaderboard-list span {
  color: var(--gold);
}

.leaderboard-list strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-list em {
  color: #fff;
  font-style: normal;
}

.leaderboard-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.72);
}

.leaderboard-dialog {
  position: relative;
  width: min(92vw, 420px);
  padding: 16px;
}

.leaderboard-close {
  position: absolute;
  top: -16px;
  right: -16px;
  width: 42px;
  height: 42px;
  font-size: 28px;
  line-height: 1;
}

.hidden {
  display: none;
}

@media (max-width: 760px) {
  body {
    align-items: start;
  }

  .shell {
    width: 100vw;
    min-height: 100dvh;
    padding: 0;
  }

  .page-layout {
    display: block;
  }

  .leaderboard-panel {
    display: none;
  }

  .game-frame {
    border-width: 4px;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
  }

  .topbar {
    position: relative;
    grid-template-columns: 52px 1fr 112px;
    gap: 10px;
    min-height: 86px;
    padding: 10px;
  }

  .portrait {
    width: 50px;
    height: 50px;
  }

  .brand {
    grid-column: 2;
    grid-row: 1;
  }

  .brand small {
    font-size: 15px;
  }

  .stats {
    grid-column: 1 / 3;
    grid-row: 2;
    grid-auto-flow: column;
    justify-content: start;
    font-size: 18px;
  }

  .scoreboard {
    grid-column: 3;
    grid-row: 1 / 3;
    font-size: 22px;
  }

  .leaderboard-mobile-open {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: block;
    min-height: 30px;
    padding: 0 8px;
    font-size: 12px;
  }

  .scoreboard span {
    font-size: 16px;
  }

  .bottombar {
    grid-template-columns: 1fr;
    min-height: 82px;
    padding: 8px;
  }

  .bonus {
    display: none;
  }

  .unlock {
    min-height: 58px;
    font-size: 18px;
  }

  .unlock strong,
  .unlock span {
    font-size: 18px;
  }

  .message {
    inset: 86px 0 82px;
  }

  .start-screen {
    inset: 86px 0 82px;
  }

  .name-panel {
    width: min(360px, calc(100vw - 28px));
    padding: 16px;
  }

  .name-panel strong {
    font-size: 32px;
  }

  .name-panel label,
  .name-panel input,
  .name-panel button {
    font-size: 20px;
  }

  #game {
    flex: 1 1 auto;
    min-height: 0;
    aspect-ratio: auto;
  }

  .touch-controls {
    pointer-events: none;
    position: absolute;
    inset: auto 0 86px;
    z-index: 5;
    display: flex;
    align-items: end;
    justify-content: space-between;
    padding: 0 16px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }

  .touch-pad {
    pointer-events: auto;
    display: grid;
    grid-template-columns: 64px 64px;
    gap: 10px;
  }

  .touch-button {
    pointer-events: auto;
    width: 64px;
    height: 64px;
    border: 4px solid rgba(247, 240, 208, 0.88);
    background: rgba(10, 12, 14, 0.72);
    color: #fff;
    font: inherit;
    font-size: 38px;
    font-weight: 1000;
    line-height: 1;
    text-shadow: 3px 3px 0 #000;
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.62);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
  }

  .touch-button.jump {
    width: 76px;
    height: 76px;
    border-color: var(--gold);
    background: rgba(214, 56, 27, 0.78);
  }

  .touch-button:active,
  .touch-button.active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.72);
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  .topbar {
    min-height: 64px;
    padding: 6px 10px;
  }

  .portrait {
    width: 44px;
    height: 44px;
  }

  .brand strong {
    font-size: 28px;
  }

  .brand small,
  .scoreboard span {
    font-size: 13px;
  }

  .stats {
    font-size: 16px;
  }

  .scoreboard {
    font-size: 20px;
  }

  .bottombar {
    min-height: 58px;
    padding: 6px;
  }

  .unlock {
    min-height: 44px;
  }

  .unlock strong,
  .unlock span {
    font-size: 14px;
  }

  .message {
    inset: 64px 0 58px;
  }

  .touch-controls {
    inset: auto 0 62px;
  }
}
