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

:root {
  --neon-green: #00ff41;
  --neon-green-dim: #00cc33;
  --bg-dark: #0a0a0a;
  --bg-card: #0d1117;
  --text-dim: #4a5568;
  --border-color: #1a2332;
}

body {
  font-family: 'Fira Code', monospace;
  background-color: var(--bg-dark);
  color: #e2e8f0;
  min-height: 100vh;
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  position: relative;
  padding: 1rem;
}

.grid-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    linear-gradient(rgba(0, 255, 65, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 65, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 0;
}

.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.1) 0px,
    rgba(0, 0, 0, 0.1) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: 1000;
  opacity: 0.3;
}

.header {
  text-align: center;
  padding: 2rem 1rem;
  position: relative;
  z-index: 1;
}

.glitch {
  position: relative;
  font-size: clamp(1.8rem, 6vw, 3.5rem);
  font-weight: 700;
  color: var(--neon-green);
  text-shadow: 
    0 0 10px var(--neon-green),
    0 0 20px var(--neon-green),
    0 0 40px var(--neon-green),
    0 0 80px var(--neon-green);
  animation: flicker 3s infinite;
}

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

.glitch::before {
  animation: glitch-1 2s infinite linear alternate-reverse;
  clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
  color: #ff0040;
  text-shadow: -2px 0 #ff0040;
}

.glitch::after {
  animation: glitch-2 3s infinite linear alternate-reverse;
  clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
  color: #00ffff;
  text-shadow: 2px 0 #00ffff;
}

@keyframes glitch-1 {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-2px, 2px); }
  40% { transform: translate(-2px, -2px); }
  60% { transform: translate(2px, 2px); }
  80% { transform: translate(2px, -2px); }
}

@keyframes glitch-2 {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(2px, -2px); }
  40% { transform: translate(2px, 2px); }
  60% { transform: translate(-2px, -2px); }
  80% { transform: translate(-2px, 2px); }
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.8; }
  94% { opacity: 1; }
  96% { opacity: 0.9; }
  97% { opacity: 1; }
}

.subtitle {
  color: var(--text-dim);
  font-size: clamp(0.75rem, 2vw, 1rem);
  margin-top: 1rem;
}

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.input-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  padding: 2rem 1rem;
}

@media (min-width: 768px) {
  .input-section {
    flex-direction: row;
    justify-content: center;
  }
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.5rem 1rem;
  width: 100%;
  max-width: 280px;
  transition: all 0.3s ease;
}

.input-wrapper:focus-within {
  border-color: var(--neon-green);
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.3);
}

.input-prefix {
  color: var(--neon-green);
  margin-right: 0.5rem;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.terminal-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--neon-green);
  font-family: 'Fira Code', monospace;
  font-size: 1rem;
  width: 100%;
}

.terminal-input::placeholder {
  color: var(--text-dim);
}

.battle-btn {
  background: linear-gradient(135deg, var(--neon-green-dim), var(--neon-green));
  color: var(--bg-dark);
  border: none;
  padding: 1rem 2rem;
  font-family: 'Fira Code', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
  animation: pulse-glow 2s infinite;
  text-transform: uppercase;
}

.battle-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(0, 255, 65, 0.6);
}

.battle-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  animation: none;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 10px rgba(0, 255, 65, 0.4); }
  50% { box-shadow: 0 0 25px rgba(0, 255, 65, 0.8); }
}

.error-msg {
  text-align: center;
  padding: 1rem;
  margin: 1rem auto;
  max-width: 500px;
  background: rgba(255, 0, 64, 0.1);
  border: 1px solid #ff0040;
  border-radius: 4px;
}

.error-glitch {
  color: #ff0040;
  animation: error-flash 0.5s infinite;
}

@keyframes error-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.easter-egg {
  text-align: center;
  padding: 2rem;
  margin: 2rem auto;
  max-width: 400px;
  background: var(--bg-card);
  border: 2px dashed var(--neon-green);
  border-radius: 8px;
  animation: egg-wobble 0.5s ease;
}

@keyframes egg-wobble {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-2deg); }
  75% { transform: rotate(2deg); }
}

