:root {
  --bg: #000000;
  --panel: #111111;
  --mid: #686868;
  --text: #f3f3f3;
  --ink: #050505;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  letter-spacing: 0.12em;
  padding: 16px 0;
}

.game-shell {
  width: min(96vw, 980px);
  background: var(--panel);
  border: 2px solid var(--text);
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.04);
  padding: 14px 14px 10px;
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0 6px 10px;
  border-bottom: 2px solid var(--text);
}

.play-friends-button {
  position: relative;
  z-index: 31;
  display: grid;
  place-items: center;
  min-height: 28px;
  padding: 6px 9px;
  border: 1px solid #aaa;
  background: #111;
  color: var(--text);
  font: inherit;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  cursor: pointer;
}

.play-friends-button[hidden] {
  display: none;
}

.play-friends-button:hover,
.play-friends-button:focus-visible {
  border-color: #fff;
  background: #292929;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.label {
  color: var(--text);
}

.meta {
  color: var(--text);
  text-align: right;
  font-size: 0.72rem;
}

.timer-expired {
  color: #aaa;
  font-weight: 800;
  text-decoration: underline;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  border: 2px solid var(--text);
  margin-top: 10px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.game-stage {
  position: relative;
  margin-top: 10px;
}

.game-stage #game {
  margin-top: 0;
}

.galaxy-dialog {
  width: min(780px, calc(100% - 36px));
  height: min(530px, calc(100dvh - 36px));
  max-height: min(90vh, 760px);
  padding: 0;
  overflow: auto;
  border: 2px solid var(--text);
  background: #090909;
  color: var(--text);
  box-shadow: 0 0 0 7px #1a1a1a, 0 20px 70px #000;
}

.galaxy-dialog::backdrop {
  background: rgba(0, 0, 0, 0.86);
}

.galaxy-dialog[open] {
  display: block;
}

.galaxy-dialog [hidden] {
  display: none;
}

.galaxy-dialog-panel {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: center;
  padding: clamp(18px, 4vw, 32px);
  text-align: center;
}

.galaxy-dialog-heading {
  position: relative;
  display: grid;
  justify-items: center;
  padding: 0 42px;
}

.galaxy-dialog-heading .select-kicker {
  margin: 0 0 8px;
  text-align: center;
}

.galaxy-dialog-heading h2 {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  letter-spacing: 0.16em;
  text-align: center;
}

.galaxy-close-button {
  position: absolute;
  top: 0;
  right: 0;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid #686868;
  background: #111;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
}

.galaxy-dialog-intro {
  margin: 12px 0 22px;
  color: #bdbdbd;
  font-size: 0.75rem;
  line-height: 1.6;
  letter-spacing: 0.06em;
}

