/**
 * GoateDB Styles
 * Terminal/database aesthetic with dark theme
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --border-color: #30363d;
  --border-highlight: #58a6ff;
  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent-green: #3fb950;
  --accent-blue: #58a6ff;
  --accent-yellow: #d29922;
  --accent-red: #f85149;
  --accent-pink: #db61a2;
  --font-mono: "JetBrains Mono", "Fira Code", "Consolas", monospace;
}

/* ============================================
   Base Styles
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-mono);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

/* ============================================
   Layer System (goats eat the screen)
   ============================================ */

/* Layer 0: Pure black void */
#void-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  background: #000;
}

/* Layer 2: Goats (always visible, never eaten) */
#goat-layer,
#goat-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 3;
  pointer-events: none;
}

/* ============================================
   Main Container (Layer 1)
   ============================================ */
.container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* ============================================
   Header
   ============================================ */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent-green);
}

.logo .version {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:hover {
  background: var(--bg-secondary);
  border-color: var(--border-highlight);
}

.btn-primary {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: var(--bg-primary);
}

.btn-primary:hover {
  background: #2ea043;
  border-color: #2ea043;
}

.btn-icon {
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
}

/* ============================================
   Main Play Area
   ============================================ */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  min-height: 0;
}

/* Status Bar (terminal style) */
.status-bar {
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.status-prompt {
  color: var(--accent-green);
  margin-right: 0.5rem;
}

.status-cmd {
  color: var(--text-primary);
}

.status-flag {
  color: var(--accent-blue);
  margin-left: 0.5rem;
}

.status-cursor {
  color: var(--accent-green);
  margin-left: 0.25rem;
  animation: cursor-blink 1s step-end infinite;
}

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

/* Legacy support */
.query-bar {
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.query-bar span {
  color: var(--accent-blue);
}

/* Individual Database Box - positioned inside play area */
.database {
  position: absolute;
  background: var(--bg-secondary);
  border: 4px solid #8b4513;
  z-index: 5;
  overflow: visible;
  transition:
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}

/* Entrance directions - remove border on entrance side */
.database.entrance-top {
  border-top: none;
  border-radius: 0 0 6px 6px;
}
.database.entrance-bottom {
  border-bottom: none;
  border-radius: 6px 6px 0 0;
}
.database.entrance-left {
  border-left: none;
  border-radius: 0 6px 6px 0;
}
.database.entrance-right {
  border-right: none;
  border-radius: 6px 0 0 6px;
}

.database.has-goats {
  border-color: #6b8e23;
  box-shadow: 0 0 15px rgba(63, 185, 80, 0.3);
}

.db-header {
  padding: 0.25rem 0.5rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  border-radius: 4px 4px 0 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-blue);
  position: relative;
  z-index: 6;
}

.db-container {
  position: relative;
  height: calc(100% - 25px);
}

.db-count {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 0.625rem;
  color: var(--text-muted);
  z-index: 6;
}

/* Lifetime bar */
.db-lifetime-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  overflow: hidden;
}

.db-lifetime-fill {
  height: 100%;
  width: 100%;
  background: var(--accent-green);
  transition:
    width 0.1s linear,
    background 0.3s ease;
}

/* Expiring state (< 25% lifetime) */
.database.expiring {
  animation: expiring-pulse 0.5s ease-in-out infinite;
}

.database.expiring .db-header {
  color: var(--accent-red);
}

@keyframes expiring-pulse {
  0%,
  100% {
    box-shadow:
      0 0 10px rgba(248, 81, 73, 0.3),
      inset 0 0 10px rgba(248, 81, 73, 0.1);
  }
  50% {
    box-shadow:
      0 0 20px rgba(248, 81, 73, 0.5),
      inset 0 0 15px rgba(248, 81, 73, 0.2);
  }
}

/* Expired state */
.database.expired {
  opacity: 0.5;
  pointer-events: none;
  animation: expire-fade 1s ease-out forwards;
}

@keyframes expire-fade {
  0% {
    opacity: 0.5;
    transform: scale(1);
  }
  50% {
    opacity: 0.3;
    transform: scale(0.98);
  }
  100% {
    opacity: 0;
    transform: scale(0.95);
  }
}

/* Pen spawn animation */
@keyframes pen-spawn {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Play Area (where goats roam) */
#play-area {
  flex: 1;
  position: relative;
  cursor: crosshair;
  background:
    linear-gradient(90deg, var(--bg-tertiary) 1px, transparent 1px),
    linear-gradient(var(--bg-tertiary) 1px, transparent 1px);
  background-size: 20px 20px;
  min-height: 300px;
}

