@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
  --game-bg: #000000;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Press Start 2P', cursive;
  background-color: var(--game-bg);
  color: #fff;
  overflow: hidden;
  height: 100vh;
  display: block;
}

.game-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--game-bg);
  overflow: hidden;
}

.game-container::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 10px solid rgba(255, 222, 89, 0);
  box-shadow: inset 0 0 0 0 rgba(255, 222, 89, 0);
  pointer-events: none;
  opacity: 0;
}

.game-container.debug-dump-flash::after {
  animation: debug-dump-flash 0.4s ease-out;
}

canvas {
  background-color: var(--game-bg);
  outline: none;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  width: min(100vw, calc(100vh * 1.25));
  height: min(100vh, calc(100vw / 1.25));
  max-width: 100vw;
  max-height: 100vh;
  aspect-ratio: 1280 / 1024;
}

/* Optional per-game controls/help text (rendered from platform/<handle>/controls.md). */
.game-controls-template {
  display: none;
}

.game-controls-pre {
  margin: 0;
  padding: 10px 12px;
  white-space: pre-wrap;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  line-height: 1.5;
  color: #ffffff;
}
/* Optional per-game controls/help text (rendered from platform/<handle>/controls.md). */
.game-controls-body {
  padding: 10px 12px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  line-height: 1.5;
  color: #ffffff;
  text-align: left;
}

.game-controls-body p {
  margin: 0 0 10px 0;
}

.game-controls-body ul,
.game-controls-body ol {
  margin: 0 0 10px 20px;
  padding: 0;
}

.game-controls-body li {
  margin: 0 0 6px 0;
}

.game-controls-body code,
.game-controls-body pre {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
}

.game-controls-body pre {
  margin: 10px 0;
  padding: 10px 12px;
  white-space: pre-wrap;
  border: 2px solid #ffffff;
  background: rgba(0, 0, 0, 0.35);
  overflow: auto;
}

.game-controls-body a {
  color: #ffffff;
}

#dev-overlay,
#controller-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 20000;
  display: none;
  align-items: center;
  justify-content: center;
}

.controls-dialog {
  background: #1a1a1a;
  border: 4px solid #ffffff;
  padding: 2rem 3rem;
  text-align: left;
  box-shadow: 0 0 0 4px #1a1a1a, 0 0 0 8px #ffffff;
  image-rendering: pixelated;
  max-width: min(720px, calc(100vw - 48px));
  max-height: 75vh;
  overflow: auto;
}

.controls-dialog h2 {
  color: #ffffff;
  font-size: 18px;
  margin: 0 0 1.5rem 0;
  letter-spacing: 3px;
  text-shadow: 3px 3px 0 #000;
  font-family: 'Press Start 2P', monospace;
}

.controls-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.controls-btn {
  background: transparent;
  color: #cccccc;
  border: 2px solid #cccccc;
  padding: 0.75rem 1.5rem;
  font-size: 12px;
  font-family: 'Press Start 2P', monospace;
  cursor: pointer;
  transition: none;
}

.controls-btn:hover {
  color: #ffff00;
  border-color: #ffff00;
}

.pause-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.host-panel-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.78);
  z-index: 5500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pause-menu {
  background: #1a1a1a;
  border: 4px solid #ffffff;
  padding: 2rem 3rem;
  text-align: center;
  box-shadow: 0 0 0 4px #1a1a1a, 0 0 0 8px #ffffff;
  image-rendering: pixelated;
  width: 440px;
}

