/* ═══════════════════════════════════════════════════════
   ARCADE ZONE — Host Screen CSS
   90s fliperama aesthetic: CRT scanlines, neon glow,
   dark backgrounds, pixel-inspired typography
   ═══════════════════════════════════════════════════════ */

/* ─── Reset & Base ─────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --cyan: #00fff5;
  --magenta: #ff00ea;
  --yellow: #ffe100;
  --green: #00ff88;
  --orange: #ff6b35;
  --red: #ff2255;
  --white: #f0f0f0;
  --dim: #556677;
  --bg-deep: #050810;
  --bg-mid: #0a0e1a;
  --bg-card: rgba(10, 18, 40, 0.85);
  --p1-color: #00ccff;
  --p2-color: #ff6b35;
  --font-mono: 'Courier New', 'Consolas', 'Liberation Mono', monospace;
  --glow-cyan: 0 0 7px var(--cyan), 0 0 15px var(--cyan), 0 0 30px rgba(0, 255, 245, 0.3);
  --glow-magenta: 0 0 7px var(--magenta), 0 0 15px var(--magenta), 0 0 30px rgba(255, 0, 234, 0.3);
  --glow-yellow: 0 0 7px var(--yellow), 0 0 15px var(--yellow);
  --glow-green: 0 0 7px var(--green), 0 0 15px var(--green);
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--white);
  font-family: var(--font-mono);
}

/* ─── CRT Scanlines ────────────────────────────────── */
.scanlines::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(0deg,
      rgba(0, 0, 0, 0.12) 0px,
      rgba(0, 0, 0, 0.12) 1px,
      transparent 1px,
      transparent 3px);
  pointer-events: none;
  z-index: 9999;
}

.crt-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  /* background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%); */
  pointer-events: none;
  z-index: 9998;
}

/* ─── Particle Canvas ──────────────────────────────── */
.particles-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ─── App Container ────────────────────────────────── */
#arcade-app {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
  background: linear-gradient(180deg, var(--bg-deep) 0%, #0d0a20 40%, #0a0818 100%);
}

/* ─── Screens ──────────────────────────────────────── */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0.6s ease;
  z-index: 1;
}

.screen-active {
  opacity: 1;
  visibility: visible;
}

/* ═══════════════════════════════════════════════════════
   IDLE SCREEN
   ═══════════════════════════════════════════════════════ */

/* Title Section */
.arcade-title-section {
  text-align: center;
  margin-bottom: 24px;
}

.arcade-subtitle {
  font-size: clamp(12px, 2vw, 18px);
  color: var(--magenta);
  text-shadow: var(--glow-magenta);
  letter-spacing: 6px;
  text-transform: uppercase;
  animation: arcadeBlink 2s ease-in-out infinite;
}

.arcade-title {
  font-size: clamp(32px, 7vw, 72px);
  font-weight: 900;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin: 8px 0;
  line-height: 1.1;
}

.arcade-tagline {
  font-size: clamp(10px, 1.5vw, 14px);
  color: var(--dim);
  letter-spacing: 4px;
  text-transform: uppercase;
}

/* QR Section */
.qr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 16px 0;
}

.qr-frame {
  position: relative;
  padding: 12px;
  background: rgba(0, 255, 245, 0.03);
  border: 2px solid rgba(0, 255, 245, 0.25);
  border-radius: 12px;
  animation: qrPulse 3s ease-in-out infinite;
}

.qr-image {
  width: clamp(160px, 28vw, 280px);
  height: clamp(160px, 28vw, 280px);
  display: block;
  filter: drop-shadow(0 0 8px rgba(0, 255, 245, 0.4));
}

/* QR Corners */
.qr-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: var(--cyan);
  border-style: solid;
}

.qr-tl {
  top: -2px;
  left: -2px;
  border-width: 3px 0 0 3px;
  border-radius: 6px 0 0 0;
}

.qr-tr {
  top: -2px;
  right: -2px;
  border-width: 3px 3px 0 0;
  border-radius: 0 6px 0 0;
}

.qr-bl {
  bottom: -2px;
  left: -2px;
  border-width: 0 0 3px 3px;
  border-radius: 0 0 0 6px;
}

.qr-br {
  bottom: -2px;
  right: -2px;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 6px 0;
}

.qr-instruction {
  margin-top: 16px;
  font-size: clamp(14px, 2.5vw, 22px);
  font-weight: 700;
  color: var(--yellow);
  text-shadow: var(--glow-yellow);
  letter-spacing: 3px;
  text-transform: uppercase;
  animation: arcadeBlink 1.5s ease-in-out infinite;
}