.egg-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.egg-icon {
  font-size: 3rem;
}

.egg-text {
  color: var(--neon-green);
  font-size: 1.5rem;
  font-weight: 700;
}

.egg-sub {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.loading-section {
  text-align: center;
  padding: 3rem 1rem;
}

.loading-text {
  color: var(--neon-green);
  font-size: 1.2rem;
  margin-bottom: 1rem;
  animation: loading-blink 1s infinite;
}

@keyframes loading-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.loading-bar {
  width: 100%;
  max-width: 400px;
  height: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  margin: 0 auto;
  overflow: hidden;
}

.loading-progress {
  height: 100%;
  background: var(--neon-green);
  animation: loading-fill 2s ease-in-out infinite;
  box-shadow: 0 0 10px var(--neon-green);
}

@keyframes loading-fill {
  0% { width: 0%; }
  50% { width: 80%; }
  100% { width: 100%; }
}

.battle-arena {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 2rem 1rem;
  align-items: center;
}

@media (min-width: 900px) {
  .battle-arena {
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
  }
}

.vs-divider {
  color: var(--neon-green);
  font-size: 2rem;
  font-weight: 700;
  text-shadow: 0 0 10px var(--neon-green);
  display: flex;
  align-items: center;
  justify-content: center;
}

.battle-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  width: 100%;
  max-width: 380px;
  position: relative;
  transition: all 0.3s ease;
}

.winner-card {
  border-color: var(--neon-green);
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
}

.winner-badge {
  position: absolute;
  top: -12px;
  right: 20px;
  background: var(--neon-green);
  color: var(--bg-dark);
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  animation: badge-glow 1s infinite alternate;
}

@keyframes badge-glow {
  from { box-shadow: 0 0 5px var(--neon-green); }
  to { box-shadow: 0 0 15px var(--neon-green); }
}

.card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  transition: all 0.3s ease;
}

.winner-avatar {
  border-color: var(--neon-green);
  box-shadow: 0 0 15px rgba(0, 255, 65, 0.5);
}

.user-info {
  flex: 1;
  min-width: 0;
}

.username {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.handle {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.bio {
  color: var(--text-dim);
  font-size: 0.8rem;
  line-height: 1.4;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-icon {
  font-size: 0.9rem;
}

.stat-label {
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.stat-value {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 600;
}

.power-section {
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.power-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.power-label {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-transform: uppercase;
}

.power-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
}

.winner-power {
  color: var(--neon-green);
  text-shadow: 0 0 10px rgba(0, 255, 65, 0.5);
}

.power-bar-container {
  height: 8px;
  background: var(--bg-dark);
  border-radius: 4px;
  overflow: hidden;
}

.power-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-green-dim), var(--neon-green));
  transition: width 0.1s linear;
  border-radius: 4px;
}

.winner-bar {
  box-shadow: 0 0 10px var(--neon-green);
}

.result-section {
  text-align: center;
  padding: 3rem 1rem;
  animation: fade-in 0.5s ease;
}

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

.trophy-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: trophy-bounce 1s ease infinite;
}

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

.result-text {
  color: var(--neon-green);
  font-size: 1.5rem;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(0, 255, 65, 0.5);
}

.history-section {
  max-width: 500px;
  margin: 2rem auto;
  padding: 1rem;
}

.history-toggle {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-dim);
  padding: 0.75rem 1rem;
  width: 100%;
  font-family: 'Fira Code', monospace;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.history-toggle:hover {
  border-color: var(--neon-green);
  color: var(--neon-green);
}

.history-list {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 4px 4px;
  padding: 0.5rem;
}

.history-item {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-dim);
}

.history-item:last-child {
  border-bottom: none;
}

.winner-name {
  color: var(--neon-green);
  font-weight: 600;
}

.vs-small {
  color: var(--text-dim);
  opacity: 0.5;
}

.history-scores {
  opacity: 0.6;
  font-size: 0.75rem;
}

.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  position: relative;
  z-index: 1;
}

.footer a {
  color: var(--neon-green);
  text-decoration: none;
  transition: all 0.3s ease;
}

.footer a:hover {
  text-shadow: 0 0 10px var(--neon-green);
}