.galaxy-dialog button:focus-visible,
.galaxy-dialog input:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.galaxy-lobby {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.galaxy-button {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid #aaa;
  background: #111;
  color: #f3f3f3;
  font: inherit;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.galaxy-button:hover,
.galaxy-button:focus-visible {
  border-color: #fff;
  background: #292929;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.galaxy-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.galaxy-join-form,
.galaxy-share-code {
  display: flex;
  gap: 8px;
}

.galaxy-join-form {
  width: min(420px, 100%);
}

.galaxy-join-form input {
  min-width: 0;
  width: 100%;
  border: 1px solid #686868;
  padding: 9px 10px;
  background: #080808;
  color: #f3f3f3;
  font: inherit;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
}

.galaxy-join-form input::placeholder {
  color: #999;
}

.galaxy-connected {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.galaxy-connected-label,
.galaxy-player-count {
  margin: 0;
  color: #bbb;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
}

.galaxy-share-code {
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: clamp(1rem, 4vw, 1.4rem);
  font-weight: 800;
  letter-spacing: 0.18em;
}

.galaxy-copy-button {
  white-space: nowrap;
}

.galaxy-status {
  min-height: 1.4em;
  margin: 16px 0 8px;
  color: #bbb;
  font-size: 0.65rem;
  line-height: 1.5;
  letter-spacing: 0.05em;
}

.galaxy-leave-button,
.galaxy-back-button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid #686868;
  background: #111;
  color: #f3f3f3;
  font: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.galaxy-back-button {
  align-self: center;
}

.galaxy-status.error {
  color: #f3b2b2;
}

.game-controls {
  display: none;
}

.touch-help {
  display: none;
}

.help {
  margin-top: 8px;
  text-align: center;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  opacity: 0.9;
  line-height: 1.5;
}

.daily-challenge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #686868;
  background: #080808;
}

.daily-challenge h2 {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
}

.daily-challenge p {
  margin: 5px 0 0;
  color: #aaa;
  font-size: 0.62rem;
  line-height: 1.5;
}

.daily-challenge .daily-challenge-status {
  color: #f3f3f3;
  font-weight: 700;
}

.daily-challenge-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.daily-challenge-button {
  padding: 8px 10px;
  border: 1px solid #f3f3f3;
  background: #111;
  color: #f3f3f3;
  font: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  cursor: pointer;
}

.daily-challenge-button:hover,
.daily-challenge-button:focus-visible {
  background: #292929;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.daily-challenge-button[hidden] {
  display: none;
}

.challenge-start-copy {
  margin: 14px 0 8px;
  color: #aaa;
  font-size: 0.68rem;
}

.music-player {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #383838;
  background: #080808;
  font-size: 0.65rem;
}

.music-title {
  font-weight: 700;
  letter-spacing: 0.12em;
}

.music-button {
  padding: 7px 10px;
  font: inherit;
  font-size: 0.65rem;
  border: 1px solid #f3f3f3;
  background: #111;
  color: #f3f3f3;
  cursor: pointer;
  letter-spacing: 0.08em;
}

.music-player button:hover,
.music-player button:focus-visible,
.music-player button[aria-pressed="true"] {
  background: #292929;
}

.volume-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #bdbdbd;
  letter-spacing: 0.08em;
}

#musicVolume {
  width: 88px;
  height: 18px;
  accent-color: #f3f3f3;
}

#chiptuneStatus {
  color: #aaa;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
}

.achievements {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid #686868;
  background: #080808;
}

.achievements-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #686868;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
}

.achievement-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

#resetAchievements {
  padding: 5px 8px;
  border: 1px solid #686868;
  background: #111;
  color: #bdbdbd;
  font: inherit;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  cursor: pointer;
}

#resetAchievements:hover,
#resetAchievements:focus-visible {
  border-color: #fff;
  color: #fff;
  outline: none;
}

.achievements-heading h2 {
  margin: 0;
  font-size: inherit;
}

#achievementCount {
  color: #bdbdbd;
}

.next-missions {
  margin: 10px 0 0;
  padding: 10px;
  border: 1px solid #f3f3f3;
  color: #f3f3f3;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  line-height: 1.5;
  text-align: center;
}

.next-missions[hidden] {
  display: none;
}

.bug-report {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #686868;
  background: #080808;
}

.bug-report h2 {
  margin: 0;
  font-size: 0.68rem;
}

.bug-report p {
  margin: 5px 0 0;
  color: #aaa;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  line-height: 1.5;
}

.updates {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #686868;
  background: #080808;
}

.updates h2 {
  margin: 0;
  font-size: 0.68rem;
}

.updates p {
  margin: 5px 0 0;
  color: #aaa;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  line-height: 1.5;
}

