/* =====================================================
   TANQUES EN MUROS - Estilos Retro Arcade
   ===================================================== */

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

/* ---- Variables ---- */
:root {
  --green:  #00ff41;
  --green2: #00cc33;
  --red:    #ff2222;
  --yellow: #ffe600;
  --amber:  #ff9900;
  --bg:     #050a05;
  --bg2:    #0a120a;
  --panel:  rgba(0, 255, 65, 0.06);
  --border: rgba(0, 255, 65, 0.25);
  --font:   'Press Start 2P', monospace;
}

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

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--green);
  font-family: var(--font);
  overflow: hidden;
  user-select: none;
}

/* ---- Screens ---- */
.screen {
  position: fixed; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 1;
}
.screen.active { display: flex; }

/* ---- CRT Scanlines ---- */
.scanlines {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 999;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.18) 0px,
    rgba(0,0,0,0.18) 1px,
    transparent 1px,
    transparent 3px
  );
}

/* ---- CRT Flicker ---- */
body::after {
  content: '';
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.55) 100%);
  pointer-events: none;
  z-index: 998;
}

/* ===================== WELCOME ===================== */
.welcome-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 20px;
  width: 100%;
  max-width: 560px;
}

/* Logo / Title */
.logo-container {
  position: relative;
  text-align: center;
}

.game-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.4;
}

.title-line1 {
  font-size: clamp(22px, 5vw, 42px);
  color: var(--green);
  text-shadow:
    0 0 8px var(--green),
    0 0 20px var(--green),
    0 0 40px var(--green2);
  animation: flicker 4s infinite;
}

.title-line2 {
  font-size: clamp(14px, 3.2vw, 26px);
  color: var(--yellow);
  text-shadow:
    0 0 6px var(--yellow),
    0 0 15px var(--amber);
  letter-spacing: 6px;
}

/* Pixel tank decoration */
.tank-icon {
  position: relative;
  width: 60px;
  height: 36px;
  margin: 0 auto 12px;
}
.tank-body {
  position: absolute;
  width: 40px; height: 24px;
  left: 10px; top: 8px;
  background: var(--green2);
  border: 2px solid var(--green);
  box-shadow: 0 0 8px var(--green);
}
.tank-barrel {
  position: absolute;
  width: 22px; height: 6px;
  left: 38px; top: 13px;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.tank-tracks {
  position: absolute;
  width: 46px; height: 8px;
  left: 7px; top: 28px;
  background: repeating-linear-gradient(
    90deg, var(--green) 0 6px, var(--bg) 6px 8px
  );
}

/* Form */
.welcome-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.input-label {
  font-size: 7px;
  color: var(--green);
  opacity: 0.75;
  text-align: center;
  letter-spacing: 1px;
}

.retro-input {
  font-family: var(--font);
  font-size: 13px;
  background: transparent;
  border: 2px solid var(--green);
  color: var(--green);
  padding: 12px 16px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  outline: none;
  text-transform: uppercase;
  box-shadow: 0 0 10px rgba(0,255,65,0.3), inset 0 0 10px rgba(0,255,65,0.05);
  caret-color: var(--green);
  transition: box-shadow .2s;
}
.retro-input:focus {
  box-shadow: 0 0 20px rgba(0,255,65,0.6), inset 0 0 12px rgba(0,255,65,0.1);
}

.error-msg {
  font-size: 7px;
  color: var(--red);
  text-shadow: 0 0 6px var(--red);
  opacity: 0;
  transition: opacity .3s;
  height: 14px;
}
.error-msg.show { opacity: 1; }

/* Buttons */
.retro-btn {
  font-family: var(--font);
  font-size: clamp(8px, 1.5vw, 10px);
  padding: 12px 24px;
  border: 2px solid;
  cursor: pointer;
  background: transparent;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all .15s;
  min-width: 220px;
}
.btn-green {
  color: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 10px rgba(0,255,65,0.3);
}
.btn-green:hover {
  background: var(--green);
  color: var(--bg);
  box-shadow: 0 0 22px var(--green);
}
.btn-yellow {
  color: var(--yellow);
  border-color: var(--yellow);
  box-shadow: 0 0 8px rgba(255,230,0,0.2);
}
.btn-yellow:hover {
  background: var(--yellow);
  color: var(--bg);
  box-shadow: 0 0 18px var(--yellow);
}
.btn-red {
  color: var(--red);
  border-color: var(--red);
  box-shadow: 0 0 8px rgba(255,34,34,0.2);
}
.btn-red:hover {
  background: var(--red);
  color: #fff;
  box-shadow: 0 0 18px var(--red);
}

.controls-hint {
  font-size: 7px;
  color: rgba(0,255,65,0.5);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.sep { color: rgba(0,255,65,0.2); }

.insert-coin {
  font-size: 8px;
  color: var(--yellow);
  text-shadow: 0 0 8px var(--yellow);
  animation: blink 1s steps(1) infinite;
}

/* ===================== HUD ===================== */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(0,0,0,0.7);
  border-bottom: 2px solid var(--border);
  width: 100%;
  flex-wrap: wrap;
  gap: 8px;
  z-index: 10;
  flex-shrink: 0;
}

.hud-left, .hud-center, .hud-right, .hud-timer, .hud-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.lives-value { color: #ff4444; text-shadow: 0 0 6px #ff2222; letter-spacing: 2px; }
.coins-value { color: var(--yellow); text-shadow: 0 0 6px var(--yellow); }

.hud-label {
  font-size: 6px;
  color: rgba(0,255,65,0.5);
  letter-spacing: 2px;
}

.hud-value {
  font-size: clamp(9px, 2vw, 13px);
  color: var(--green);
  text-shadow: 0 0 6px var(--green);
}

.timer-value { color: var(--yellow); text-shadow: 0 0 6px var(--yellow); }
.timer-value.danger { color: var(--red); text-shadow: 0 0 10px var(--red); animation: blink .5s steps(1) infinite; }

/* ===================== CANVAS ===================== */
.canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
}

#game-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ===================== GAME OVER ===================== */
.gameover-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 30px 20px;
  max-width: 500px;
  width: 100%;
}