.qr-url {
  margin-top: 6px;
  font-size: clamp(10px, 1.3vw, 13px);
  color: var(--dim);
  letter-spacing: 1px;
}

/* Game Badge */
.game-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  padding: 8px 20px;
  background: var(--bg-card);
  border: 1px solid rgba(255, 0, 234, 0.3);
  border-radius: 20px;
  font-size: clamp(11px, 1.5vw, 15px);
  color: var(--magenta);
  text-shadow: 0 0 5px rgba(255, 0, 234, 0.3);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.game-badge-icon {
  font-size: 1.3em;
}

/* Player Slots */
.players-section {
  display: flex;
  gap: clamp(12px, 3vw, 32px);
  margin-top: 16px;
}

.player-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 24px;
  background: var(--bg-card);
  border-radius: 12px;
  min-width: clamp(120px, 18vw, 180px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: border-color 0.4s, box-shadow 0.4s;
}

.player-slot.connected {
  border-color: var(--green);
  box-shadow: 0 0 15px rgba(0, 255, 136, 0.15);
}

.player-slot.ready {
  border-color: var(--cyan);
  box-shadow: 0 0 20px rgba(0, 255, 245, 0.25);
  animation: readyPulse 1.5s ease-in-out infinite;
}

#slot-p1 .slot-label {
  color: var(--p1-color);
}

#slot-p2 .slot-label {
  color: var(--p2-color);
}

.slot-label {
  font-size: clamp(10px, 1.3vw, 13px);
  font-weight: 700;
  letter-spacing: 3px;
  margin-bottom: 4px;
}

.slot-status {
  font-size: clamp(9px, 1.1vw, 12px);
  color: var(--dim);
  letter-spacing: 1px;
  transition: color 0.3s;
}

.player-slot.connected .slot-status {
  color: var(--green);
}

.player-slot.ready .slot-status {
  color: var(--cyan);
}

.slot-name {
  font-size: clamp(10px, 1.2vw, 14px);
  color: var(--white);
  margin-top: 4px;
  min-height: 1.2em;
}

.slot-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dim);
  margin-top: 8px;
  transition: background 0.3s, box-shadow 0.3s;
}

.player-slot.connected .slot-indicator {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.player-slot.ready .slot-indicator {
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  animation: dotBlink 1s infinite;
}

/* Queue Badge */
.queue-badge {
  margin-top: 12px;
  padding: 6px 16px;
  background: rgba(255, 107, 53, 0.1);
  border: 1px solid rgba(255, 107, 53, 0.3);
  border-radius: 16px;
  font-size: clamp(10px, 1.2vw, 13px);
  color: var(--orange);
  letter-spacing: 1px;
}

/* ═══════════════════════════════════════════════════════
   COUNTDOWN SCREEN
   ═══════════════════════════════════════════════════════ */
#screen-countdown {
  background: radial-gradient(circle at center, rgba(0, 255, 245, 0.05) 0%, transparent 60%);
}

.countdown-number {
  font-size: clamp(120px, 30vw, 300px);
  font-weight: 900;
  color: var(--cyan);
  text-shadow: var(--glow-cyan), 0 0 60px rgba(0, 255, 245, 0.5);
  animation: countdownZoom 1s ease-out;
  line-height: 1;
}

.countdown-label {
  font-size: clamp(16px, 3vw, 28px);
  color: var(--yellow);
  text-shadow: var(--glow-yellow);
  letter-spacing: 6px;
  text-transform: uppercase;
  margin-top: 16px;
}

/* ═══════════════════════════════════════════════════════
   PLAYING SCREEN
   ═══════════════════════════════════════════════════════ */
#screen-playing {
  padding: 16px;
  justify-content: flex-start;
}

.playing-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 4vw, 48px);
  width: 100%;
  padding: 12px;
}

.playing-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
}

.playing-label {
  font-size: clamp(11px, 1.5vw, 15px);
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.playing-value {
  font-size: clamp(36px, 7vw, 72px);
  font-weight: 900;
  line-height: 1;
}

.p1-color {
  color: var(--p1-color);
  text-shadow: 0 0 10px rgba(0, 204, 255, 0.4);
}

.p2-color {
  color: var(--p2-color);
  text-shadow: 0 0 10px rgba(255, 107, 53, 0.4);
}

.playing-vs {
  font-size: clamp(16px, 3vw, 28px);
  color: var(--dim);
  font-weight: 700;
}

.playing-timer {
  font-size: clamp(14px, 2vw, 20px);
  color: var(--yellow);
  text-shadow: var(--glow-yellow);
  letter-spacing: 2px;
  margin: 8px 0;
  min-height: 1.4em;
}

.playing-game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.playing-game-name {
  font-size: clamp(20px, 4vw, 40px);
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
  letter-spacing: 4px;
  text-transform: uppercase;
}

.game-canvas {
  width: 90%;
  max-width: 800px;
  aspect-ratio: 16/9;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 255, 245, 0.15);
  border-radius: 8px;
  margin-top: 12px;
}

