/* ============================================
   BINARY BATTLE — HAL-Ω vs Warrior / Guardian
   80s arcade × holodeck
   ============================================ */

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

.hal-game-overlay {
  position: fixed;
  inset: 0;
  z-index: 100002;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-3);
  background: rgba(2, 6, 14, 0.92);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.hal-game-overlay--open {
  opacity: 1;
  pointer-events: auto;
}

.hal-game-cabinet {
  position: relative;
  width: min(960px, 100%);
  max-height: calc(100vh - 32px);
  overflow: hidden;
  border-radius: 18px;
  border: 3px solid rgba(255, 60, 60, 0.55);
  box-shadow:
    0 0 0 2px rgba(0, 212, 255, 0.25),
    0 0 60px rgba(255, 40, 40, 0.35),
    0 24px 80px rgba(0, 0, 0, 0.65),
    inset 0 0 80px rgba(0, 212, 255, 0.06);
  background:
    linear-gradient(180deg, #1a0a12 0%, #0a1020 40%, #061018 100%);
  font-family: 'Share Tech Mono', monospace;
  color: #b8f4ff;
}

.hal-game-cabinet::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.14) 2px,
    rgba(0, 0, 0, 0.14) 4px
  );
  z-index: 20;
  opacity: 0.35;
}

.hal-game-cabinet::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(0, 212, 255, 0.12) 0%, transparent 55%),
    linear-gradient(90deg, transparent 48%, rgba(0, 212, 255, 0.03) 50%, transparent 52%);
  z-index: 1;
}

.hal-game-marquee {
  position: relative;
  z-index: 5;
  padding: 14px 20px;
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.55rem, 2.2vw, 0.72rem);
  letter-spacing: 0.12em;
  color: #ff4444;
  text-shadow: 0 0 20px rgba(255, 60, 60, 0.9), 0 0 40px rgba(255, 0, 0, 0.4);
  background: linear-gradient(180deg, #2a0810 0%, #120818 100%);
  border-bottom: 2px solid rgba(255, 60, 60, 0.45);
  animation: halMarqueePulse 2.4s ease-in-out infinite;
}

.hal-game-screen {
  position: relative;
  z-index: 5;
  min-height: 480px;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 100%, rgba(0, 212, 255, 0.08) 0%, transparent 45%),
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(0, 212, 255, 0.04) 31px, rgba(0, 212, 255, 0.04) 32px),
    repeating-linear-gradient(90deg, transparent, transparent 31px, rgba(0, 212, 255, 0.04) 31px, rgba(0, 212, 255, 0.04) 32px);
}

.hal-game-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 30;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.hal-game-close:hover {
  border-color: #ff4444;
  color: #ff6666;
}

/* Title screen */
.hal-game-title {
  text-align: center;
  padding: 24px 12px;
}

.hal-game-title h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.9rem, 3.5vw, 1.35rem);
  color: #00d4ff;
  text-shadow: 0 0 24px rgba(0, 212, 255, 0.8);
  margin-bottom: 12px;
  line-height: 1.5;
}

.hal-game-title p {
  font-size: 0.95rem;
  color: rgba(255, 180, 180, 0.85);
  margin-bottom: 24px;
  line-height: 1.6;
}

.hal-game-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  margin: 6px;
  border: 2px solid rgba(0, 212, 255, 0.55);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(0, 80, 120, 0.6) 0%, rgba(0, 30, 50, 0.8) 100%);
  color: #e8fcff;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.5rem, 2vw, 0.62rem);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hal-game-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 0 28px rgba(0, 212, 255, 0.45);
}

.hal-game-btn--danger {
  border-color: rgba(255, 60, 60, 0.65);
  background: linear-gradient(180deg, rgba(120, 20, 20, 0.7) 0%, rgba(40, 8, 8, 0.85) 100%);
  color: #ffaaaa;
}

.hal-game-btn--danger:hover {
  box-shadow: 0 0 28px rgba(255, 60, 60, 0.45);
}

