/* ============================================
   STACK HEROES: THE TOWER OF OPERATIONS
   Complete Stylesheet
   ============================================ */

/* CSS Variables - Dark Fantasy Theme */
:root {
  /* Primary Colors */
  --bg-dark: #0a0a0f;
  --bg-darker: #050508;
  --bg-gradient: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #0a0a0f 100%);

  /* Accent Colors */
  --primary: #6366f1;
  --primary-glow: #818cf8;
  --secondary: #10b981;
  --accent-gold: #fbbf24;
  --accent-red: #ef4444;
  --accent-purple: #a855f7;
  --accent-cyan: #06b6d4;
  --accent-orange: #f97316;

  /* Text Colors */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Stack Element Colors */
  --stack-1: #6366f1;
  --stack-2: #8b5cf6;
  --stack-3: #a855f7;
  --stack-4: #d946ef;
  --stack-5: #ec4899;

  /* Realm Colors */
  --realm-1: #3b82f6;
  --realm-2: #8b5cf6;
  --realm-3: #ec4899;
  --realm-4: #f97316;
  --realm-5: #eab308;
  --realm-6: #22c55e;
  --realm-7: #14b8a6;
  --realm-8: #06b6d4;
  --realm-9: #6366f1;
  --realm-10: #ef4444;

  /* UI */
  --border-color: rgba(99, 102, 241, 0.3);
  --card-bg: rgba(15, 15, 25, 0.8);
  --glass-bg: rgba(255, 255, 255, 0.05);

  /* Fonts */
  --font-display: 'Cinzel', serif;
  --font-ui: 'Rajdhani', sans-serif;
  --font-mono: 'Orbitron', monospace;

  /* Sizing */
  --stack-item-height: 50px;
  --stack-item-width: 120px;
}

/* Reset & Base */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
}

/* ============================================
   SCREEN MANAGEMENT
   ============================================ */
.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.screen.active {
  display: flex;
  opacity: 1;
  z-index: 10;
}

/* ============================================
   LOADING SCREEN
   ============================================ */
#loading-screen {
  background: var(--bg-gradient);
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

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

.loading-tower {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 4px;
  margin-bottom: 40px;
}

.tower-block {
  width: 80px;
  height: 20px;
  background: linear-gradient(
    90deg,
    var(--primary) 0%,
    var(--primary-glow) 100%
  );
  border-radius: 4px;
  animation: stackPulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
}

.tower-block:nth-child(1) {
  animation-delay: 0s;
  width: 60px;
}
.tower-block:nth-child(2) {
  animation-delay: 0.1s;
  width: 70px;
}
.tower-block:nth-child(3) {
  animation-delay: 0.2s;
  width: 80px;
}
.tower-block:nth-child(4) {
  animation-delay: 0.3s;
  width: 90px;
}
.tower-block:nth-child(5) {
  animation-delay: 0.4s;
  width: 100px;
}

@keyframes stackPulse {
  0%,
  100% {
    transform: scaleX(1);
    opacity: 0.7;
  }
  50% {
    transform: scaleX(1.1);
    opacity: 1;
  }
}

.loading-title {
  font-family: var(--font-display);
  font-size: 4rem;
  font-weight: 900;
  background: linear-gradient(
    135deg,
    var(--accent-gold) 0%,
    var(--accent-orange) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 40px rgba(251, 191, 36, 0.3);
  letter-spacing: 0.1em;
}

.loading-subtitle {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--text-secondary);
  letter-spacing: 0.3em;
  margin-top: 10px;
}

.loading-bar {
  width: 300px;
  height: 6px;
  background: var(--glass-bg);
  border-radius: 3px;
  margin: 40px auto 20px;
  overflow: hidden;
}

.loading-progress {
  width: 0%;
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--primary) 0%,
    var(--accent-cyan) 100%
  );
  border-radius: 3px;
  animation: loadProgress 2s ease-out forwards;
}

@keyframes loadProgress {
  0% {
    width: 0%;
  }
  100% {
    width: 100%;
  }
}

.loading-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* ============================================
   MAIN MENU
   ============================================ */