.bug-report-link {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid #f3f3f3;
  background: #111;
  color: #f3f3f3;
  font: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.bug-report-link:hover,
.bug-report-link:focus-visible {
  background: #292929;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.bug-report-dialog {
  width: min(520px, calc(100% - 28px));
  max-height: min(90vh, 760px);
  padding: 0;
  overflow: auto;
  border: 2px solid #f3f3f3;
  background: #090909;
  color: #f3f3f3;
  box-shadow: 0 0 0 7px #1a1a1a, 0 20px 70px #000;
}

.bug-report-dialog::backdrop {
  background: rgba(0, 0, 0, 0.86);
}

.bug-report-form {
  display: grid;
  gap: 9px;
  padding: clamp(16px, 4vw, 24px);
}

.bug-report-dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.bug-report-dialog-heading .select-kicker {
  margin: 0 0 6px;
}

.bug-report-dialog-heading h2 {
  margin: 0;
  font-size: clamp(1rem, 4vw, 1.3rem);
  letter-spacing: 0.1em;
}

.bug-report-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid #686868;
  background: #111;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

.bug-report-intro {
  margin: 2px 0 6px;
  color: #aaa;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  line-height: 1.5;
}

.bug-report-field {
  margin-top: 4px;
  color: #d0d0d0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.bug-report-field span {
  color: #999;
  font-weight: 400;
}

.bug-report-form input,
.bug-report-form select,
.bug-report-form textarea {
  width: 100%;
  border: 1px solid #686868;
  border-radius: 0;
  padding: 9px 10px;
  background: #111;
  color: #f3f3f3;
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

.bug-report-form textarea {
  resize: vertical;
  line-height: 1.5;
}

.bug-report-form input::placeholder,
.bug-report-form textarea::placeholder {
  color: #888;
}

.bug-report-form select:focus-visible,
.bug-report-form input:focus-visible,
.bug-report-form textarea:focus-visible,
.bug-report-close:focus-visible,
.bug-report-cancel:focus-visible,
.bug-report-submit:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.bug-report-form [hidden] {
  display: none;
}

.bug-report-status {
  min-height: 1em;
  margin: 0;
  color: #ddd;
  font-size: 0.65rem;
  line-height: 1.4;
}

.bug-report-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
}

.bug-report-cancel,
.bug-report-submit {
  padding: 9px 12px;
  border: 1px solid #f3f3f3;
  font: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.bug-report-cancel {
  background: #111;
  color: #f3f3f3;
}

.bug-report-submit {
  background: #f3f3f3;
  color: #050505;
}

.bug-report-cancel:hover,
.bug-report-submit:hover {
  filter: brightness(0.78);
}

.bug-report-submit:disabled {
  cursor: wait;
  opacity: 0.6;
}

.cat-select {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.94);
}

.cat-select[hidden] {
  display: none;
}

.daily-challenge {
  align-items: stretch;
  flex-direction: column;
}

.daily-challenge-actions {
  justify-content: stretch;
}

.daily-challenge-actions .daily-challenge-button {
  flex: 1 1 100%;
}

.select-panel {
  width: min(780px, 100%);
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  padding: clamp(18px, 4vw, 32px);
  border: 2px solid var(--text);
  background: #090909;
  box-shadow: 0 0 0 7px #1a1a1a;
  text-align: center;
}

.select-kicker {
  margin: 0 0 8px;
  color: #aaa;
  font-size: 0.65rem;
}

.select-panel h1 {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  letter-spacing: 0.16em;
}

.select-intro {
  margin: 10px 0 22px;
  color: #bdbdbd;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}

.cat-select .challenge-start-copy {
  margin: 0 0 12px;
}

.cat-select .daily-challenge-button {
  display: block;
  margin: 0 auto 28px;
  padding: 11px 16px;
}

.cat-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.cat-option {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 175px;
  padding: 14px 8px;
  border: 1px solid #555;
  background: #111;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.cat-option:hover,
.cat-option:focus-visible {
  border-color: #fff;
  background: #1b1b1b;
  transform: translateY(-2px);
  outline: none;
}

.cat-option.selected {
  border: 2px solid #fff;
  background: #202020;
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.12);
}

.cat-preview {
  width: min(130px, 100%);
  height: 82px;
  overflow: visible;
  image-rendering: pixelated;
}

.preview-outline {
  fill: #050505;
  stroke: #f3f3f3;
  stroke-width: 2;
  stroke-linejoin: round;
}

.preview-fur,
.preview-paws {
  fill: #f3f3f3;
}

.preview-face {
  fill: #050505;
}

.gray-preview .preview-fur,
.gray-preview .preview-paws {
  fill: #888;
}

.gray-preview .preview-face {
  fill: #111;
}

.preview-stripes {
  fill: none;
  stroke: #333;
  stroke-width: 3;
  stroke-linecap: square;
}

.cat-option strong {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
}

.cat-option span {
  color: #aaa;
  font-size: 0.62rem;
  letter-spacing: 0.03em;
}

.start-button {
  margin-top: 20px;
  padding: 12px 22px;
  border: 2px solid #fff;
  background: #f3f3f3;
  color: #050505;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  cursor: pointer;
}

.start-button:hover,
.start-button:focus-visible {
  background: #aaa;
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.achievement-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.achievement {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid #383838;
  background: #111;
  color: #929292;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.achievement-mark {
  flex: 0 0 auto;
  font-family: Consolas, monospace;
  font-size: 0.8rem;
}

.achievement-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.achievement-copy strong {
  color: #d0d0d0;
  font-size: 0.68rem;
}

.achievement-copy small {
  font-size: 0.6rem;
  letter-spacing: 0.03em;
  line-height: 1.4;
}

.achievement-progress {
  margin-left: auto;
  color: #bdbdbd;
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  text-align: right;
  white-space: nowrap;
}

.achievement.unlocked {
  border-color: #f3f3f3;
  background: #1b1b1b;
  color: #f3f3f3;
}

.achievement.unlocked .achievement-mark,
.achievement.unlocked .achievement-copy strong,
.achievement.unlocked .achievement-progress {
  color: #fff;
}

.achievement.just-unlocked {
  animation: achievementSpark 650ms steps(2, end);
}

.win-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.18);
  z-index: 20;
  overflow: hidden;
}

.win-flash {
  position: absolute;
  inset: -12%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0.98));
  transform: scale(0.85);
  opacity: 0;
  animation: flashBurst 0.8s ease-out forwards;
}

.confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  display: block;
  background: #f3f3f3;
  border: 1px solid rgba(0, 0, 0, 0.3);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
  transform-origin: center;
  opacity: 0;
  animation: confettiBurst var(--duration, 1.5s) cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  animation-delay: var(--delay, 0s);
}

.win-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 36px;
  border: 2px solid var(--text);
  background: rgba(0, 0, 0, 0.82);
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.05), 0 0 40px rgba(255, 255, 255, 0.12);
  transform: scale(0.62);
  opacity: 0;
  animation: panelRise 0.7s cubic-bezier(0.18, 0.89, 0.32, 1.28) 0.22s forwards;
}

.win-title,
.win-subtitle {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  line-height: 1.1;
  text-align: center;
}

.win-title {
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 800;
  animation: textPulse 1.2s ease-in-out infinite alternate;
}

.win-subtitle {
  font-size: clamp(0.7rem, 1.8vw, 1rem);
  opacity: 0.9;
}

.win-warning {
  max-width: 34ch;
  color: #bdbdbd;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  line-height: 1.6;
  text-align: center;
}

.replay-button {
  margin-top: 8px;
}

@keyframes flashBurst {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  62% {
    opacity: 0.82;
  }
  100% {
    transform: scale(1.15);
    opacity: 0;
  }
}

@keyframes confettiBurst {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(0deg);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot));
    opacity: 0;
  }
}

