* {
  box-sizing: border-box;
}

:root {
  --game-stage-width: 100vw;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0715;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

body {
  position: fixed;
  inset: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.app {
  width: 100vw;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#game-canvas {
  display: block;
  image-rendering: auto;
  touch-action: none;
}

.hidden {
  display: none !important;
}

.end-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.62);
  touch-action: manipulation;
}

.end-panel {
  width: min(940px, 94vw);
  max-width: calc(var(--game-stage-width, 100vw) - 24px);
  max-height: calc(var(--game-stage-height, 100dvh) - 24px);
  overflow: hidden;
  padding: 0;
  border: 5px solid #000000;
  background: #ff5cb8;
  color: #000000;
  font-family: "Akzidenz-Grotesk BQ", "Akzidenz-Grotesk Pro", "Helvetica Neue", "Arial Black", "Impact", sans-serif;
  text-transform: uppercase;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.end-panel-content {
  width: 100%;
  padding: 28px 24px;
  transform-origin: top center;
  transform: scale(var(--end-panel-scale, 1));
}

.end-panel h1,
.end-panel h2,
.end-panel p,
.end-panel li,
.end-panel label,
.end-panel button {
  margin: 0;
  letter-spacing: 0.02em;
  font-weight: 900;
  color: #000000;
  -webkit-text-stroke: 1.5px #ffffff;
  paint-order: stroke fill;
  text-shadow:
    1px 0 #ffffff,
    -1px 0 #ffffff,
    0 1px #ffffff,
    0 -1px #ffffff,
    0.75px 0.75px #ffffff,
    -0.75px 0.75px #ffffff,
    0.75px -0.75px #ffffff,
    -0.75px -0.75px #ffffff;
}

.end-panel h1 {
  text-align: center;
  font-size: clamp(36px, 7vw, 64px);
  white-space: nowrap;
}

.final-score {
  margin-top: 10px !important;
  text-align: center;
  font-size: var(--end-final-score-size, clamp(24px, 4.2vw, 46px));
  white-space: nowrap;
  display: block;
  width: 100%;
  padding: 0 10px;
  line-height: 1;
}

.end-panel h2 {
  margin-top: 0 !important;
  text-align: center;
  font-size: clamp(24px, 4vw, 36px);
  line-height: 0.95;
  white-space: normal;
}

.leaderboard-section {
  margin-top: 18px;
}

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

.leaderboard-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 8px;
  font-size: var(--end-leaderboard-row-size, clamp(16px, 3.1vw, 30px));
}

.leaderboard-rank {
  min-width: 44px;
}

.leaderboard-name {
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  min-width: 0;
}

.end-actions {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.end-panel button {
  width: 100%;
  min-height: 62px;
  border: none;
  background: #5fb7f9;
  color: #000000;
  font-size: clamp(20px, 3.6vw, 28px);
  cursor: pointer;
  touch-action: manipulation;
}

.score-entry-form {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.score-entry-form label {
  font-size: clamp(18px, 3vw, 24px);
}

.score-entry-form input {
  width: 100%;
  min-height: 56px;
  padding: 10px 12px;
  border: 4px solid #000000;
  background: #ffffff;
  color: #000000;
  font-size: clamp(20px, 3.4vw, 28px);
  font-family: "Akzidenz-Grotesk BQ", "Akzidenz-Grotesk Pro", "Helvetica Neue", "Arial Black", "Impact", sans-serif;
  text-transform: uppercase;
}

#email-input {
  text-transform: none;
}

.score-entry-form input:focus {
  outline: 3px solid #000000;
  outline-offset: 2px;
}

.entry-feedback {
  margin-top: 10px !important;
  text-align: center;
  min-height: 28px;
  font-size: clamp(16px, 2.8vw, 22px);
}

@media (max-width: 640px) {
  .end-panel {
    padding: 20px 14px;
  }

  .leaderboard-rank {
    min-width: 44px;
  }
}