/* ============================================
   Goats
   ============================================ */
.goat {
  position: absolute;
  font-size: 2rem;
  line-height: 1;
  user-select: none;
  pointer-events: none;
  transition: transform 0.05s linear;
  z-index: 10;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.goat.contained {
  z-index: 15;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* ============================================
   Attractors (grass, food, etc)
   ============================================ */
.attractor {
  position: absolute;
  font-size: 1.5rem;
  line-height: 1;
  user-select: none;
  pointer-events: none;
  z-index: 1;
  opacity: 0.8;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

.attractor.eaten {
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
}

/* Click ripple effect */
.click-ripple {
  position: fixed;
  width: 20px;
  height: 20px;
  border: 3px solid var(--accent-red);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: none;
  z-index: 9999;
  animation: ripple-expand 0.6s ease-out forwards;
}

@keyframes ripple-expand {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(15);
    opacity: 0;
  }
}

/* Boosted goat effect */
.goat.boosted {
  filter: drop-shadow(0 0 12px var(--accent-red))
    drop-shadow(0 0 20px var(--accent-red));
}

/* Database entrance zone - visual green area */
.database::before {
  content: "";
  position: absolute;
  background: linear-gradient(
    to bottom,
    rgba(63, 185, 80, 0.3),
    rgba(63, 185, 80, 0.1)
  );
  border: 2px dashed var(--accent-green);
  border-radius: 4px;
  pointer-events: none;
  z-index: -1;
}

/* Entrance zone positions */
.database.entrance-top::before {
  top: -35px;
  left: 20%;
  width: 60%;
  height: 35px;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(
    to bottom,
    rgba(63, 185, 80, 0.25),
    rgba(63, 185, 80, 0.05)
  );
}
.database.entrance-bottom::before {
  bottom: -35px;
  left: 20%;
  width: 60%;
  height: 35px;
  border-top: none;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(
    to top,
    rgba(63, 185, 80, 0.25),
    rgba(63, 185, 80, 0.05)
  );
}
.database.entrance-left::before {
  left: -40px;
  top: 20%;
  width: 40px;
  height: 60%;
  border-right: none;
  border-radius: 4px 0 0 4px;
  background: linear-gradient(
    to right,
    rgba(63, 185, 80, 0.25),
    rgba(63, 185, 80, 0.05)
  );
}
.database.entrance-right::before {
  right: -40px;
  top: 20%;
  width: 40px;
  height: 60%;
  border-left: none;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(
    to left,
    rgba(63, 185, 80, 0.25),
    rgba(63, 185, 80, 0.05)
  );
}

/* Database entrance text labels */
.database::after {
  position: absolute;
  font-size: 0.55rem;
  color: var(--accent-green);
  white-space: nowrap;
  opacity: 0.9;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  font-family: var(--font-mono);
  pointer-events: none;
}

/* Label positions */
.database.entrance-top::after {
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
}
.database.entrance-bottom::after {
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
}
.database.entrance-left::after {
  left: -38px;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
}
.database.entrance-right::after {
  right: -38px;
  top: 50%;
  transform: translateY(-50%) rotate(90deg);
}

/* Block Storage - basic, unreliable */
.database.block {
  border-color: #8b5a2b;
  background: linear-gradient(
    135deg,
    var(--bg-secondary) 0%,
    rgba(139, 90, 43, 0.1) 100%
  );
}

.database.block .db-header {
  color: #cd853f;
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 0%,
    rgba(139, 90, 43, 0.2) 100%
  );
}

.database.block::after {
  content: "WRITE";
}

.database.block.processing {
  border-color: var(--accent-yellow) !important;
  animation: block-process 0.5s ease-in-out infinite;
}

.database.block.processing .db-header::after {
  content: " (WRITING...)";
  color: var(--accent-yellow);
}

@keyframes block-process {
  0%,
  100% {
    box-shadow: 0 0 5px var(--accent-yellow);
  }
  50% {
    box-shadow: 0 0 15px var(--accent-yellow);
  }
}

.database.block.corrupted {
  border-color: var(--accent-red) !important;
  animation: corruption-flash 0.2s ease-out;
}

@keyframes corruption-flash {
  0% {
    box-shadow: 0 0 30px var(--accent-red);
    filter: brightness(1.5);
  }
  100% {
    box-shadow: none;
    filter: brightness(1);
  }
}

.database.block.upgradeable {
  border-color: var(--accent-green) !important;
  box-shadow: 0 0 20px var(--accent-green);
  animation: upgrade-pulse 1s ease-in-out infinite;
}

@keyframes upgrade-pulse {
  0%,
  100% {
    box-shadow: 0 0 10px var(--accent-green);
  }
  50% {
    box-shadow:
      0 0 25px var(--accent-green),
      0 0 40px var(--accent-green);
  }
}

/* PostgreSQL */
.database.postgres::after {
  content: "INSERT";
}

.database.postgres.processing {
  border-color: var(--accent-blue) !important;
  animation: postgres-insert 0.5s ease-in-out infinite;
}

.database.postgres.processing .db-header::after {
  content: " (INSERTING...)";
  color: var(--accent-blue);
}

@keyframes postgres-insert {
  0%,
  100% {
    box-shadow: 0 0 5px var(--accent-blue);
  }
  50% {
    box-shadow: 0 0 15px var(--accent-blue);
  }
}

/* Redis */
.database.redis::after {
  content: "SET";
}

/* MongoDB */
.database.mongodb::after {
  content: "insert()";
}

/* SQLite */
.database.sqlite::after {
  content: "INSERT";
}

.database.sqlite.processing {
  border-color: var(--accent-yellow) !important;
  animation: sqlite-lock 0.3s ease-in-out infinite;
}

.database.sqlite.processing .db-header::after {
  content: " (LOCKING...)";
  color: var(--accent-yellow);
}

@keyframes sqlite-lock {
  0%,
  100% {
    box-shadow: 0 0 5px var(--accent-yellow);
  }
  50% {
    box-shadow: 0 0 12px var(--accent-yellow);
  }
}

/* Avalanche */
.database.avalanche::after {
  content: "stake()";
}

.database.avalanche {
  border-color: #e84142;
}

.database.avalanche .db-header {
  color: #e84142;
}

.database.avalanche.stressed {
  border-color: var(--accent-yellow) !important;
  animation: stress-pulse 0.3s ease-in-out infinite;
}

.database.avalanche.stressed .db-header::after {
  content: " (STRESSED)";
  color: var(--accent-yellow);
}

.database.avalanche.has-subnet {
  box-shadow:
    0 0 15px #e84142,
    0 0 30px rgba(232, 65, 66, 0.3);
}

.database.avalanche.has-subnet .db-header::after {
  content: " +SUBNET";
  color: #e84142;
}

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

/* ============================================
   New Storage Types
   ============================================ */

/* Kafka - Message Queue */
.database.kafka {
  border-color: #231f20;
  background: linear-gradient(
    135deg,
    var(--bg-secondary) 0%,
    rgba(35, 31, 32, 0.2) 100%
  );
}

.database.kafka .db-header {
  color: #ffffff;
  background: #231f20;
}

.database.kafka::after {
  content: "PRODUCE";
}

.database.kafka.processing {
  border-color: #555 !important;
  animation: kafka-produce 0.3s ease-in-out infinite;
}

.database.kafka.processing .db-header::after {
  content: " (PRODUCING...)";
  color: #aaa;
}

@keyframes kafka-produce {
  0%,
  100% {
    box-shadow: 0 0 5px #555;
  }
  50% {
    box-shadow: 0 0 12px #777;
  }
}

.database.kafka.lagging {
  border-color: var(--accent-yellow) !important;
}

.database.kafka.lagging .db-header::after {
  content: " (LAG)";
  color: var(--accent-yellow);
}

.database.kafka.severely-lagging {
  border-color: var(--accent-red) !important;
  animation: lag-pulse 0.5s ease-in-out infinite;
}

.database.kafka.severely-lagging .db-header::after {
  content: " (HIGH LAG)";
  color: var(--accent-red);
}

.database.kafka.rebalancing {
  border-color: var(--accent-blue) !important;
  animation: rebalance-spin 1s linear infinite;
}

.database.kafka.rebalancing .db-header::after {
  content: " (REBALANCING)";
  color: var(--accent-blue);
}

@keyframes lag-pulse {
  0%,
  100% {
    box-shadow: 0 0 5px var(--accent-red);
  }
  50% {
    box-shadow: 0 0 15px var(--accent-red);
  }
}

@keyframes rebalance-spin {
  0% {
    box-shadow: 0 0 10px var(--accent-blue);
  }
  50% {
    box-shadow: 0 0 20px var(--accent-blue);
  }
  100% {
    box-shadow: 0 0 10px var(--accent-blue);
  }
}

/* Git - Version Control */
.database.git {
  border-color: #f05032;
  background: linear-gradient(
    135deg,
    var(--bg-secondary) 0%,
    rgba(240, 80, 50, 0.1) 100%
  );
}

.database.git .db-header {
  color: #f05032;
}

.database.git::after {
  content: "commit";
}

.database.git.processing {
  border-color: #f05032 !important;
  animation: git-commit 0.4s ease-in-out infinite;
}

.database.git.processing .db-header::after {
  content: " (COMMITTING...)";
  color: #f05032;
}

@keyframes git-commit {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(240, 80, 50, 0.5);
  }
  50% {
    box-shadow: 0 0 15px rgba(240, 80, 50, 0.8);
  }
}

