/* ==========================================================
   JUMPING FROG - CSS & ESTÉTICA RETRO ARCADE (SPECTRUM 1983)
   Compatível com Desktop (PC) e Telemóvel (Mobile Touch)
   ========================================================== */

:root {
  --bg-deep: #050a06;
  --bg-cabinet: #0d1a10;
  --border-neon: #00ff66;
  --text-main: #39ff14;
  --text-yellow: #ffff00;
  --text-cyan: #00ffff;
  --text-red: #ff3333;
  --font-retro: 'Press Start 2P', monospace;
  --font-score: 'VT323', monospace;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: #fff;
  font-family: var(--font-retro);
  touch-action: none;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Contentor Principal */
#arcade-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  max-width: 560px;
  background: var(--bg-cabinet);
  border-left: 2px solid #1a3320;
  border-right: 2px solid #1a3320;
  position: relative;
  overflow: hidden;
}

/* Header Compacto */
#arcade-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #020603;
  border-bottom: 2px solid var(--border-neon);
  z-index: 20;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.game-badge {
  font-size: 11px;
  color: var(--text-main);
  letter-spacing: 0.5px;
  text-shadow: 0 0 6px rgba(0, 255, 102, 0.7);
}

.retro-sub {
  font-family: var(--font-score);
  font-size: 14px;
  color: var(--text-yellow);
  letter-spacing: 1px;
}

.header-right {
  display: flex;
  gap: 8px;
}

.hdr-btn {
  background: #112214;
  border: 1px solid var(--border-neon);
  border-radius: 4px;
  color: #fff;
  font-size: 13px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, background-color 0.15s;
}

.hdr-btn:active {
  transform: scale(0.92);
  background: var(--border-neon);
  color: #000;
}

/* Ecrã de Jogo / CRT Screen */
#screen-container {
  position: relative;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #000;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background-color: #000000;
}

/* Scanlines e Curvatura CRT Estilo Anos 80 */
.scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.4) 50%
  );
  background-size: 100% 4px;
  z-index: 10;
  opacity: 0.6;
}

.crt-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  box-shadow: inset 0 0 40px rgba(0, 255, 102, 0.15);
  z-index: 11;
}

/* Overlays / Modais */
.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
  padding: 16px;
  transition: opacity 0.2s ease;
}

.game-overlay.hidden {
  display: none !important;
}

.overlay-card {
  background: #09150c;
  border: 3px solid var(--border-neon);
  box-shadow: 0 0 20px rgba(0, 255, 102, 0.4);
  padding: 20px 16px;
  border-radius: 8px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  animation: cardPulse 3s infinite alternate;
}

@keyframes cardPulse {
  0% { border-color: var(--border-neon); }
  50% { border-color: var(--text-cyan); }
  100% { border-color: var(--border-neon); }
}

.frog-banner, .trophy-icon {
  font-size: 42px;
  margin-bottom: 8px;
  animation: bounce 1.2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.pixel-title {
  font-size: 16px;
  color: var(--text-yellow);
  text-shadow: 2px 2px 0px #000, 0 0 8px rgba(255, 255, 0, 0.6);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.pixel-sub {
  font-family: var(--font-score);
  font-size: 16px;
  color: var(--text-cyan);
  margin-bottom: 14px;
}

.rules-box {
  background: #030804;
  border: 1px dashed var(--border-neon);
  padding: 12px 10px;
  border-radius: 6px;
  text-align: left;
  font-size: 9px;
  line-height: 1.6;
  color: #ddffdd;
  margin-bottom: 16px;
}

.rules-box p {
  margin-bottom: 6px;
}

.arcade-start-btn, .arcade-btn {
  background: #00aa44;
  color: #ffffff;
  border: 2px solid #55ff77;
  padding: 12px 18px;
  font-family: var(--font-retro);
  font-size: 12px;
  cursor: pointer;
  border-radius: 6px;
  box-shadow: 0 4px 0 #005522;
  transition: transform 0.05s, box-shadow 0.05s;
  width: 100%;
}

.arcade-start-btn:active, .arcade-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 #005522;
}

.controls-hint {
  margin-top: 12px;
  font-size: 8px;
  color: #88ffaa;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Formulário de High Score */
.highlight-score {
  font-family: var(--font-score);
  font-size: 38px;
  color: var(--text-yellow);
  margin: 10px 0;
  letter-spacing: 2px;
}

.hs-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hs-form input {
  background: #000;
  border: 2px solid var(--border-neon);
  color: #fff;
  font-family: var(--font-retro);
  font-size: 14px;
  padding: 10px;
  text-align: center;
  text-transform: uppercase;
  border-radius: 4px;
}

/* Controlos Táteis Mobile */
.touch-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px calc(10px + var(--safe-bottom)) 16px;
  background: #020703;
  border-top: 2px solid #133318;
  z-index: 20;
}

.touch-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.touch-btn {
  background: #112615;
  border: 2px solid var(--border-neon);
  border-radius: 12px;
  color: var(--text-main);
  font-family: var(--font-retro);
  font-size: 20px;
  width: 68px;
  height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 #07150a;
  cursor: pointer;
  touch-action: manipulation;
}

.touch-btn:active, .touch-btn.active {
  background: var(--border-neon);
  color: #000;
  transform: translateY(4px);
  box-shadow: 0 0 0 #000;
}

.jump-btn {
  width: 96px;
  height: 60px;
  background: #1c3d22;
  border-color: var(--text-yellow);
  color: var(--text-yellow);
  font-size: 11px;
  gap: 2px;
}

.jump-btn .sub-arrow {
  font-size: 14px;
}

.jump-btn:active, .jump-btn.active {
  background: var(--text-yellow);
  color: #000;
}

/* Modo Paisagem / Landscape Adaptativo */
@media (orientation: landscape) and (max-height: 520px) {
  #arcade-container {
    max-width: 100vw;
    flex-direction: row;
  }

  #arcade-header {
    flex-direction: column;
    width: 60px;
    height: 100%;
    border-bottom: none;
    border-right: 2px solid var(--border-neon);
    padding: 8px 4px;
    gap: 10px;
  }

  .header-left .game-badge {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
  }

  .retro-sub {
    display: none;
  }

  .header-right {
    flex-direction: column;
    gap: 6px;
  }

  .touch-bar {
    position: absolute;
    bottom: 0;
    left: 60px;
    right: 0;
    background: transparent;
    border-top: none;
    pointer-events: none;
    padding: 0 16px 16px 16px;
  }

  .touch-group {
    pointer-events: auto;
  }

  .touch-btn {
    background: rgba(17, 38, 21, 0.7);
    backdrop-filter: blur(4px);
  }
}