#main-menu {
  background: var(--bg-gradient);
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.menu-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.floating-elements {
  position: absolute;
  width: 100%;
  height: 100%;
}

.float-elem {
  position: absolute;
  font-family: var(--font-mono);
  color: rgba(99, 102, 241, 0.15);
  font-size: 2rem;
  animation: float 20s linear infinite;
}

.float-elem:nth-child(1) {
  left: 10%;
  top: 20%;
  animation-delay: 0s;
}
.float-elem:nth-child(2) {
  left: 80%;
  top: 30%;
  animation-delay: 3s;
}
.float-elem:nth-child(3) {
  left: 30%;
  top: 70%;
  animation-delay: 6s;
}
.float-elem:nth-child(4) {
  left: 70%;
  top: 80%;
  animation-delay: 9s;
}
.float-elem:nth-child(5) {
  left: 50%;
  top: 10%;
  animation-delay: 12s;
}
.float-elem:nth-child(6) {
  left: 20%;
  top: 50%;
  animation-delay: 15s;
}

@keyframes float {
  0% {
    transform: translateY(100vh) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-100vh) rotate(360deg);
    opacity: 0;
  }
}

.menu-content {
  position: relative;
  z-index: 2;
  text-align: center;
}

.game-logo {
  margin-bottom: 60px;
}

.logo-tower {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  margin-bottom: 30px;
}

.logo-block {
  width: 100px;
  height: 35px;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--accent-purple) 100%
  );
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: bold;
  color: white;
  box-shadow:
    0 4px 15px rgba(99, 102, 241, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.2);
  position: relative;
}

.logo-block::after {
  content: attr(data-label);
  font-size: 1.2rem;
}

.logo-block:nth-child(1) {
  width: 80px;
}
.logo-block:nth-child(2) {
  width: 100px;
}
.logo-block:nth-child(3) {
  width: 120px;
}

.game-logo h1 {
  font-family: var(--font-display);
  font-size: 4.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, #fbbf24 0%, #f97316 50%, #ef4444 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.05em;
  text-shadow: 0 0 60px rgba(251, 191, 36, 0.4);
}

.game-logo h2 {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.4em;
  margin-top: 10px;
}

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

.menu-btn {
  width: 320px;
  padding: 18px 30px;
  font-family: var(--font-ui);
  font-size: 1.2rem;
  font-weight: 600;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  background: var(--glass-bg);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.menu-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
}

.menu-btn.primary {
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--accent-purple) 100%
  );
  border: none;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.menu-btn.primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 40px rgba(99, 102, 241, 0.5);
}

.btn-icon {
  font-size: 1.5rem;
}

.menu-footer {
  margin-top: 50px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.version {
  margin-top: 10px;
  font-size: 0.8rem;
  opacity: 0.5;
}

/* ============================================
   REALM SELECTION
   ============================================ */
#realm-select {
  background: var(--bg-gradient);
  flex-direction: column;
  padding: 30px;
}

.realm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px 30px;
  border-bottom: 1px solid var(--border-color);
}

.realm-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--accent-gold);
}

.back-btn {
  padding: 10px 20px;
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.back-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--primary);
}

.player-stats {
  display: flex;
  gap: 30px;
}

.stat {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.realms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 25px;
  padding: 30px 20px;
  overflow-y: auto;
  max-height: calc(100vh - 120px);
}

.realm-card {
  background: var(--card-bg);
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 25px;
  cursor: pointer;
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
}

.realm-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--realm-color, var(--primary));
}

.realm-card:hover {
  transform: translateY(-8px);
  border-color: var(--realm-color, var(--primary));
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.4),
    0 0 30px var(--realm-glow, rgba(99, 102, 241, 0.3));
}

.realm-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.realm-card.locked:hover {
  transform: none;
}

.realm-icon {
  font-size: 3rem;
  margin-bottom: 15px;
}

.realm-number {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.2em;
}

.realm-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 8px 0;
  color: var(--text-primary);
}

.realm-description {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 15px;
}

.realm-concepts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 15px;
}