.database.git.has-branches {
  box-shadow: 0 0 10px rgba(240, 80, 50, 0.3);
}

.database.git.has-branches .db-header::after {
  content: " +branches";
  color: var(--accent-green);
}

.database.git.detached-head {
  border-color: var(--accent-yellow) !important;
  animation: detached-pulse 0.8s ease-in-out infinite;
}

.database.git.detached-head .db-header::after {
  content: " (DETACHED)";
  color: var(--accent-yellow);
}

@keyframes detached-pulse {
  0%,
  100% {
    box-shadow: 0 0 5px var(--accent-yellow);
  }
  50% {
    box-shadow:
      0 0 15px var(--accent-yellow),
      0 0 25px var(--accent-yellow);
  }
}

/* Excel - Spreadsheet */
.database.excel {
  border-color: #217346;
  background: linear-gradient(
    135deg,
    var(--bg-secondary) 0%,
    rgba(33, 115, 70, 0.1) 100%
  );
}

.database.excel .db-header {
  color: #217346;
}

.database.excel::after {
  content: "=GOAT()";
}

.database.excel.processing {
  border-color: #217346 !important;
  animation: excel-save 0.5s ease-in-out infinite;
}

.database.excel.processing .db-header::after {
  content: " (SAVING...)";
  color: #217346;
}

