/* ═══════════════════════════════════════════════════════════════
   PRO PARENT SOCCER LEAGUE — BLUE LOCK EDITION
   Dark, angular, neon-accented UI inspired by Blue Lock anime
   ═══════════════════════════════════════════════════════════════ */

/* Google Fonts loaded via <link> tags in index.html to avoid render-blocking */

/* ─── Blue Lock Design Tokens ─────────────────────────────── */
:root {
  --bl-bg-deep:       #020814;
  --bl-bg-navy:       #0a1128;
  --bl-bg-mid:        #0f1a36;
  --bl-neon-blue:     #00d4ff;
  --bl-neon-pink:     #ff2d78;
  --bl-neon-green:    #39ff14;
  --bl-neon-yellow:   #ffe600;
  --bl-electric:      #4d7cff;
  --bl-white:         #e8eaf6;
  --bl-white-dim:     rgba(232, 234, 246, 0.45);
  --bl-glow-blue:     0 0 12px rgba(0, 212, 255, 0.6), 0 0 40px rgba(0, 212, 255, 0.15);
  --bl-glow-pink:     0 0 12px rgba(255, 45, 120, 0.6), 0 0 40px rgba(255, 45, 120, 0.15);
  --bl-glow-green:    0 0 12px rgba(57, 255, 20, 0.6), 0 0 40px rgba(57, 255, 20, 0.15);
  --bl-font-body:     'Inter', system-ui, -apple-system, sans-serif;
  --bl-font-display:  'Bebas Neue', 'Inter', Impact, sans-serif;
}

/* ─── Keyframe Animations ─────────────────────────────────── */

/* Pulsing neon border glow */
@keyframes bl-glow-pulse {
  0%, 100% { box-shadow: var(--bl-glow-blue); }
  50%      { box-shadow: 0 0 20px rgba(0, 212, 255, 0.9), 0 0 60px rgba(0, 212, 255, 0.3); }
}

/* Rotating hue shift on active elements */
@keyframes bl-hue-rotate {
  0%   { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

/* Diagonal speed-line sweep (background decoration) */
@keyframes bl-speed-sweep {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Loading bar energy pulse */
@keyframes bl-bar-energy {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* Title text flicker */
@keyframes bl-text-flicker {
  0%, 95%, 100% { opacity: 1; }
  96%           { opacity: 0.6; }
  97%           { opacity: 1; }
  98%           { opacity: 0.7; }
}

/* Subtle breathing glow on the loading screen emblem */
@keyframes bl-breathe {
  0%, 100% { text-shadow: 0 0 8px rgba(0, 212, 255, 0.4), 0 0 24px rgba(0, 212, 255, 0.15); }
  50%      { text-shadow: 0 0 18px rgba(0, 212, 255, 0.8), 0 0 50px rgba(0, 212, 255, 0.3), 0 0 80px rgba(77, 124, 255, 0.15); }
}

/* Angular clip-path reveal for loading screen exit */
@keyframes bl-clip-exit {
  0%   { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
  100% { clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%); }
}

/* Scan line moving down (subtle) */
@keyframes bl-scanline {
  0%   { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bl-bg-deep);
  font-family: var(--bl-font-body);
  overscroll-behavior: none;
  position: fixed;
  touch-action: none;
  color: var(--bl-white);
}

/* ─── Game Container ──────────────────────────────────────── */
#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* modern override: respects dynamic viewport on mobile */
  display: flex;
  align-items: center;
  justify-content: center;
  /* Deep dramatic radial — dark navy core with subtle blue rim */
  background:
    radial-gradient(ellipse at 50% 30%, rgba(13, 27, 74, 0.5) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(0, 212, 255, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 20% 90%, rgba(255, 45, 120, 0.03) 0%, transparent 50%),
    linear-gradient(180deg, #020814 0%, #0a1128 40%, #0f1a36 100%);
  /* Respect safe areas (notch, Dynamic Island, home indicator) */
  padding:
    env(safe-area-inset-top, 0px)
    env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px)
    env(safe-area-inset-left, 0px);
}

/* ─── Canvas ──────────────────────────────────────────────── */
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
  image-rendering: auto;
  -webkit-touch-callout: none;
  touch-action: none;
}

#game-canvas:hover {
  cursor: pointer;
}

/* ─── Mobile Text Input (Name Entry) ─────────────────────── */
#mobile-text-input {
  position: absolute;
  left: 50%;
  bottom: 40%;
  transform: translateX(-50%);
  width: 280px;
  height: 48px;
  font-size: 18px;
  font-family: var(--bl-font-body);
  font-weight: 700;
  text-align: center;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--bl-neon-blue);
  background: rgba(2, 8, 20, 0.95);
  /* Angular border — no border-radius, diagonal clip instead */
  border: 2px solid var(--bl-neon-blue);
  border-radius: 0;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  outline: none;
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  transition: opacity 0.2s ease, box-shadow 0.3s ease;
  -webkit-user-select: text;
  user-select: text;
}