.host-panel {
  width: 90vw;
  height: 90vh;
  max-width: 1152px;
  max-height: 920px;
  background: #1a1a1a;
  border: 4px solid #ffffff;
  box-shadow: 0 0 0 4px #1a1a1a, 0 0 0 8px #ffffff;
  image-rendering: pixelated;
  padding: 2rem 2.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.host-panel h2 {
  color: #ffffff;
  font-size: 24px;
  margin: 0 0 1.5rem 0;
  letter-spacing: 4px;
  text-shadow: 3px 3px 0 #000;
  font-family: 'Press Start 2P', monospace;
  text-align: center;
}

.host-panel-body {
  flex: 1 1 auto;
  min-height: 0;
}

.host-panel-body-level-select {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
}

.host-panel-body-level-select-loading {
  justify-content: center;
  align-items: center;
}

.host-panel-body-ranking {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
}

.host-panel-body-ranking-loading {
  justify-content: center;
  align-items: center;
}

.ranking-loading {
  color: #dfe8f0;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

.ranking-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
  min-height: 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.ranking-tabs::-webkit-scrollbar {
  display: none;
}

.ranking-tab {
  background: #111111;
  border: 2px solid #4f5d75;
  color: #cfd8e3;
  padding: 0.85rem 1rem;
  font-size: 11px;
  font-family: 'Press Start 2P', monospace;
  cursor: pointer;
  white-space: nowrap;
}

.ranking-tab.selected {
  border-color: #ffcf42;
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(255, 207, 66, 0.25);
}

.ranking-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: rgba(0, 0, 0, 0.42);
  border: 2px solid #283347;
  padding: 12px 16px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.ranking-list::-webkit-scrollbar {
  display: none;
}

.ranking-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(143, 164, 194, 0.18);
  color: #dfe8f0;
  font-size: 11px;
  line-height: 1.5;
}

.ranking-row.selected {
  background: rgba(255, 207, 66, 0.14);
  outline: 2px solid rgba(255, 207, 66, 0.45);
  outline-offset: 2px;
}

.ranking-row:last-child {
  border-bottom: 0;
}

.ranking-row-left {
  text-align: left;
  min-width: 0;
}

.ranking-row-right {
  text-align: right;
  color: #8eff8e;
  flex: 0 0 auto;
}

.ranking-empty {
  color: #a7b9cf;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  padding: 24px 0;
}

.level-select-loading {
  color: #dfe8f0;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

.level-select-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  align-content: start;
  overflow: auto;
  padding-right: 8px;
  min-height: 0;
}

.level-select-tile {
  background: #111111;
  border: 3px solid #4f5d75;
  color: #ffffff;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 208px;
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  text-align: left;
}

.level-select-tile.selected {
  border-color: #ffcf42;
  box-shadow: 0 0 0 2px rgba(255, 207, 66, 0.4);
}

.level-select-tile:disabled {
  cursor: default;
}

.level-select-thumb {
  position: relative;
  aspect-ratio: 5 / 4;
  background: #05080d;
  border: 2px solid #202734;
  overflow: hidden;
}

.level-select-thumb-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  image-rendering: pixelated;
}

.level-select-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  color: #b8bcc8;
  font-size: 11px;
  letter-spacing: 2px;
  text-align: center;
}

.level-select-tile:not(.locked) .level-select-lock {
  display: none;
}

.level-select-lock-img {
  width: 42px;
  height: auto;
  display: block;
  image-rendering: pixelated;
}

.level-select-label {
  font-size: 12px;
  line-height: 1.5;
  color: #dfe8f0;
  text-align: center;
}

.level-select-label-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.level-select-sub-label {
  font-size: 10px;
  line-height: 1.4;
  color: #a7b9cf;
  text-align: center;
}

.level-select-sub-label.rank-first {
  color: #53d86a;
}

.level-select-sub-label.rank-second {
  color: #ffd54a;
}

.level-select-sub-label.rank-third {
  color: #4b97ff;
}

.host-panel.level-select-panel {
  overflow: hidden;
}

.host-panel.level-select-panel .host-panel-body {
  flex: 1 1 auto;
  min-height: 0;
}

.host-panel.level-select-panel .host-panel-body-level-select {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
}