@keyframes excel-save {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(33, 115, 70, 0.5);
  }
  50% {
    box-shadow: 0 0 12px rgba(33, 115, 70, 0.8);
  }
}

.database.excel.slow {
  border-color: var(--accent-yellow) !important;
}

.database.excel.slow .db-header::after {
  content: " (SLOW)";
  color: var(--accent-yellow);
}

.database.excel.crawling {
  border-color: #ff6600 !important;
  animation: excel-crawl 2s ease-in-out infinite;
}

.database.excel.crawling .db-header::after {
  content: " (NOT RESPONDING)";
  color: #ff6600;
}

.database.excel.frozen {
  border-color: var(--accent-red) !important;
  filter: grayscale(50%);
}

.database.excel.frozen .db-header::after {
  content: " (FROZEN)";
  color: var(--accent-red);
}

.database.excel.locked {
  border-color: var(--accent-blue) !important;
}

.database.excel.locked .db-header::after {
  content: " (READ-ONLY)";
  color: var(--accent-blue);
}

.database.excel.formula-error {
  animation: excel-error 0.3s ease-out;
}

.database.excel.save-failed {
  animation: save-fail 0.5s ease-out;
}

@keyframes excel-crawl {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes excel-error {
  0% {
    box-shadow: 0 0 20px var(--accent-red);
  }
  100% {
    box-shadow: none;
  }
}

@keyframes save-fail {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* Tape Archive - Legacy Storage */
.database.tape {
  border-color: #8b4513;
  background: linear-gradient(
    135deg,
    var(--bg-secondary) 0%,
    rgba(139, 69, 19, 0.15) 100%
  );
}

.database.tape .db-header {
  color: #d2691e;
}

.database.tape::after {
  content: "WRITE";
}

.database.tape.processing {
  border-color: #d2691e !important;
  animation: tape-write 0.4s ease-in-out infinite;
}

.database.tape.processing .db-header::after {
  content: " (WRITING...)";
  color: #d2691e;
}

@keyframes tape-write {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(210, 105, 30, 0.5);
  }
  50% {
    box-shadow: 0 0 12px rgba(210, 105, 30, 0.8);
  }
}

.database.tape.seeking {
  border-color: var(--accent-yellow) !important;
  animation: tape-seek 0.3s linear infinite;
}

.database.tape.seeking .db-header::after {
  content: " (SEEKING...)";
  color: var(--accent-yellow);
}

.database.tape.changing-tape {
  border-color: var(--accent-blue) !important;
  animation: tape-change 1s ease-in-out infinite;
}

.database.tape.changing-tape .db-header::after {
  content: " (CHANGING TAPE)";
  color: var(--accent-blue);
}

.database.tape.read-error {
  animation: tape-error 0.3s ease-out;
}

@keyframes tape-seek {
  0%,
  100% {
    box-shadow: -3px 0 5px var(--accent-yellow);
  }
  50% {
    box-shadow: 3px 0 5px var(--accent-yellow);
  }
}

@keyframes tape-change {
  0% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(1deg);
  }
  75% {
    transform: rotate(-1deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

@keyframes tape-error {
  0% {
    background: rgba(248, 81, 73, 0.3);
  }
  100% {
    background: transparent;
  }
}

/* HDFS - Distributed File System */
.database.hdfs {
  border-color: #66ccff;
  background: linear-gradient(
    135deg,
    var(--bg-secondary) 0%,
    rgba(102, 204, 255, 0.1) 100%
  );
}

.database.hdfs .db-header {
  color: #66ccff;
}

.database.hdfs::after {
  content: "WRITE";
}

.database.hdfs.processing {
  border-color: #66ccff !important;
  animation: hdfs-replicate 0.5s ease-in-out infinite;
}

.database.hdfs.processing .db-header::after {
  content: " (REPLICATING...)";
  color: #66ccff;
}

@keyframes hdfs-replicate {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(102, 204, 255, 0.5);
  }
  50% {
    box-shadow: 0 0 15px rgba(102, 204, 255, 0.8);
  }
}

.database.hdfs.safe-mode {
  border-color: var(--accent-yellow) !important;
  animation: safe-mode-pulse 1s ease-in-out infinite;
}

.database.hdfs.safe-mode .db-header::after {
  content: " (SAFE MODE)";
  color: var(--accent-yellow);
}

.database.hdfs.node-failure {
  animation: node-fail-flash 0.5s ease-out;
}

@keyframes safe-mode-pulse {
  0%,
  100% {
    box-shadow: 0 0 5px var(--accent-yellow);
  }
  50% {
    box-shadow: 0 0 15px var(--accent-yellow);
  }
}

@keyframes node-fail-flash {
  0% {
    box-shadow: 0 0 20px var(--accent-red);
    filter: brightness(1.3);
  }
  100% {
    box-shadow: none;
    filter: brightness(1);
  }
}

/* Hover effect on entrance zone */
.database:hover::before {
  background: rgba(63, 185, 80, 0.25);
  border-color: #7fff00;
  box-shadow: 0 0 10px rgba(63, 185, 80, 0.4);
}
.database:hover::after {
  color: #7fff00;
  text-shadow: 0 0 8px rgba(63, 185, 80, 0.8);
}

/* Indicator (!, ?, ♥, ...) */
.indicator {
  position: absolute;
  top: -1.5rem;
  left: 50%;
  transform: translateX(-50%) scale(0);
  font-size: 1rem;
  font-weight: bold;
  opacity: 0;
  transition:
    transform 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55),
    opacity 0.2s ease;
}

.indicator.show {
  transform: translateX(-50%) scale(1);
  opacity: 1;
}

.indicator.startled {
  color: var(--accent-red);
  text-shadow: 0 0 8px var(--accent-red);
}

.indicator.curious {
  color: var(--accent-yellow);
  text-shadow: 0 0 8px var(--accent-yellow);
}

.indicator.happy {
  color: var(--accent-pink);
  text-shadow: 0 0 8px var(--accent-pink);
}

.indicator.escaping {
  color: var(--text-muted);
  animation: pulse 0.5s ease infinite;
}

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

/* ============================================
   Footer / Status Bar
   ============================================ */
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-top: 1rem;
  font-size: 0.875rem;
}