#mobile-text-input::placeholder {
  color: var(--bl-white-dim);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

#mobile-text-input.active {
  opacity: 1;
  pointer-events: auto;
  animation: bl-glow-pulse 2s ease-in-out infinite;
}

#mobile-text-input:focus {
  border-color: var(--bl-neon-pink);
  color: var(--bl-neon-pink);
  box-shadow: var(--bl-glow-pink);
}

/* ─── Loading Screen ──────────────────────────────────────── */
#loading-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    /* Diagonal speed lines behind the content */
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 40px,
      rgba(0, 212, 255, 0.015) 40px,
      rgba(0, 212, 255, 0.015) 42px
    ),
    linear-gradient(180deg, var(--bl-bg-deep) 0%, var(--bl-bg-navy) 100%);
  z-index: 100;
  transition: opacity 0.5s ease;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
}

#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Animated diagonal speed lines overlay */
#loading-screen::before {
  content: '';
  position: absolute;
  top: 0;
  left: -50%;
  width: 200%;
  height: 100%;
  background: repeating-linear-gradient(
    -60deg,
    transparent,
    transparent 80px,
    rgba(0, 212, 255, 0.03) 80px,
    rgba(0, 212, 255, 0.03) 82px
  );
  animation: bl-speed-sweep 8s linear infinite;
  pointer-events: none;
  z-index: 0;
}

/* Subtle scan line effect on loading screen */
#loading-screen::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--bl-neon-blue), transparent);
  opacity: 0.15;
  animation: bl-scanline 3s linear infinite;
  pointer-events: none;
  z-index: 1;
}

#loading-screen h1 {
  position: relative;
  z-index: 2;
  font-family: var(--bl-font-display);
  font-size: 44px;
  font-weight: 900;
  color: var(--bl-white);
  letter-spacing: 8px;
  text-transform: uppercase;
  margin-bottom: 6px;
  animation: bl-breathe 3s ease-in-out infinite, bl-text-flicker 6s ease-in-out infinite;
  /* Angular text shadow to give depth */
  text-shadow:
    0 0 10px rgba(0, 212, 255, 0.5),
    0 2px 0 rgba(0, 0, 0, 0.8),
    2px 4px 0 rgba(10, 17, 40, 0.5);
}

#loading-screen h2 {
  position: relative;
  z-index: 2;
  font-family: var(--bl-font-body);
  font-size: 16px;
  font-weight: 600;
  color: var(--bl-neon-blue);
  letter-spacing: 6px;
  text-transform: uppercase;
  margin-bottom: 36px;
  opacity: 0.8;
}

/* Loading bar — angular, no border-radius */
#loading-bar-container {
  position: relative;
  z-index: 2;
  width: 320px;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 0;
  overflow: hidden;
  /* Angular cut on the bar container */
  clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
}