.game-iframe {
  width: 92%;
  max-width: 960px;
  aspect-ratio: 16/9;
  background: #000;
  border: 2px solid rgba(0, 255, 245, 0.3);
  border-radius: 8px;
  box-shadow: 0 0 25px rgba(0, 255, 245, 0.15);
  margin-top: 8px;
  outline: none;
}

.game-iframe.hidden {
  display: none;
}

.playing-status {
  font-size: clamp(10px, 1.3vw, 13px);
  color: var(--green);
  text-shadow: var(--glow-green);
  letter-spacing: 3px;
  padding: 12px;
  animation: arcadeBlink 2s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════
   FULLSCREEN / VERTICAL GAME MODE (e.g. Futebol Montessoriano)
   ═══════════════════════════════════════════════════════ */
#screen-playing.fullscreen-game {
  padding: 0 !important;
  margin: 0 !important;
  width: 100% !important;
  height: 100% !important;
  justify-content: center !important;
  align-items: center !important;
  background: #000 !important;
  overflow: hidden !important;
}

#screen-playing.fullscreen-game .playing-header,
#screen-playing.fullscreen-game .playing-timer,
#screen-playing.fullscreen-game .playing-game-name,
#screen-playing.fullscreen-game .playing-status {
  display: none !important;
}

#screen-playing.fullscreen-game .playing-game-area {
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  padding: 0 !important;
  margin: 0 !important;
  position: relative !important;
  overflow: hidden !important;
}

#screen-playing.fullscreen-game .game-iframe {
  height: 100% !important;
  max-height: 100% !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  margin: 0 !important;
  padding: 0 !important;
  background: #000 !important;
  outline: none !important;
}

/* In landscape mode: vertical game occupies 100vh height and maintains vertical ratio */
@media (orientation: landscape) {
  #screen-playing.fullscreen-game .game-iframe {
    height: 100vh !important;
    width: min(100vw, calc(100vh * 480 / 854)) !important;
    max-width: 100vw !important;
  }
}

/* In portrait mode: vertical game fills 100% width and 100% height */
@media (orientation: portrait) {
  #screen-playing.fullscreen-game .game-iframe {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
  }
}

/* ═══════════════════════════════════════════════════════
   RESULT SCREEN
   ═══════════════════════════════════════════════════════ */
#screen-result {
  background: radial-gradient(circle at center, rgba(255, 225, 0, 0.04) 0%, transparent 60%);
}

.confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.result-title {
  font-size: clamp(24px, 5vw, 48px);
  font-weight: 900;
  color: var(--yellow);
  text-shadow: var(--glow-yellow);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 24px;
  animation: slideInDown 0.6s ease-out;
  z-index: 1;
}

.result-cards {
  display: flex;
  align-items: center;
  gap: clamp(12px, 3vw, 32px);
  z-index: 1;
}

.result-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(16px, 3vw, 28px);
  background: var(--bg-card);
  border-radius: 16px;
  min-width: clamp(120px, 20vw, 200px);
  animation: slideInUp 0.8s ease-out;
}

.result-p1 {
  border: 2px solid var(--p1-color);
  box-shadow: 0 0 20px rgba(0, 204, 255, 0.2);
}

.result-p2 {
  border: 2px solid var(--p2-color);
  box-shadow: 0 0 20px rgba(255, 107, 53, 0.2);
}

.result-player-label {
  font-size: clamp(10px, 1.3vw, 13px);
  letter-spacing: 3px;
  color: var(--dim);
  margin-bottom: 4px;
}

.result-p1 .result-player-label {
  color: var(--p1-color);
}

.result-p2 .result-player-label {
  color: var(--p2-color);
}

.result-player-name {
  font-size: clamp(14px, 2vw, 20px);
  color: var(--white);
  margin-bottom: 8px;
}

.result-player-score {
  font-size: clamp(36px, 7vw, 64px);
  font-weight: 900;
  color: var(--yellow);
  text-shadow: var(--glow-yellow);
  line-height: 1;
}

.result-points {
  font-size: clamp(9px, 1vw, 11px);
  color: var(--dim);
  letter-spacing: 3px;
  margin-top: 4px;
}

.result-vs {
  font-size: clamp(16px, 3vw, 28px);
  color: var(--dim);
  font-weight: 700;
  z-index: 1;
}