.concept-tag {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  background: rgba(99, 102, 241, 0.2);
  border-radius: 4px;
  color: var(--primary-glow);
}

.realm-progress {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

.realm-stars {
  color: var(--accent-gold);
  font-size: 1.2rem;
}

.realm-status {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.realm-status.completed {
  color: var(--secondary);
}

/* ============================================
   TUTORIAL SCREEN
   ============================================ */
#tutorial-screen {
  background: var(--bg-gradient);
  justify-content: center;
  overflow-y: auto;
}

.tutorial-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px;
}

.tutorial-container h1 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  color: var(--accent-gold);
  text-align: center;
  margin-bottom: 40px;
}

.tutorial-content {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.tutorial-section {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 30px;
}

.tutorial-section h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--primary-glow);
  margin-bottom: 20px;
}

.tutorial-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  margin: 20px 0;
}

.tutorial-stack {
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  padding: 20px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
}

.tutorial-stack .stack-item {
  width: 100px;
  height: 45px;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--accent-purple) 100%
  );
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: bold;
  font-size: 1.2rem;
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.tutorial-pointer {
  font-family: var(--font-mono);
  color: var(--accent-gold);
  font-size: 1rem;
}

.operations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
}

.operation-card {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: all 0.3s ease;
}

.operation-card:hover {
  border-color: var(--primary);
  transform: translateY(-5px);
}

.op-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 15px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: bold;
}

.push-icon {
  background: linear-gradient(135deg, var(--secondary) 0%, #059669 100%);
}
.pop-icon {
  background: linear-gradient(135deg, var(--accent-red) 0%, #dc2626 100%);
}
.peek-icon {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, #0891b2 100%);
}
.size-icon {
  background: linear-gradient(135deg, var(--accent-purple) 0%, #7c3aed 100%);
}

.operation-card h3 {
  font-family: var(--font-mono);
  color: var(--text-primary);
  margin-bottom: 8px;
}

.operation-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.operation-card code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-gold);
  background: rgba(251, 191, 36, 0.1);
  padding: 4px 8px;
  border-radius: 4px;
}

.complexity-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
}

.complexity-table th,
.complexity-table td {
  padding: 12px 20px;
  text-align: center;
  border: 1px solid var(--border-color);
}

.complexity-table th {
  background: rgba(99, 102, 241, 0.2);
  font-family: var(--font-mono);
  color: var(--primary-glow);
}

.complexity-table td {
  font-family: var(--font-mono);
  color: var(--secondary);
}

/* ============================================
   DEBUGGER SCREEN
   ============================================ */
#debugger-screen {
  background: var(--bg-gradient);
  overflow-y: auto;
}

.debugger-container {
  width: 100%;
  height: 100%;
  padding: 30px;
  display: flex;
  flex-direction: column;
}

.debugger-container h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--accent-gold);
  margin-bottom: 30px;
  text-align: center;
}

.debugger-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 30px;
  flex: 1;
  min-height: 0;
}

.debugger-controls {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 25px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.debugger-controls h3 {
  font-family: var(--font-mono);
  color: var(--primary-glow);
  font-size: 1rem;
  margin-bottom: 10px;
}

.debug-input-group {
  display: flex;
  gap: 10px;
}

.debug-input-group input,
#debug-expression {
  flex: 1;
  padding: 12px 15px;
  font-family: var(--font-mono);
  font-size: 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  outline: none;
}

.debug-input-group input:focus,
#debug-expression:focus {
  border-color: var(--primary);
}

.debugger-controls button {
  padding: 10px 15px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--primary);
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.debugger-controls button:hover {
  background: var(--primary-glow);
  transform: translateY(-2px);
}

.debug-buttons {
  display: flex;
  gap: 10px;
}

.debug-buttons button {
  flex: 1;
}

.debug-info {
  background: rgba(0, 0, 0, 0.3);
  padding: 15px;
  border-radius: 8px;
}

