/* ============================================================
   H4KKEN - Global Styles
   ============================================================ */

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

:root {
  --primary: #00f0ff;
  --primary-dark: #007a82;
  --secondary: #ff2d6a;
  --warning: #ffaa00;
  --bg-dark: #0a0a0f;
  --bg-panel: rgba(10, 10, 20, 0.85);
  --text: #e8e8f0;
  --p1-color: #00c8ff;
  --p2-color: #ff3366;
  --health-green: #00ff88;
  --health-yellow: #ffcc00;
  --health-red: #ff2244;
  --health-bg: #1a1a2e;
  --font-main: 'Orbitron', sans-serif;
  --font-body: 'Rajdhani', sans-serif;
}

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

#game-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* ============================================================
   Screens
   ============================================================ */

.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
  background: linear-gradient(135deg, rgba(5,5,15,0.97), rgba(10,10,30,0.95));
}

.screen.active {
  display: flex;
}

/* ============================================================
   Game Title
   ============================================================ */

.game-title {
  font-family: var(--font-main);
  font-size: 6rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--primary);
  text-shadow:
    0 0 20px rgba(0,240,255,0.5),
    0 0 60px rgba(0,240,255,0.2);
  margin-bottom: 0.5rem;
  user-select: none;
}

/* Glitch Effect */
.glitch {
  position: relative;
  animation: glitch-skew 4s infinite linear alternate-reverse;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.glitch::before {
  color: var(--secondary);
  animation: glitch-left 3s infinite linear alternate-reverse;
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
  z-index: -1;
}

.glitch::after {
  color: var(--primary);
  animation: glitch-right 2s infinite linear alternate-reverse;
  clip-path: polygon(0 60%, 100% 60%, 100% 100%, 0 100%);
  z-index: -1;
}

@keyframes glitch-left {
  0%, 90% { transform: translate(0); }
  91% { transform: translate(-3px, 1px); }
  93% { transform: translate(2px, -1px); }
  95% { transform: translate(-1px, 2px); }
  100% { transform: translate(0); }
}

@keyframes glitch-right {
  0%, 88% { transform: translate(0); }
  89% { transform: translate(3px, -1px); }
  92% { transform: translate(-2px, 1px); }
  96% { transform: translate(1px, -2px); }
  100% { transform: translate(0); }
}

@keyframes glitch-skew {
  0%, 95% { transform: skew(0deg); }
  96% { transform: skew(1deg); }
  98% { transform: skew(-0.5deg); }
  100% { transform: skew(0deg); }
}

.menu-subtitle {
  font-family: var(--font-main);
  font-size: 1.2rem;
  letter-spacing: 0.5em;
  color: var(--secondary);
  margin-bottom: 3rem;
  text-align: center;
}

/* ============================================================
   Loading Screen
   ============================================================ */

.loading-content {
  text-align: center;
}

.loading-bar-container {
  width: 400px;
  height: 6px;
  background: var(--health-bg);
  border-radius: 3px;
  margin: 2rem auto;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.loading-text {
  font-family: var(--font-body);
  font-size: 1rem;
  color: rgba(255,255,255,0.5);
}

/* ============================================================
   Menu
   ============================================================ */

.menu-content {
  text-align: center;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.menu-input {
  font-family: var(--font-main);
  font-size: 1rem;
  padding: 0.8rem 2rem;
  width: 300px;
  background: rgba(0,240,255,0.05);
  border: 1px solid rgba(0,240,255,0.3);
  border-radius: 4px;
  color: var(--primary);
  text-align: center;
  outline: none;
  transition: border-color 0.3s;
  letter-spacing: 0.1em;
}

.menu-input::placeholder {
  color: rgba(0,240,255,0.3);
}

.menu-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(0,240,255,0.15);
}

.menu-btn {
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  padding: 0.9rem 3rem;
  width: 300px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}

.menu-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0,240,255,0.07), transparent);
  transition: left 0.4s;
}

.menu-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  text-shadow: 0 0 10px rgba(0,240,255,0.5);
}

.menu-btn:hover::after {
  left: 100%;
}

.menu-btn.primary {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(0,240,255,0.08);
}

.menu-btn.primary:hover {
  background: rgba(0,240,255,0.15);
  box-shadow: 0 0 30px rgba(0,240,255,0.15);
}

/* ============================================================
   Waiting Screen
   ============================================================ */

.waiting-content {
  text-align: center;
}