.gameover-title {
  font-size: clamp(24px, 6vw, 48px);
  color: var(--red);
  text-shadow: 0 0 12px var(--red), 0 0 30px var(--red);
  animation: flicker 3s infinite;
}

.gameover-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 9px;
  color: rgba(0,255,65,0.75);
  text-align: center;
  line-height: 2;
}

.highlight { color: var(--green); }
.highlight.green { color: var(--green); text-shadow: 0 0 8px var(--green); }

.record-msg {
  color: var(--yellow);
  text-shadow: 0 0 8px var(--yellow);
  font-size: 8px;
  animation: blink 1s steps(1) infinite;
  min-height: 16px;
}

.gameover-btns {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  align-items: center;
}

/* ===================== RANKING ===================== */
.ranking-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 20px;
  width: 100%;
  max-width: 600px;
  max-height: 100vh;
  overflow-y: auto;
}

.ranking-title {
  font-size: clamp(14px, 3vw, 22px);
  color: var(--yellow);
  text-shadow: 0 0 10px var(--yellow);
}

.ranking-table-wrapper {
  width: 100%;
  overflow-x: auto;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(7px, 1.4vw, 9px);
}

.ranking-table th {
  color: var(--yellow);
  padding: 10px 8px;
  border-bottom: 2px solid var(--yellow);
  text-align: left;
  white-space: nowrap;
}

.ranking-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--green);
  white-space: nowrap;
}

.ranking-table tr:hover td { background: var(--panel); }

.rank-1 td { color: #ffd700; text-shadow: 0 0 6px #ffd700; }
.rank-2 td { color: #c0c0c0; text-shadow: 0 0 4px #c0c0c0; }
.rank-3 td { color: #cd7f32; text-shadow: 0 0 4px #cd7f32; }

.ranking-empty {
  text-align: center;
  font-size: 9px;
  color: rgba(0,255,65,0.4);
  padding: 30px;
  line-height: 2.5;
  display: none;
}

/* ===================== OVERLAY ===================== */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.overlay.hidden { display: none; }

.overlay-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 40px;
  border: 2px solid var(--green);
  box-shadow: 0 0 30px rgba(0,255,65,0.4);
  text-align: center;
}

.overlay-title {
  font-size: clamp(12px, 2.5vw, 18px);
  color: var(--green);
  text-shadow: 0 0 12px var(--green);
}
.overlay-sub {
  font-size: clamp(9px, 1.8vw, 12px);
  color: var(--yellow);
  text-shadow: 0 0 8px var(--yellow);
}
.overlay-next {
  font-size: 8px;
  color: rgba(0,255,65,0.6);
  animation: blink .7s steps(1) infinite;
}

/* ===================== ANIMATIONS ===================== */
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes flicker {
  0%, 95%, 100% { opacity: 1; }
  96% { opacity: 0.85; }
  97% { opacity: 1; }
  98% { opacity: 0.7; }
  99% { opacity: 0.95; }
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 480px) {
  .hud { padding: 6px 10px; }
  .retro-btn { min-width: 180px; font-size: 7px; padding: 10px 16px; }
  .overlay-box { padding: 20px 20px; }
}