/* Character select */
.hal-game-select {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 640px;
  margin: 0 auto;
}

.hal-game-hero-card {
  padding: 16px;
  border: 2px solid rgba(0, 212, 255, 0.35);
  border-radius: 10px;
  background: rgba(0, 20, 40, 0.65);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.hal-game-hero-card:hover,
.hal-game-hero-card--selected {
  border-color: rgba(255, 200, 80, 0.75);
  box-shadow: 0 0 30px rgba(255, 180, 60, 0.25);
  transform: translateY(-4px);
}

.hal-game-hero-card--guardian {
  border-color: rgba(247, 37, 133, 0.4);
}

.hal-game-hero-card--guardian:hover,
.hal-game-hero-card--guardian.hal-game-hero-card--selected {
  border-color: rgba(247, 37, 133, 0.75);
  box-shadow: 0 0 30px rgba(247, 37, 133, 0.3);
}

.hal-game-hero-icon {
  width: 80px;
  height: 100px;
  margin: 0 auto 12px;
}

.hal-game-hero-card h3 {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.58rem;
  margin-bottom: 8px;
  color: #ffd86b;
}

.hal-game-hero-card--guardian h3 {
  color: #ff8ec8;
}

.hal-game-hero-card p {
  font-size: 0.78rem;
  line-height: 1.5;
  color: rgba(200, 230, 255, 0.75);
}

/* Battle arena */
.hal-game-arena {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}

.hal-game-fighter {
  text-align: center;
}

.hal-game-fighter__sprite {
  width: 100px;
  height: 130px;
  margin: 0 auto 8px;
  filter: drop-shadow(0 0 16px rgba(0, 212, 255, 0.4));
}

.hal-game-fighter__sprite--hal {
  filter: drop-shadow(0 0 20px rgba(255, 40, 40, 0.7));
}

.hal-game-fighter__name {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
  margin-bottom: 8px;
}

.hal-game-hp {
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.5);
  overflow: hidden;
  margin-bottom: 4px;
}

.hal-game-hp__fill {
  height: 100%;
  background: linear-gradient(90deg, #00aa44, #00ff88);
  transition: width 0.4s ease;
  box-shadow: 0 0 10px rgba(0, 255, 120, 0.5);
}

.hal-game-hp__fill--hal {
  background: linear-gradient(90deg, #aa1111, #ff3333);
  box-shadow: 0 0 10px rgba(255, 60, 60, 0.6);
}

.hal-game-hp__text {
  font-size: 0.72rem;
  color: rgba(200, 230, 255, 0.7);
}

.hal-game-vs {
  font-family: 'Press Start 2P', monospace;
  font-size: 1rem;
  color: #ff4444;
  text-shadow: 0 0 16px rgba(255, 60, 60, 0.8);
  padding-bottom: 40px;
}

.hal-game-hal-eye {
  width: 72px;
  height: 72px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff6666 0%, #cc0000 40%, #440000 100%);
  box-shadow: 0 0 30px rgba(255, 0, 0, 0.8), inset 0 0 20px rgba(255, 200, 200, 0.3);
  position: relative;
  animation: halEyePulse 2s ease-in-out infinite;
}

.hal-game-hal-eye::after {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #ffaaaa 30%, #880000 100%);
}

.hal-game-console {
  border: 2px solid rgba(0, 212, 255, 0.35);
  border-radius: 10px;
  background: rgba(0, 12, 24, 0.85);
  padding: 16px;
  margin-top: 8px;
}

.hal-game-taunt {
  min-height: 52px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-left: 3px solid #ff3333;
  background: rgba(80, 0, 0, 0.25);
  font-size: 0.88rem;
  line-height: 1.55;
  color: #ffaaaa;
}

.hal-game-taunt strong {
  color: #ff4444;
}

.hal-game-log {
  min-height: 48px;
  font-size: 0.82rem;
  color: rgba(0, 212, 255, 0.85);
  margin-bottom: 14px;
  line-height: 1.5;
}

.hal-game-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.hal-game-action {
  flex: 1;
  min-width: 140px;
  max-width: 220px;
  padding: 18px 12px;
  border: 3px solid;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.55rem, 2vw, 0.7rem);
  text-align: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.hal-game-action:active {
  transform: scale(0.96);
}

.hal-game-action--shield {
  border-color: #00d4ff;
  background: linear-gradient(180deg, rgba(0, 100, 140, 0.7) 0%, rgba(0, 40, 60, 0.9) 100%);
  color: #aaf8ff;
  box-shadow: 0 0 24px rgba(0, 212, 255, 0.3);
}

.hal-game-action--shield:hover {
  box-shadow: 0 0 32px rgba(0, 212, 255, 0.55);
}

.hal-game-action--spear {
  border-color: #ffd86b;
  background: linear-gradient(180deg, rgba(140, 100, 0, 0.7) 0%, rgba(60, 40, 0, 0.9) 100%);
  color: #fff3c4;
  box-shadow: 0 0 24px rgba(255, 200, 80, 0.3);
}

.hal-game-action--spear:hover {
  box-shadow: 0 0 32px rgba(255, 200, 80, 0.55);
}

.hal-game-action__key {
  display: block;
  font-size: 1.4rem;
  margin-bottom: 6px;
  opacity: 0.9;
}

.hal-game-action__label {
  display: block;
  font-size: 0.48rem;
  letter-spacing: 0.08em;
}

.hal-game-hint {
  width: 100%;
  text-align: center;
  font-size: 0.72rem;
  color: rgba(180, 200, 220, 0.55);
  margin-top: 8px;
}

.hal-game-deck-label {
  text-align: center;
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(0, 212, 255, 0.45);
  margin-bottom: 12px;
}

.hal-game-result {
  text-align: center;
  padding: 32px 16px;
}

.hal-game-result h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.8rem, 3vw, 1.1rem);
  margin-bottom: 16px;
  line-height: 1.6;
}

