@font-face {
  font-family: 'Press Start 2P';
  src: url('../assets/fonts/PressStart2P-Regular.ttf') format('truetype');
  font-display: block;
}

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

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: 'Courier New', monospace;
  color: #fff;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#game-canvas {
  width: 100%;
  height: 100%;
  max-width: 177.77vh; /* keep 16:9 */
  max-height: 56.25vw;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  background: #08141a;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5em;
  background: rgba(0, 0, 0, 0.55);
  text-align: center;
  pointer-events: none;
}

.overlay.hidden {
  display: none;
}

#overlay-title {
  background: linear-gradient(to bottom, #06121a 0%, #0d3b44 40%, #14775a 75%, #46c98b 100%);
  overflow: hidden;
}

.title-scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.title-glow {
  position: absolute;
  top: 6%;
  left: 50%;
  width: clamp(90px, 22vw, 180px);
  height: clamp(90px, 22vw, 180px);
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255, 226, 138, 0.9) 0%, rgba(126, 227, 184, 0.45) 45%, transparent 72%);
  border-radius: 50%;
  filter: blur(1px);
}

.title-grid {
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: 0;
  height: 46%;
  background-image:
    repeating-linear-gradient(to right, rgba(126, 227, 184, 0.55) 0 2px, transparent 2px 36px),
    repeating-linear-gradient(to bottom, rgba(126, 227, 184, 0.55) 0 2px, transparent 2px 18px);
  transform: perspective(180px) rotateX(58deg);
  transform-origin: bottom;
}

.title-roster {
  position: absolute;
  bottom: 4%;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(4px, 1.6vw, 12px);
  padding: 0 4%;
}

.title-roster-item {
  width: clamp(34px, 9vw, 64px);
  aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5));
}

.title-roster-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.overlay h1,
.title-subtitle,
.overlay .blink,
.overlay .controls-hint {
  position: relative;
  z-index: 1;
}

.overlay h1 {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: clamp(1.4rem, 5vw, 3rem);
  line-height: 1.6;
  letter-spacing: 0.02em;
  text-shadow: 4px 4px 0 #e63946;
}

.overlay h1 span {
  color: #e63946;
  font-size: 0.6em;
  display: inline-block;
  margin: 0 0.3em;
}

.title-subtitle {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: clamp(0.7rem, 2vw, 1.1rem);
  line-height: 1.6;
  color: #ffd23f;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}

.title-subtitle span {
  color: #e63946;
}

.blink {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  animation: blink 1s steps(1) infinite;
  font-size: clamp(0.6rem, 1.6vw, 0.9rem);
  line-height: 1.6;
}

.controls-hint {
  display: flex;
  gap: 3em;
  font-size: clamp(0.7rem, 1.5vw, 1rem);
}

.controls-hint strong {
  color: #ffd23f;
}

.select-row {
  display: flex;
  gap: clamp(1.5em, 6vw, 5em);
}

.select-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6em;
}

.select-label {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  color: #ffd23f;
  font-size: clamp(0.55rem, 1.4vw, 0.8rem);
  line-height: 1.6;
}

.select-portrait-frame {
  width: clamp(70px, 16vw, 140px);
  height: clamp(70px, 16vw, 140px);
  border: 3px solid #666;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.select-portrait-frame img {
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
}

.select-player.ready .select-portrait-frame {
  border-color: #4caf50;
  box-shadow: 0 0 12px #4caf50;
}

.select-name {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: clamp(0.7rem, 2vw, 1.1rem);
  line-height: 1.6;
}

.select-hint {
  font-size: clamp(0.65rem, 1.4vw, 0.9rem);
  color: #ccc;
}

.select-player.ready .select-hint {
  color: #4caf50;
}

.select-player.ready .select-hint::after {
  content: ' — PRÊT !';
}

.stage-preview-frame {
  width: clamp(220px, 60vw, 340px);
  aspect-ratio: 16 / 9;
  border: 3px solid #666;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.stage-preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.stage-select-name {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: clamp(0.7rem, 2vw, 1.1rem);
  line-height: 1.6;
  color: #ffd23f;
}

.file-warning {
  max-width: 32em;
  color: #ffb300;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #ffb300;
  padding: 0.6em 1em;
  font-size: clamp(0.75rem, 1.6vw, 1rem);
}

@keyframes blink {
  50% { opacity: 0; }
}