@keyframes panelRise {
  0% {
    opacity: 0;
    transform: scale(0.62) translateY(30px);
  }
  60% {
    opacity: 1;
    transform: scale(1.04) translateY(-4px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes textPulse {
  0% {
    letter-spacing: 0.24em;
    opacity: 0.82;
  }
  100% {
    letter-spacing: 0.38em;
    opacity: 1;
  }
}

@keyframes achievementSpark {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
  50% {
    box-shadow: 0 0 14px 2px rgba(255, 255, 255, 0.65);
  }
}

@media (max-width: 620px) {
  body {
    display: block;
    padding: 8px 0;
  }

  .game-shell {
    width: calc(100% - 16px);
    margin: 0 auto;
    padding: 8px;
  }

  .bug-report {
    align-items: flex-start;
    flex-direction: column;
  }

  .hud {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    font-size: 0.65rem;
  }

  .meta {
    text-align: left;
    font-size: 0.62rem;
    line-height: 1.5;
  }

  .help {
    font-size: 0.62rem;
  }

  .achievements-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .achievement-actions {
    width: 100%;
    justify-content: space-between;
  }

  .music-player {
    gap: 10px;
    line-height: 1.5;
  }

  .cat-options {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .cat-option {
    min-height: 0;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    padding: 8px;
    text-align: left;
  }

  .cat-preview {
    width: 62px;
    height: 48px;
  }

  .cat-option strong {
    flex: 1 1 calc(100% - 80px);
  }

  .cat-option span {
    font-size: 0.54rem;
    margin-left: 70px;
    margin-top: -8px;
  }

  .select-panel {
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    padding: 16px 12px;
  }

  .galaxy-dialog {
    height: min(530px, calc(100dvh - 24px));
    max-height: calc(100dvh - 24px);
  }

  .galaxy-dialog-panel {
    padding: 16px 12px;
  }

  .galaxy-share-code {
    flex-wrap: wrap;
  }

  .select-intro {
    margin-bottom: 14px;
    line-height: 1.5;
  }

  .achievement-list {
    grid-template-columns: 1fr;
  }
}

@media (pointer: coarse) {
  .keyboard-help {
    display: none;
  }

  .touch-help {
    display: inline;
  }

  .game-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 4px 2px;
    touch-action: none;
    user-select: none;
  }

  .movement-controls {
    display: flex;
    gap: 12px;
  }

  .game-control {
    display: grid;
    width: 60px;
    height: 56px;
    place-items: center;
    border: 2px solid #f3f3f3;
    background: #111;
    color: #f3f3f3;
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }

  .game-control:active,
  .game-control.is-pressed {
    background: #383838;
    transform: translateY(1px);
  }

  .jump-control {
    width: 84px;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
  }
}

.leaderboard {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid #686868;
  background: #080808;
}

.leaderboard-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #686868;
}

.leaderboard-heading h2 {
  margin: 0;
  font-size: 0.68rem;
}

.leaderboard-heading p,
.leaderboard-status {
  margin: 5px 0 0;
  color: #aaa;
  font-size: 0.58rem;
  letter-spacing: 0.05em;
  line-height: 1.5;
}

.leaderboard-tabs {
  display: flex;
  gap: 6px;
}

.leaderboard-tab {
  padding: 7px 9px;
  border: 1px solid #686868;
  background: #111;
  color: #bdbdbd;
  font: inherit;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  cursor: pointer;
}

.leaderboard-tab.selected,
.leaderboard-tab:hover,
.leaderboard-tab:focus-visible {
  border-color: #fff;
  color: #fff;
  outline: none;
}

.leaderboard-status.error {
  color: #f3b0b0;
}

.leaderboard-list {
  display: grid;
  gap: 5px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 1px solid #383838;
  background: #111;
  font-size: 0.62rem;
}

.leaderboard-rank,
.leaderboard-score,
.leaderboard-time {
  font-family: Consolas, monospace;
  white-space: nowrap;
}

.leaderboard-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-verification {
  grid-column: 2 / -1;
  color: #999;
  font-size: 0.5rem;
}

.win-leaderboard-form {
  display: grid;
  width: min(360px, 100%);
  gap: 7px;
  margin-top: 10px;
  text-align: left;
}

.win-leaderboard-form label {
  font-size: 0.58rem;
  letter-spacing: 0.08em;
}

.win-leaderboard-form input {
  width: 100%;
  min-width: 0;
  padding: 9px;
  border: 1px solid #686868;
  background: #111;
  color: #f3f3f3;
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.win-leaderboard-form p {
  max-width: 42ch;
  margin: 0;
  color: #bdbdbd;
  font-size: 0.56rem;
  letter-spacing: 0.05em;
  line-height: 1.5;
  text-align: center;
}

.win-leaderboard-form .leaderboard-verification-notice,
.win-leaderboard-form .win-leaderboard-status {
  color: #aaa;
}

.win-leaderboard-form .start-button {
  margin-top: 2px;
}

.win-leaderboard-form button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.win-panel {
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
}

@media (max-width: 420px) {
  .leaderboard-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .leaderboard-list li {
    grid-template-columns: 24px minmax(0, 1fr) auto;
    gap: 6px;
  }

  .leaderboard-time {
    grid-column: 2;
  }

  .leaderboard-verification {
    grid-column: 3;
    grid-row: 2;
    text-align: right;
  }

  .win-panel {
    padding: 18px 14px;
  }
}