.debug-info p {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.debug-info span {
  color: var(--secondary);
}

.debug-tests {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.debug-tests button {
  background: rgba(99, 102, 241, 0.3);
  font-size: 0.85rem;
}

.debugger-visual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.debug-stack-container,
.debug-output {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 25px;
  display: flex;
  flex-direction: column;
}

.debug-stack-container h3,
.debug-output h3 {
  font-family: var(--font-mono);
  color: var(--primary-glow);
  margin-bottom: 20px;
}

.debug-stack {
  flex: 1;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  padding: 20px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  min-height: 300px;
  overflow-y: auto;
}

.stack-base {
  padding: 10px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 3px solid var(--border-color);
  margin-top: auto;
}

.debug-stack .stack-item {
  padding: 15px 20px;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--accent-purple) 100%
  );
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: bold;
  color: white;
  text-align: center;
  animation: stackSlideIn 0.3s ease-out;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

@keyframes stackSlideIn {
  from {
    transform: translateY(-30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.debug-log {
  flex: 1;
  padding: 15px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-secondary);
  overflow-y: auto;
  max-height: 400px;
}

.debug-log .log-entry {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.debug-log .log-push {
  color: var(--secondary);
}
.debug-log .log-pop {
  color: var(--accent-red);
}
.debug-log .log-peek {
  color: var(--accent-cyan);
}
.debug-log .log-info {
  color: var(--accent-gold);
}
.debug-log .log-error {
  color: var(--accent-red);
}

/* ============================================
   GAME SCREEN
   ============================================ */
#game-screen {
  background: var(--bg-darker);
  flex-direction: column;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 25px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
}

.realm-info {
  text-align: center;
}

.realm-info h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--accent-gold);
}

.realm-info p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.game-stats {
  display: flex;
  gap: 25px;
}

.game-stats .stat {
  font-family: var(--font-mono);
}

.game-main {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 20px;
  padding: 20px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.game-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
  overflow-y: auto;
}

.panel-section {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 15px;
}

.panel-section h3 {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--primary-glow);
  margin-bottom: 10px;
}

.panel-section p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.panel-section pre {
  background: rgba(0, 0, 0, 0.4);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
}

.panel-section code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--secondary);
  line-height: 1.6;
}

.game-center {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
}

.game-arena {
  flex: 1;
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.game-controls {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
}

.game-controls button {
  padding: 12px 25px;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--accent-purple) 100%
  );
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.game-controls button:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

.game-controls button.secondary {
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
}

.game-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Stack Visuals in Game Panels */
.stack-visual {
  min-height: 200px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
}

.stack-visual .stack-item {
  padding: 10px;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--accent-purple) 100%
  );
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: bold;
  color: white;
  text-align: center;
  animation: stackSlideIn 0.3s ease-out;
}

.stack-visual .stack-item.highlight {
  box-shadow: 0 0 20px var(--accent-gold);
  border: 2px solid var(--accent-gold);
}

.stack-visual .stack-item.removing {
  animation: stackSlideOut 0.3s ease-out forwards;
}

@keyframes stackSlideOut {
  to {
    transform: translateY(-30px);
    opacity: 0;
  }
}

.stack-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.output-display {
  padding: 15px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--secondary);
  text-align: center;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   GAME ARENA ELEMENTS
   ============================================ */
/* Plate Tower (Realm 1) */
.plate-tower {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  padding: 30px;
}