.waiting-content h2 {
  font-family: var(--font-main);
  font-size: 1.8rem;
  letter-spacing: 0.1em;
  color: var(--primary);
  margin-bottom: 2rem;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(0,240,255,0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 2rem;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   Controls Screen
   ============================================================ */

.controls-content {
  text-align: center;
  max-width: 900px;
  padding: 2rem;
}

.controls-content h2 {
  font-family: var(--font-main);
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 2rem;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  margin-bottom: 2rem;
  text-align: left;
}

.control-section h3 {
  font-family: var(--font-main);
  font-size: 0.9rem;
  color: var(--secondary);
  margin-bottom: 0.8rem;
  letter-spacing: 0.1em;
}

.control-row {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  color: rgba(255,255,255,0.7);
}

.key {
  display: inline-block;
  font-family: var(--font-main);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  min-width: 1.8rem;
  text-align: center;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 3px;
  color: var(--primary);
  margin-right: 0.3rem;
}

.key.attack {
  border-color: var(--secondary);
  color: var(--secondary);
}

.control-layout {
  margin-bottom: 0.8rem;
}

.control-layout .label {
  display: block;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
  margin-top: 0.2rem;
}

/* ============================================================
   Fight HUD
   ============================================================ */

.hud {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 50;
  pointer-events: none;
}

.hud.hidden {
  display: none;
}

.health-bar-section {
  padding: 15px 30px 10px;
}

.player-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.player-info.p2-info {
  flex-direction: row-reverse;
}

.player-name {
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.p1-info .player-name { color: var(--p1-color); }
.p2-info .player-name { color: var(--p2-color); }

.win-indicators {
  display: flex;
  gap: 6px;
}

.win-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  background: transparent;
}

.win-dot.won {
  background: var(--warning);
  border-color: var(--warning);
  box-shadow: 0 0 8px rgba(255,170,0,0.5);
}

.health-bars {
  display: flex;
  align-items: center;
  gap: 0;
}

.health-bar-wrapper {
  flex: 1;
  height: 28px;
  position: relative;
}

.health-bar-bg {
  width: 100%;
  height: 100%;
  background: var(--health-bg);
  position: relative;
  overflow: hidden;
}

.p1-bar .health-bar-bg {
  clip-path: polygon(0 0, 100% 0, 97% 100%, 0 100%);
}

.p2-bar .health-bar-bg {
  clip-path: polygon(3% 0, 100% 0, 100% 100%, 0 100%);
}

.health-bar-fill {
  position: absolute;
  top: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, var(--health-green), #00cc66);
  transition: width 0.15s ease-out;
}

.health-bar-fill.medium {
  background: linear-gradient(180deg, var(--health-yellow), #cc9900);
}

.health-bar-fill.low {
  background: linear-gradient(180deg, var(--health-red), #cc1133);
  animation: health-pulse 0.5s ease-in-out infinite;
}

@keyframes health-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.health-bar-damage {
  position: absolute;
  top: 0;
  height: 100%;
  width: 100%;
  background: var(--health-red);
  opacity: 0.6;
  transition: width 0.8s ease-out 0.4s;
}

.p1-bar .health-bar-fill,
.p1-bar .health-bar-damage {
  right: 0;
  left: auto;
}

.p2-bar .health-bar-fill,
.p2-bar .health-bar-damage {
  left: 0;
}

.timer-box {
  width: 70px;
  height: 55px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-panel);
  border: 2px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
  z-index: 1;
}

.timer-box span {
  font-family: var(--font-main);
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--text);
}

.timer-box span.urgent {
  color: var(--health-red);
  animation: timer-flash 0.5s ease-in-out infinite;
}

@keyframes timer-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================================
   Combo Display
   ============================================================ */

.combo-display {
  position: fixed;
  top: 30%;
  padding: 10px 25px;
  background: rgba(0,0,0,0.7);
  border-left: 3px solid;
  animation: combo-pop 0.3s ease-out;
}

.combo-display.hidden { display: none; }

.combo-display.p1-combo {
  left: 40px;
  border-color: var(--p1-color);
}

.combo-display.p2-combo {
  right: 40px;
  border-color: var(--p2-color);
}

.combo-hits {
  font-family: var(--font-main);
  font-size: 2.5rem;
  font-weight: 900;
  display: block;
}

.p1-combo .combo-hits { color: var(--p1-color); }
.p2-combo .combo-hits { color: var(--p2-color); }

.combo-label {
  font-family: var(--font-main);
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  color: rgba(255,255,255,0.6);
}

.combo-damage {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--health-red);
  display: block;
  margin-top: 4px;
}

@keyframes combo-pop {
  from { transform: scale(1.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ============================================================
   Announcements
   ============================================================ */

.announcement {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 200;
  pointer-events: none;
}

.announcement.hidden { display: none; }

.announce-text {
  font-family: var(--font-main);
  font-size: 5rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: white;
  text-shadow:
    0 0 30px rgba(0,240,255,0.8),
    0 0 80px rgba(0,240,255,0.3),
    3px 3px 0 rgba(255,45,106,0.6);
  animation: announce-in 0.5s ease-out;
}

.announce-sub {
  font-family: var(--font-main);
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  color: var(--warning);
  margin-top: 0.5rem;
  animation: announce-in 0.5s ease-out 0.2s both;
}

@keyframes announce-in {
  from {
    transform: scale(2) translateY(-20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.announce-text.ko {
  font-size: 8rem;
  color: var(--health-red);
  text-shadow:
    0 0 40px rgba(255,34,68,0.8),
    0 0 100px rgba(255,34,68,0.4);
}

.announce-text.victory {
  color: var(--warning);
  text-shadow:
    0 0 30px rgba(255,170,0,0.8),
    0 0 80px rgba(255,170,0,0.3);
}

/* ============================================================
   Input Display (debug, can be toggled)
   ============================================================ */

.input-display {
  position: fixed;
  bottom: 20px;
  padding: 10px;
  background: rgba(0,0,0,0.7);
  font-family: var(--font-body);
  font-size: 0.85rem;
  z-index: 60;
  border-radius: 4px;
}

.input-display.p1 { left: 20px; }
.input-display.p2 { right: 20px; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
  .game-title { font-size: 3.5rem; }
  .controls-grid { grid-template-columns: 1fr; }
  .menu-btn, .menu-input { width: 250px; }
}