#loading-bar {
  width: 0%;
  height: 100%;
  border-radius: 0;
  /* Animated neon gradient */
  background: linear-gradient(
    90deg,
    var(--bl-neon-blue),
    var(--bl-neon-pink),
    var(--bl-neon-blue),
    var(--bl-neon-green)
  );
  background-size: 200% 100%;
  animation: bl-bar-energy 1.5s linear infinite;
  transition: width 0.3s ease;
  /* Trailing glow */
  box-shadow:
    0 0 8px rgba(0, 212, 255, 0.6),
    0 0 20px rgba(0, 212, 255, 0.2);
}

#loading-text {
  position: relative;
  z-index: 2;
  color: var(--bl-white-dim);
  font-size: 11px;
  font-family: var(--bl-font-body);
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 18px;
}

/* ─── Scanline Overlay (desktop only for perf) ────────────── */
@media (hover: hover) {
  #game-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(0, 212, 255, 0.008) 3px,
      rgba(0, 212, 255, 0.008) 4px
    );
    z-index: 10;
  }
}

/* ═══════════════════════════════════════════════════════════════
   BLUE LOCK UTILITY CLASSES
   For use in JS-rendered UI or any DOM overlays
   ═══════════════════════════════════════════════════════════════ */

/* Glowing border on any element */
.bl-glow {
  box-shadow: var(--bl-glow-blue);
}

.bl-glow-pink {
  box-shadow: var(--bl-glow-pink);
}

.bl-glow-green {
  box-shadow: var(--bl-glow-green);
}

/* Pulsing glow animation */
.bl-glow-pulse {
  animation: bl-glow-pulse 2s ease-in-out infinite;
}

/* Angular clip — parallelogram cut */
.bl-clip-angular {
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}

/* Angular clip — reverse diagonal */
.bl-clip-angular-reverse {
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 100%, 10px 100%);
}

/* Neon text glow */
.bl-text-glow-blue {
  color: var(--bl-neon-blue);
  text-shadow: 0 0 8px rgba(0, 212, 255, 0.6), 0 0 24px rgba(0, 212, 255, 0.2);
}

.bl-text-glow-pink {
  color: var(--bl-neon-pink);
  text-shadow: 0 0 8px rgba(255, 45, 120, 0.6), 0 0 24px rgba(255, 45, 120, 0.2);
}

.bl-text-glow-green {
  color: var(--bl-neon-green);
  text-shadow: 0 0 8px rgba(57, 255, 20, 0.6), 0 0 24px rgba(57, 255, 20, 0.2);
}

/* Energy lines background */
.bl-energy-lines {
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 20px,
    rgba(0, 212, 255, 0.04) 20px,
    rgba(0, 212, 255, 0.04) 22px
  );
}

/* Speed lines — horizontal */
.bl-speed-lines {
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 6px,
    rgba(0, 212, 255, 0.05) 6px,
    rgba(0, 212, 255, 0.05) 7px
  );
}

/* Bold display font */
.bl-display {
  font-family: var(--bl-font-display);
  font-weight: 900;
  letter-spacing: 4px;
  text-transform: uppercase;
}

/* High-contrast panel background */
.bl-panel {
  background: rgba(10, 17, 40, 0.9);
  border: 1px solid rgba(0, 212, 255, 0.2);
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}

/* ─── Mobile Responsive ───────────────────────────────────── */
@media (max-width: 768px) {
  #loading-screen h1 {
    font-size: 30px;
    letter-spacing: 5px;
  }
  #loading-screen h2 {
    font-size: 12px;
    letter-spacing: 4px;
  }
  #loading-bar-container {
    width: 240px;
  }
  #mobile-text-input {
    width: 85%;
  }
}

@media (max-width: 480px) {
  #loading-screen h1 {
    font-size: 24px;
    letter-spacing: 3px;
  }
  #loading-screen h2 {
    font-size: 10px;
    letter-spacing: 3px;
    margin-bottom: 24px;
  }
  #loading-bar-container {
    width: 200px;
  }
}

/* ─── Landscape Safe Areas (iPhone notch on the side) ─────── */
@media (orientation: landscape) and (max-height: 500px) {
  #game-container {
    padding-left: max(env(safe-area-inset-left, 0px), 20px);
    padding-right: max(env(safe-area-inset-right, 0px), 20px);
  }
}