.stats {
  display: flex;
  gap: 1.5rem;
}

.stat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-label {
  color: var(--text-muted);
}

.stat-value {
  font-weight: 600;
  color: var(--accent-green);
}

.stat-value.loose {
  color: var(--accent-yellow);
}

.stat-value.total {
  color: var(--text-primary);
}

/* System Log */
#system-log {
  flex: 1;
  max-height: 4rem;
  overflow-y: auto;
  margin: 0 1rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.log-line {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-line:last-child {
  color: var(--accent-green);
}

/* Legacy support */
#sql-log {
  display: none;
}
.sql-line {
  display: none;
}

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

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

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

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

/* ============================================
   Buy Me a Coffee button
   ============================================ */
.bmc-button {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 50;
  opacity: 0.8;
  transition: opacity 0.2s;
  background: #ffdd00;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.bmc-button:hover {
  opacity: 1;
}

.bmc-button img {
  height: 1.5rem;
  width: auto;
}

.bmc-button::after {
  content: "Buy me a coffee";
  color: #000;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ============================================
   Responsive - Mobile: game only, no UI chrome
   ============================================ */
@media (max-width: 1024px) {
  header,
  .sidebar,
  .status-bar,
  #system-log,
  .bmc-button {
    display: none !important;
  }

  .container {
    padding: 0;
  }

  .main-layout {
    display: block;
  }

  #play-area {
    width: 100vw;
    height: calc(100vh - 2.5rem);
    margin: 0;
    padding: 0;
  }

  #goat-canvas {
    width: 100vw;
    height: calc(100vh - 2.5rem);
  }

  footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
  }

  footer .stats {
    flex: 1;
    display: flex;
    justify-content: space-around;
    gap: 0.5rem;
  }

  footer .stat {
    font-size: 0.75rem;
  }

  footer .best-score {
    margin: 0;
  }
}