.plate {
  height: 40px;
  background: linear-gradient(135deg, var(--stack-1) 0%, var(--stack-2) 100%);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: bold;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.plate:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.plate.new {
  animation: plateSlideIn 0.4s ease-out;
}

@keyframes plateSlideIn {
  from {
    transform: translateY(-100px) rotate(-10deg);
    opacity: 0;
  }
  to {
    transform: translateY(0) rotate(0);
    opacity: 1;
  }
}

.plate.removing {
  animation: plateSlideOut 0.4s ease-out forwards;
}

@keyframes plateSlideOut {
  to {
    transform: translateY(-100px) rotate(10deg);
    opacity: 0;
  }
}

.tower-base {
  width: 200px;
  height: 20px;
  background: linear-gradient(90deg, #4a5568, #2d3748);
  border-radius: 10px;
  margin-top: 10px;
}

/* Linked List Nodes (Realm 2) */
.linked-list-container {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 5px;
  padding: 30px;
}

.ll-node {
  display: flex;
  align-items: center;
  animation: nodeSlideIn 0.4s ease-out;
}

@keyframes nodeSlideIn {
  from {
    transform: translateX(-50px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.node-data {
  width: 80px;
  height: 50px;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--accent-purple) 100%
  );
  border-radius: 8px 0 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: bold;
  color: white;
}

.node-next {
  width: 40px;
  height: 50px;
  background: var(--accent-cyan);
  border-radius: 0 8px 8px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
}

.node-pointer {
  width: 30px;
  height: 3px;
  background: var(--accent-gold);
  position: relative;
}

.node-pointer::after {
  content: '▼';
  position: absolute;
  right: -8px;
  top: -10px;
  color: var(--accent-gold);
  font-size: 0.8rem;
  transform: rotate(180deg);
}

.head-label {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent-gold);
  margin-right: 15px;
}

.null-node {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* Monster Characters (Realm 3) */
.monster-row {
  display: flex;
  gap: 15px;
  padding: 30px;
  flex-wrap: wrap;
  justify-content: center;
}

.monster {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.monster:hover {
  transform: scale(1.15);
}

.monster.matched {
  animation: monsterMatch 0.5s ease-out forwards;
}

@keyframes monsterMatch {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

.monster-label {
  position: absolute;
  bottom: -20px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Expression Elements (Realm 4, 5, 6) */
.expression-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
  padding: 30px;
  width: 100%;
}

.expression-input {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.expr-token {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.expr-token.operand {
  background: linear-gradient(135deg, var(--secondary) 0%, #059669 100%);
  color: white;
}

.expr-token.operator {
  background: linear-gradient(
    135deg,
    var(--accent-orange) 0%,
    var(--accent-red) 100%
  );
  color: white;
}

.expr-token.parenthesis {
  background: linear-gradient(135deg, var(--accent-purple) 0%, #7c3aed 100%);
  color: white;
}

.expr-token:hover {
  transform: scale(1.1);
}

.expr-token.selected {
  box-shadow: 0 0 20px var(--accent-gold);
  border: 3px solid var(--accent-gold);
}

.expr-token.processed {
  opacity: 0.3;
}

.dual-stack-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  width: 100%;
  max-width: 500px;
}

.stack-column {
  text-align: center;
}

.stack-column h4 {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-bottom: 15px;
}

.expr-output {
  padding: 20px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  text-align: center;
  width: 100%;
  max-width: 400px;
}

.expr-output h4 {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.expr-result {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  color: var(--accent-gold);
  letter-spacing: 0.2em;
}

/* Expression Tree (Realm 5) */
.expr-tree-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.tree-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.tree-value {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: bold;
  font-size: 1.2rem;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--accent-purple) 100%
  );
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.tree-value.operator {
  background: linear-gradient(
    135deg,
    var(--accent-orange) 0%,
    var(--accent-red) 100%
  );
}

.tree-children {
  display: flex;
  gap: 40px;
  margin-top: 30px;
  position: relative;
}

.tree-children::before {
  content: '';
  position: absolute;
  top: -15px;
  left: 50%;
  width: 2px;
  height: 15px;
  background: var(--border-color);
}

.tree-branch {
  position: absolute;
  top: -15px;
  width: 2px;
  height: 30px;
  background: var(--border-color);
}

/* Histogram Bars (Realm 7, 8, 9, 10) */
.histogram-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  padding: 30px;
  height: 100%;
}

.histogram-bar {
  width: 60px;
  background: linear-gradient(
    180deg,
    var(--primary) 0%,
    var(--accent-purple) 100%
  );
  border-radius: 8px 8px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.histogram-bar:hover {
  background: linear-gradient(
    180deg,
    var(--primary-glow) 0%,
    var(--accent-purple) 100%
  );
  transform: scaleY(1.02);
}

.histogram-bar.active {
  background: linear-gradient(
    180deg,
    var(--accent-gold) 0%,
    var(--accent-orange) 100%
  );
}

.histogram-bar.highlight {
  box-shadow: 0 0 30px var(--accent-gold);
}

.bar-height {
  font-family: var(--font-mono);
  font-weight: bold;
  color: white;
  font-size: 1.1rem;
}

.bar-index {
  position: absolute;
  bottom: -25px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.nsl-nsr-display {
  position: absolute;
  top: -30px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent-cyan);
}

.rectangle-overlay {
  position: absolute;
  background: rgba(251, 191, 36, 0.3);
  border: 3px dashed var(--accent-gold);
  pointer-events: none;
  transition: all 0.3s ease;
}

/* ============================================
   MODALS
   ============================================ */
.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: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 20px;
  padding: 40px;
  max-width: 500px;
  text-align: center;
  animation: modalSlideIn 0.4s ease-out;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.realm-intro-content {
  max-width: 550px;
}

.realm-intro-header {
  margin-bottom: 30px;
}

.realm-intro-header .realm-number {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 0.3em;
}

.realm-intro-header h1 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  color: var(--accent-gold);
  margin: 10px 0;
}

.realm-tagline {
  color: var(--text-secondary);
}

.realm-intro-body .realm-icon {
  font-size: 5rem;
  margin: 20px 0;
}

.realm-intro-body p {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 20px;
}

.realm-intro-body .realm-concepts {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 30px;
}

.level-complete-content .result-stars {
  font-size: 3rem;
  margin: 20px 0;
}

.level-complete-content .result-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin: 20px 0;
}

.level-complete-content .result-stats p {
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.level-complete-content .result-stats span {
  color: var(--secondary);
}

.level-complete-buttons,
.realm-complete-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 30px;
}

.realm-complete-content .realm-complete-badge {
  font-size: 5rem;
  margin-bottom: 20px;
}

.realm-complete-content h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--accent-gold);
}

.realm-complete-content h2 {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-top: 10px;
}

.realm-summary {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin: 25px 0;
}

.realm-summary p {
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.realm-summary span {
  color: var(--secondary);
}

.concept-mastered h3 {
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 10px;
}

.mastered-tags {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.mastered-tags span {
  padding: 6px 14px;
  background: rgba(34, 197, 94, 0.2);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--secondary);
}

/* Game Message Overlay */
.game-message {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.game-message.hidden {
  display: none;
}

.message-content {
  background: var(--card-bg);
  border: 2px solid var(--accent-gold);
  border-radius: 20px;
  padding: 40px;
  text-align: center;
  animation: messagePopIn 0.4s ease-out;
}

@keyframes messagePopIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.message-content h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--accent-gold);
  margin-bottom: 15px;
}

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

.message-content .stars {
  font-size: 2.5rem;
  margin-bottom: 25px;
}

.message-content button {
  padding: 12px 30px;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--accent-purple) 100%
  );
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.message-content button:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 1200px) {
  .game-main {
    grid-template-columns: 220px 1fr 220px;
  }
}

@media (max-width: 992px) {
  .game-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .game-panel {
    flex-direction: row;
    overflow-x: auto;
  }

  .panel-section {
    min-width: 200px;
  }

  .debugger-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .loading-title {
    font-size: 2.5rem;
  }

  .game-logo h1 {
    font-size: 2.5rem;
  }

  .menu-btn {
    width: 100%;
    max-width: 300px;
  }

  .realms-grid {
    grid-template-columns: 1fr;
  }

  .operations-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.hidden {
  display: none !important;
}

.highlight {
  animation: highlightPulse 0.5s ease-in-out;
}

@keyframes highlightPulse {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(251, 191, 36, 0);
  }
  50% {
    box-shadow: 0 0 30px rgba(251, 191, 36, 0.8);
  }
}

.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

.success-flash {
  animation: successFlash 0.5s ease-out;
}

@keyframes successFlash {
  0% {
    background-color: rgba(34, 197, 94, 0.5);
  }
  100% {
    background-color: transparent;
  }
}

.error-flash {
  animation: errorFlash 0.5s ease-out;
}

@keyframes errorFlash {
  0% {
    background-color: rgba(239, 68, 68, 0.5);
  }
  100% {
    background-color: transparent;
  }
}

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

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

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

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