/* Shared Styles for String Algorithm Games */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@300;400;500;700&family=Fira+Code:wght@400;500&display=swap');

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

:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #8892b0;
  --accent-cyan: #00f5ff;
  --accent-magenta: #ff00ff;
  --accent-gold: #ffcc00;
  --accent-green: #00ff88;
  --accent-red: #ff6b6b;
  --accent-purple: #7b68ee;
  --accent-orange: #ff8c00;
}

body {
  font-family: 'Rajdhani', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
}

/* Common Game Container */
.game-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Header Styles */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  background: rgba(20, 20, 40, 0.8);
  border-bottom: 2px solid var(--accent);
  margin-bottom: 30px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  text-decoration: none;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 500;
  transition: all 0.3s;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--accent);
}

.game-title {
  font-family: 'Orbitron', monospace;
  font-size: 1.5rem;
  color: var(--accent);
}

/* Score Display */
.score-display {
  display: flex;
  gap: 20px;
  font-family: 'Fira Code', monospace;
}

.score-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-item label {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.score-item span {
  color: var(--accent);
  font-weight: bold;
}

/* Character Grid */
.char-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 30px 0;
}

.char-tile {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fira Code', monospace;
  font-size: 1.5rem;
  font-weight: bold;
  background: linear-gradient(
    145deg,
    rgba(30, 30, 50, 0.9),
    rgba(20, 20, 40, 0.95)
  );
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
}

.char-tile:hover {
  transform: scale(1.1);
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--glow);
}

.char-tile.selected {
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 30px var(--glow);
}

.char-tile .index {
  position: absolute;
  bottom: -18px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  font-family: 'Orbitron', monospace;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 4px 15px var(--glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px var(--glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Input Fields */
.input-field {
  padding: 12px 20px;
  font-family: 'Fira Code', monospace;
  font-size: 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  outline: none;
  transition: all 0.3s;
}

.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 15px var(--glow);
}

/* Info Panels */
.info-panel {
  background: rgba(20, 20, 40, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px;
  margin: 20px 0;
}

.info-panel h3 {
  font-family: 'Orbitron', monospace;
  color: var(--accent);
  margin-bottom: 10px;
}

/* Code Display */
.code-display {
  font-family: 'Fira Code', monospace;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 15px;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--accent-cyan);
}

/* Result Display */
.result-display {
  font-family: 'Fira Code', monospace;
  font-size: 1.2rem;
  text-align: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  border: 2px solid var(--accent);
  color: var(--accent);
  margin: 20px 0;
}

/* Animations */
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes glow {
  0%,
  100% {
    box-shadow: 0 0 5px var(--glow);
  }
  50% {
    box-shadow: 0 0 25px var(--glow);
  }
}

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

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

/* Level Indicator */
.level-indicator {
  font-family: 'Orbitron', monospace;
  font-size: 0.9rem;
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  gap: 10px;
}

.level-indicator .level-num {
  background: rgba(255, 204, 0, 0.2);
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid rgba(255, 204, 0, 0.5);
}

/* Progress Bar */
.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: linear-gradient(145deg, #1a1a2e, #0a0a1a);
  border: 2px solid var(--accent);
  border-radius: 20px;
  padding: 40px;
  max-width: 500px;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s;
}

.modal.active .modal-content {
  transform: scale(1);
}

.modal-content h2 {
  font-family: 'Orbitron', monospace;
  color: var(--accent);
  font-size: 2rem;
  margin-bottom: 15px;
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 25px;
}

/* Tooltip */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.tooltip:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Responsive */
@media (max-width: 768px) {
  .game-header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }

  .char-tile {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .btn {
    padding: 10px 20px;
    font-size: 0.8rem;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-dark);
}
