:root {
  font-family: 'Press Start 2P', 'VT323', monospace;
  background-color: #ffffff;
  color: #000000;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #ffffff;
}

.app {
  width: min(460px, 100%);
  padding: 1rem;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud {
  display: flex;
  justify-content: center;
  align-self: stretch;
}
@media (pointer: coarse) {
  .hud {
    display: none;
  }
}

.stage-shell {
  position: relative;
  width: 100%;
}

.stage {
  margin-top: 0.75rem;
  border: 4px solid #000;
  padding: 4px;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.score-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.65);
  z-index: 5;
}

.score-overlay[hidden] {
  display: none;
}

.score-overlay__panel {
  border: 4px solid #000;
  background: #fff;
  padding: 1rem;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25);
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  background: #ffffff;
  image-rendering: pixelated;
}

.controls {
  display: none;
  margin-top: 1rem;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
}

.controls__row {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.controls__row--main {
  gap: 1rem;
}

.control-btn {
  min-width: 72px;
  min-height: 72px;
  border: 3px solid #000;
  border-radius: 12px;
  background: #fff;
  color: #000;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.85rem;
  text-transform: uppercase;
  box-shadow: 0 4px 0 #000;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 60ms ease, box-shadow 60ms ease;
}

.control-btn:active,
.control-btn.is-pressed {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #000;
}

@media (pointer: coarse) {
  .controls {
    display: grid;
  }
}

@media (pointer: coarse) and (min-width: 640px) {
.controls {
    margin-left: auto;
    margin-right: auto;
    max-width: 360px;
  }
}

[hidden] {
  display: none !important;
}

.layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 400px;
  align-self: center;
}

.panel {
  border: 4px solid #000;
  padding: 1rem;
  background: #fff;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.panel__refresh {
  border: 2px solid #000;
  background: #fff;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  transition: background 0.2s, transform 0.2s;
}

.panel__refresh:hover {
  background: #f0f0f0;
  transform: rotate(8deg);
}

.panel__refresh:focus-visible {
  outline: 3px solid #000;
  outline-offset: 2px;
}

.stats__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.stats__row + .stats__row {
  margin-top: 0.5rem;
}

.stats__hint {
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: #444;
}

.score-form__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.score-overlay__close {
  border: 2px solid #000;
  background: #fff;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  line-height: 1;
}

.score-overlay__hint {
  margin: 0 0 0.5rem;
  font-size: 0.7rem;
  color: #444;
}

.score-overlay__close:focus-visible {
  outline: 3px solid #000;
  outline-offset: 2px;
}

.panel h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.score-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.score-form__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.score-form__label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
}

.score-form input {
  border: 3px solid #000;
  padding: 0.35rem 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
}

.score-form button {
  border: 3px solid #000;
  padding: 0.5rem;
  font-family: inherit;
  font-size: 0.85rem;
  text-transform: uppercase;
  cursor: pointer;
  background: #ffe600;
}

.score-form button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.score-form__status {
  min-height: 1.2em;
  font-size: 0.7rem;
  margin: 0;
}

.score-form__status[data-tone='success'] {
  color: #0b7a0b;
}

.score-form__status[data-tone='error'] {
  color: #b00020;
}

.score-form__status[data-tone='info'] {
  color: #004cff;
}

.leaderboard__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.leaderboard__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 2px solid #000;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
}

.leaderboard__rank {
  width: 2rem;
}

.leaderboard__info {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.leaderboard__score {
  width: 3rem;
  text-align: right;
}

.leaderboard__speed {
  font-size: 0.65rem;
  color: #333;
}

.leaderboard__empty {
  font-size: 0.8rem;
  margin-top: 0.75rem;
}

.leaderboard__empty[data-tone='error'] {
  color: #b00020;
}

@media (min-width: 900px) {
  body {
    align-items: flex-start;
  }

  .app {
    width: 100%;
    align-items: flex-start;
  }

  .layout {
    display: grid;
    grid-template-columns: 420px minmax(220px, 320px);
    gap: 1.5rem;
    align-items: start;
    justify-content: center;
  }

  .stage-shell {
    margin: 0;
    grid-column: 1 / 2;
  }

  .stage {
    margin: 0;
  }

  .sidebar {
    grid-column: 2 / 3;
    max-width: 320px;
    align-self: flex-start;
  }
}
.site-footer {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.65rem;
  color: #666;
  width: 100%;
  padding-bottom: 1rem;
  flex: 0 0 auto;
}

.site-footer a {
  color: inherit;
  text-decoration: underline;
}