/* ============================================
   Header Controls
   ============================================ */
.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.volume-slider {
  width: 80px;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-tertiary);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent-blue);
  border-radius: 50%;
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent-blue);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* ============================================
   Action Buttons
   ============================================ */
.action-buttons {
  display: inline-flex;
  gap: 0.5rem;
  margin-left: 1rem;
}

.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-success {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: var(--bg-primary);
}

.btn-success:hover {
  background: #2ea043;
  border-color: #2ea043;
}

/* ============================================
   DB Protection Constraint
   ============================================ */
.db-protection {
  margin: 0.5rem 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px dashed var(--accent-blue);
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.constraint-keyword {
  color: var(--accent-pink);
  font-weight: 600;
}

.constraint-params {
  color: var(--accent-yellow);
}

.constraint-status {
  color: var(--accent-green);
  margin-left: 0.5rem;
}

/* ============================================
   Database States
   ============================================ */
.database.rampaged {
  border-color: var(--accent-red) !important;
  box-shadow: 0 0 20px var(--accent-red);
  animation: rampage-flash 0.5s ease-out;
}

@keyframes rampage-flash {
  0%,
  100% {
    box-shadow: 0 0 20px var(--accent-red);
  }
  50% {
    box-shadow:
      0 0 40px var(--accent-red),
      0 0 60px var(--accent-red);
  }
}

.database.locked {
  border-color: var(--accent-yellow) !important;
  box-shadow: 0 0 10px var(--accent-yellow);
}

.database.locked .db-header::after {
  content: " (LOCKED)";
  color: var(--accent-yellow);
}

.database.vacuuming {
  border-color: var(--accent-blue) !important;
  box-shadow: 0 0 15px var(--accent-blue);
  animation: vacuum-pulse 0.5s ease-in-out infinite;
}

.database.vacuuming .db-header::after {
  content: " (VACUUM)";
  color: var(--accent-blue);
}

@keyframes vacuum-pulse {
  0%,
  100% {
    box-shadow: 0 0 10px var(--accent-blue);
  }
  50% {
    box-shadow:
      0 0 25px var(--accent-blue),
      0 0 40px var(--accent-blue);
  }
}

/* ============================================
   Stat Colors
   ============================================ */
.stat-value.survived {
  color: var(--accent-blue);
}

.stat-value.best {
  color: var(--accent-pink);
}

/* ============================================
   Query Bar Layout
   ============================================ */
.query-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ============================================
   Database UI Elements - Header
   ============================================ */
.connection-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-red);
}

.status-dot.connected {
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
}

.schema-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
}

.schema-label {
  color: var(--text-muted);
}

.schema-value {
  color: var(--accent-blue);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
}

.user-name {
  color: var(--text-secondary);
}

/* ============================================
   Database UI Elements - Sidebar
   ============================================ */
.main-layout {
  display: flex;
  flex: 1;
  gap: 0.5rem;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}