.result-winner {
  font-size: clamp(18px, 3.5vw, 32px);
  font-weight: 900;
  color: var(--green);
  text-shadow: var(--glow-green);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 24px;
  z-index: 1;
  animation: winnerBounce 0.6s ease-out;
}

.result-card.winner-card {
  border-color: var(--yellow);
  box-shadow: 0 0 30px rgba(255, 225, 0, 0.3);
  animation: slideInUp 0.8s ease-out, winnerGlow 1.5s ease-in-out infinite;
}

.result-next {
  font-size: clamp(10px, 1.3vw, 13px);
  color: var(--dim);
  letter-spacing: 2px;
  margin-top: 20px;
  z-index: 1;
  animation: arcadeBlink 2s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════
   PAUSED OVERLAY
   ═══════════════════════════════════════════════════════ */
.overlay-full {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  z-index: 5000;
  transition: opacity 0.4s;
}

.paused-text {
  font-size: clamp(32px, 8vw, 80px);
  font-weight: 900;
  color: var(--yellow);
  text-shadow: var(--glow-yellow);
  letter-spacing: 8px;
  animation: arcadeBlink 1.2s ease-in-out infinite;
}

/* ─── Utility ──────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════ */
@keyframes arcadeBlink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.25;
  }
}

@keyframes qrPulse {

  0%,
  100% {
    box-shadow: 0 0 15px rgba(0, 255, 245, 0.15);
  }

  50% {
    box-shadow: 0 0 35px rgba(0, 255, 245, 0.45), 0 0 60px rgba(0, 255, 245, 0.15);
  }
}

@keyframes readyPulse {

  0%,
  100% {
    box-shadow: 0 0 15px rgba(0, 255, 245, 0.2);
  }

  50% {
    box-shadow: 0 0 30px rgba(0, 255, 245, 0.5);
  }
}

@keyframes dotBlink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

@keyframes countdownZoom {
  0% {
    transform: scale(3);
    opacity: 0;
  }

  50% {
    transform: scale(1);
    opacity: 1;
  }

  100% {
    transform: scale(0.95);
    opacity: 1;
  }
}

@keyframes slideInUp {
  from {
    transform: translateY(60px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInDown {
  from {
    transform: translateY(-40px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes winnerBounce {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

  60% {
    transform: scale(1.15);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes winnerGlow {

  0%,
  100% {
    box-shadow: 0 0 20px rgba(255, 225, 0, 0.2);
  }

  50% {
    box-shadow: 0 0 40px rgba(255, 225, 0, 0.5), 0 0 60px rgba(255, 225, 0, 0.2);
  }
}

@keyframes screenFlash {
  0% {
    background: rgba(255, 255, 255, 0.3);
  }

  100% {
    background: transparent;
  }
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — Portrait / Landscape
   ═══════════════════════════════════════════════════════ */
@media (orientation: landscape) {
  .arcade-title {
    font-size: clamp(28px, 5vw, 56px);
  }

  .qr-image {
    width: clamp(120px, 18vh, 200px);
    height: clamp(120px, 18vh, 200px);
  }

  .players-section {
    gap: 40px;
  }

  .qr-section {
    margin: 8px 0;
  }

  .arcade-title-section {
    margin-bottom: 8px;
  }

  .countdown-number {
    font-size: clamp(100px, 25vh, 250px);
  }
}

@media (orientation: portrait) {
  .players-section {
    flex-direction: column;
    gap: 12px;
  }

  .player-slot {
    flex-direction: row;
    gap: 12px;
    min-width: 80%;
    justify-content: center;
  }

  .result-cards {
    flex-direction: column;
  }

  .result-vs {
    display: none;
  }
}

@media (max-width: 480px) {
  .screen {
    padding: 16px;
  }

  .arcade-title-section {
    margin-bottom: 12px;
  }

  .game-badge {
    padding: 6px 14px;
  }
}

/* ═══════════════════════════════════════════════════════
   FLOATING GAME TIMER (overlays fullscreen games)
   ═══════════════════════════════════════════════════════ */
.floating-game-timer {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  padding: 6px 20px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 225, 0, 0.4);
  border-radius: 20px;
  font-size: clamp(16px, 2.5vw, 24px);
  font-weight: 900;
  color: var(--yellow);
  text-shadow: var(--glow-yellow);
  letter-spacing: 3px;
  font-family: var(--font-mono);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  transition: color 0.3s, border-color 0.3s, text-shadow 0.3s;
}

.floating-game-timer.urgent {
  color: var(--red);
  border-color: rgba(255, 34, 85, 0.6);
  text-shadow: 0 0 7px var(--red), 0 0 15px var(--red);
  animation: arcadeBlink 0.8s ease-in-out infinite;
}