.host-panel.level-select-panel .level-select-grid {
  overflow: auto;
  min-height: 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.host-panel.level-select-panel .level-select-grid::-webkit-scrollbar {
  display: none;
}

.pause-menu h2 {
  color: #ffffff;
  font-size: 24px;
  margin: 0 0 2rem 0;
  letter-spacing: 4px;
  text-shadow: 3px 3px 0 #000;
  font-family: 'Press Start 2P', monospace;
}

.pause-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.pause-btn {
  background: #111111;
  color: #cccccc;
  border: 2px solid #666666;
  padding: 1rem 2rem;
  font-size: 14px;
  font-family: 'Press Start 2P', monospace;
  cursor: pointer;
  text-align: center;
  transition: none;
  outline: none;
  width: 100%;
  min-height: 56px;
}

.pause-btn.selected {
  background: #ffff00;
  color: #111111;
  border-color: #ffff00;
}

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

.pause-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.debug-mode-badge {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 6000;
  padding: 10px 12px 8px;
  background: rgba(0, 0, 0, 0.82);
  border: 2px solid #ffcf42;
  color: #ffcf42;
  font-size: 11px;
  letter-spacing: 2px;
  text-shadow: 2px 2px 0 #000;
  pointer-events: none;
}

@keyframes debug-dump-flash {
  0% {
    opacity: 0;
    border-color: rgba(255, 222, 89, 0);
    box-shadow: inset 0 0 0 0 rgba(255, 222, 89, 0);
  }
  25% {
    opacity: 1;
    border-color: rgba(255, 222, 89, 0.95);
    box-shadow: inset 0 0 48px rgba(255, 222, 89, 0.22);
  }
  100% {
    opacity: 0;
    border-color: rgba(255, 222, 89, 0);
    box-shadow: inset 0 0 0 0 rgba(255, 222, 89, 0);
  }
}

.intro-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--game-bg);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.intro-panel {
  background: transparent;
  border: none;
  padding: 0;
  text-align: center;
  box-shadow: none;
  image-rendering: pixelated;
  width: 90vw;
  max-width: 900px;
  position: relative;
}

.intro-art {
  width: 100%;
  height: auto;
  border: none;
  margin: 0 auto 1.5rem auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cccccc;
  font-size: 12px;
  letter-spacing: 3px;
  font-family: 'Press Start 2P', monospace;
}

.intro-art-img {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;
  z-index: 1;
}

.intro-text {
  color: #ffffff;
  font-size: 14px;
  margin: 0;
  max-width: calc(100% - 48px);
  letter-spacing: 2px;
  line-height: 1.5;
  text-shadow: 3px 3px 0 #000;
  font-family: 'Press Start 2P', monospace;
  position: absolute;
  left: 0;
  right: 0;
  bottom: clamp(44px, 7vh, 72px);
  z-index: 2;
  pointer-events: none;
  text-align: center;
  animation: intro-text-blink 1s steps(1, end) infinite;
}

@keyframes intro-text-blink {
  0%, 49% {
    opacity: 1;
  }

  50%, 100% {
    opacity: 0;
  }
}

#screenshot-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 20000;
  display: none;
  align-items: center;
  justify-content: center;
}

.screenshot-dialog {
  background: #1a1a1a;
  border: 4px solid #ffffff;
  padding: 2rem 3rem;
  text-align: center;
  box-shadow: 0 0 0 4px #1a1a1a, 0 0 0 8px #ffffff;
  image-rendering: pixelated;
  max-width: 600px;
}

.screenshot-dialog h2 {
  color: #ffffff;
  font-size: 18px;
  margin: 0 0 1.5rem 0;
  letter-spacing: 3px;
  text-shadow: 3px 3px 0 #000;
  font-family: 'Press Start 2P', monospace;
}

.screenshot-preview {
  margin: 1rem 0;
  border: 2px solid #ffffff;
}

.screenshot-preview img {
  max-width: 100%;
  height: auto;
  display: block;
}

.screenshot-input {
  width: 100%;
  padding: 0.75rem;
  margin: 1rem 0;
  background: #000;
  color: #fff;
  border: 2px solid #ffffff;
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  outline: none;
}

.screenshot-input:focus {
  border-color: #ffff00;
}

.screenshot-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.screenshot-btn {
  background: transparent;
  color: #cccccc;
  border: 2px solid #cccccc;
  padding: 0.75rem 1.5rem;
  font-size: 12px;
  font-family: 'Press Start 2P', monospace;
  cursor: pointer;
  transition: none;
}

.screenshot-btn:hover {
  color: #ffff00;
  border-color: #ffff00;
}

.screenshot-message {
  color: #ffff00;
  font-size: 10px;
  margin-top: 1rem;
  font-family: 'Press Start 2P', monospace;
}

.screenshot-error {
  color: #ff4444;
}