.sidebar-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.panel-header {
  padding: 0.5rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.panel-content {
  padding: 0.5rem;
  font-size: 0.7rem;
}

.tree-item {
  padding: 0.25rem 0;
  color: var(--text-secondary);
  cursor: pointer;
}

.tree-item:hover {
  color: var(--accent-blue);
}

.tree-children {
  margin-left: 1rem;
  color: var(--text-muted);
}

.tree-leaf {
  padding: 0.125rem 0;
  font-size: 0.65rem;
}

.index-item,
.constraint-item {
  padding: 0.25rem 0;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.constraint-item.critical {
  color: var(--accent-yellow);
}

.constraint-badge {
  font-size: 0.6rem;
  color: var(--accent-green);
  margin-left: auto;
}

/* ============================================
   Database UI Elements - Toolbar
   ============================================ */
.query-toolbar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem 0.625rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.toolbar-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-highlight);
}

.toolbar-btn .btn-icon {
  font-size: 0.8rem;
}

.toolbar-btn.btn-run {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: var(--bg-primary);
}

.toolbar-btn.btn-run:hover {
  background: #2ea043;
}

.toolbar-btn.btn-stop {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: white;
}

.toolbar-btn.btn-action {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: var(--bg-primary);
}

.toolbar-btn.btn-success {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: var(--bg-primary);
}

.toolbar-separator {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 0.25rem;
}

.toolbar-spacer {
  flex: 1;
}

/* ============================================
   Database UI Elements - Floating Panels
   ============================================ */
.floating-panel {
  position: absolute;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  z-index: 5;
}

.panel-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0.5rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.7rem;
}

.panel-title {
  color: var(--text-secondary);
  font-weight: 600;
}

.panel-controls {
  color: var(--text-muted);
  letter-spacing: 2px;
}

.panel-info {
  color: var(--text-muted);
  font-size: 0.65rem;
}

.panel-body {
  padding: 0.5rem;
  font-size: 0.7rem;
}

/* Query Editor Panel */
.query-editor {
  top: 0.5rem;
  left: 0.5rem;
  width: calc(100% - 1rem);
  max-width: 400px;
}

.sql-code {
  display: block;
  font-family: var(--font-mono);
  color: var(--text-primary);
  white-space: pre-wrap;
  line-height: 1.4;
}

.sql-keyword {
  color: var(--accent-pink);
  font-weight: 600;
}

.sql-number {
  color: var(--accent-yellow);
}

/* Results Grid Panel */
.results-grid {
  bottom: 0.5rem;
  left: 0.5rem;
  width: 180px;
}

.grid-body {
  padding: 0;
}

.grid-header {
  display: grid;
  grid-template-columns: 30px 70px 50px;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-tertiary);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

.grid-row {
  display: grid;
  grid-template-columns: 30px 70px 50px;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.65rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--bg-tertiary);
}

.grid-row:hover {
  background: var(--bg-tertiary);
}

/* Execution Plan Panel */
.exec-plan {
  bottom: 0.5rem;
  right: 0.5rem;
  width: 200px;
}

.plan-node {
  color: var(--text-secondary);
  padding: 0.125rem 0;
}

.plan-node.indent {
  margin-left: 1rem;
  color: var(--text-muted);
}

.plan-stats {
  color: var(--accent-yellow);
  font-size: 0.6rem;
  margin-top: 0.25rem;
}

/* ============================================
   Database UI Elements - Footer
   ============================================ */
.footer-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.query-stats {
  font-size: 0.75rem;
}

.stat-separator {
  color: var(--text-muted);
}

.tx-status {
  padding: 0.25rem 0.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.tx-badge {
  font-size: 0.7rem;
  font-weight: 600;
}

.tx-badge.autocommit {
  color: var(--accent-green);
}

.notifications {
  padding: 0.25rem 0.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
}

.notif-icon {
  font-size: 0.875rem;
}

.notif-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-yellow);
}

.best-score {
  margin-left: auto;
}

/* ============================================
   Game Over Overlay
   ============================================ */
.game-over-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(13, 17, 23, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: game-over-fade-in 0.5s ease-out;
}

@keyframes game-over-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.game-over-content {
  text-align: center;
  padding: 3rem;
  background: var(--bg-secondary);
  border: 2px solid var(--accent-red);
  border-radius: 8px;
  box-shadow:
    0 0 30px rgba(248, 81, 73, 0.3),
    inset 0 0 20px rgba(248, 81, 73, 0.1);
  animation: game-over-pulse 2s ease-in-out infinite;
}