.hal-game-result--win h2 {
  color: #00ff88;
  text-shadow: 0 0 24px rgba(0, 255, 120, 0.7);
}

.hal-game-result--lose h2 {
  color: #ff4444;
  text-shadow: 0 0 24px rgba(255, 60, 60, 0.7);
}

.hal-game-flash-fx {
  position: fixed;
  inset: 0;
  z-index: 100001;
  pointer-events: none;
  background: radial-gradient(circle at var(--flash-x, 50%) var(--flash-y, 90%), rgba(255, 255, 255, 0.9) 0%, rgba(255, 60, 60, 0.4) 30%, transparent 60%);
  opacity: 0;
  transition: opacity 0.1s ease-out;
}

.hal-game-flash-fx--on {
  opacity: 1;
}

.hal-game-flash-fx--off {
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

.hal-game-fighter--hit {
  animation: halFighterHit 0.35s ease;
}

.hal-game-fighter--block {
  animation: halFighterBlock 0.35s ease;
}

@keyframes halMarqueePulse {
  0%, 100% { opacity: 0.92; }
  50% { opacity: 1; }
}

@keyframes halEyePulse {
  0%, 100% { box-shadow: 0 0 30px rgba(255, 0, 0, 0.8); }
  50% { box-shadow: 0 0 50px rgba(255, 60, 60, 1); }
}

@keyframes halFighterHit {
  0%, 100% { transform: translateX(0); filter: brightness(1); }
  25% { transform: translateX(-8px); filter: brightness(1.8) hue-rotate(-20deg); }
  75% { transform: translateX(8px); filter: brightness(1.4); }
}

@keyframes halFighterBlock {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); filter: brightness(1.3); }
}

@media (max-width: 640px) {
  .hal-game-select {
    grid-template-columns: 1fr;
  }

  .hal-game-arena {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .hal-game-vs {
    padding: 8px 0;
  }

  .hal-game-screen {
    min-height: 420px;
    padding: 14px;
  }
}

body.hal-game-open {
  overflow: hidden;
}