@keyframes game-over-pulse {
  0%,
  100% {
    box-shadow:
      0 0 30px rgba(248, 81, 73, 0.3),
      inset 0 0 20px rgba(248, 81, 73, 0.1);
  }
  50% {
    box-shadow:
      0 0 50px rgba(248, 81, 73, 0.5),
      inset 0 0 30px rgba(248, 81, 73, 0.2);
  }
}

.game-over-content h1 {
  font-size: 2.5rem;
  color: var(--accent-red);
  margin-bottom: 1rem;
  text-shadow: 0 0 10px rgba(248, 81, 73, 0.5);
  animation: glitch-text 0.3s ease-in-out infinite alternate;
}

@keyframes glitch-text {
  0% {
    text-shadow:
      0 0 10px rgba(248, 81, 73, 0.5),
      2px 0 0 rgba(255, 0, 0, 0.3),
      -2px 0 0 rgba(0, 255, 255, 0.3);
  }
  100% {
    text-shadow:
      0 0 10px rgba(248, 81, 73, 0.5),
      -2px 0 0 rgba(255, 0, 0, 0.3),
      2px 0 0 rgba(0, 255, 255, 0.3);
  }
}

.game-over-content .error-code {
  font-size: 1rem;
  color: var(--accent-yellow);
  margin-bottom: 2rem;
  font-family: var(--font-mono);
}

.game-over-content .score {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.game-over-content .score span {
  color: var(--accent-green);
  font-weight: bold;
}

.game-over-content .best-score {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.game-over-content .best-score span {
  color: var(--accent-blue);
}

.game-over-content .restart-btn {
  padding: 1rem 2rem;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.game-over-content .restart-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(88, 166, 255, 0.5);
}

/* ============================================
   Overflow State Indicators (Soft Cap System)
   ============================================ */

/* Warning state - 1 goat over soft cap */
.database.over-soft-cap {
  box-shadow: 0 0 15px rgba(210, 153, 34, 0.4);
}

.database.over-soft-cap .db-header::before {
  content: "⚠ ";
  color: var(--accent-yellow);
}

.database.over-soft-cap .db-count {
  color: var(--accent-yellow);
}

/* Danger state - 2 goats over soft cap */
.database.critical-overflow {
  animation: critical-pulse 0.8s ease-in-out infinite;
  border-color: var(--accent-red) !important;
}

.database.critical-overflow .db-header::before {
  content: "⚠⚠ ";
  color: var(--accent-red);
}

.database.critical-overflow .db-count {
  color: var(--accent-red);
  font-weight: bold;
}

@keyframes critical-pulse {
  0%,
  100% {
    box-shadow: 0 0 10px rgba(248, 81, 73, 0.4);
  }
  50% {
    box-shadow:
      0 0 25px rgba(248, 81, 73, 0.7),
      0 0 40px rgba(248, 81, 73, 0.3);
  }
}

/* Doom imminent - 3+ goats over soft cap */
.database.doom-imminent {
  animation:
    doom-shake 0.15s ease-in-out infinite,
    doom-glow 0.5s ease-in-out infinite;
  border-color: var(--accent-red) !important;
  filter: saturate(1.3);
}

.database.doom-imminent .db-header {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 0%,
    rgba(248, 81, 73, 0.3) 50%,
    var(--bg-tertiary) 100%
  );
  animation: doom-header-flash 0.3s ease-in-out infinite;
}

.database.doom-imminent .db-header::before {
  content: "💀 ";
  animation: doom-skull 0.5s ease-in-out infinite;
}

.database.doom-imminent .db-count {
  color: var(--accent-red);
  font-weight: bold;
  text-shadow: 0 0 5px var(--accent-red);
}

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

@keyframes doom-glow {
  0%,
  100% {
    box-shadow:
      0 0 15px rgba(248, 81, 73, 0.6),
      0 0 30px rgba(248, 81, 73, 0.3),
      inset 0 0 10px rgba(248, 81, 73, 0.1);
  }
  50% {
    box-shadow:
      0 0 30px rgba(248, 81, 73, 0.9),
      0 0 50px rgba(248, 81, 73, 0.5),
      inset 0 0 20px rgba(248, 81, 73, 0.2);
  }
}

@keyframes doom-header-flash {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes doom-skull {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}
