:root {
  /* Modern Palette */
  --bg-dark: #050505;
  --bg-panel: rgba(20, 20, 25, 0.6);
  --primary: #6366f1;
  /* Indigo */
  --primary-glow: rgba(99, 102, 241, 0.5);
  --secondary: #ec4899;
  /* Pink */
  --secondary-glow: rgba(236, 72, 153, 0.5);
  --accent: #06b6d4;
  /* Cyan */
  --accent-glow: rgba(6, 182, 212, 0.5);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --border-light: rgba(255, 255, 255, 0.08);
  --glass-blur: blur(16px);

  --font-family: 'Outfit', sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* subtle grid background */
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.15), transparent 60%);
  background-size: 50px 50px, 50px 50px, 100% 100%;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

#game-container {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  padding: 1.5rem 2rem;
  gap: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

/* HEADER */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--bg-panel);
  backdrop-filter: var(--glass-blur);
  border-radius: 1rem;
  border: 1px solid var(--border-light);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.05rem;
  text-transform: uppercase;
  background: linear-gradient(135deg, #fff 0%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.highlight {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#status-bar {
  display: flex;
  gap: 2.5rem;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.stat-box .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05rem;
  font-weight: 600;
}

.stat-box .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

/* MAIN LAYOUT */
main {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  gap: 1.5rem;
  height: 100%;
  overflow: hidden;
  padding-bottom: 1.5rem;
}

#left-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#right-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* PANELS */
.panel {
  background: var(--bg-panel);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: var(--transition);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  flex: 1;
  min-height: 0;
}

.panel:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

.panel h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* LISTS */
.scroll-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 0.25rem;
}

/* UPGRADES & ITEMS */
.upgrade-item,
.achievement-item,
.catalog-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-radius: 0.75rem;
  padding: 1rem;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.upgrade-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.03), transparent);
  transform: translateX(-100%);
  transition: 0.5s;
}

.upgrade-item:hover::before {
  transform: translateX(100%);
}

.upgrade-item:hover,
.catalog-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.upgrade-item h3 {
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
  color: #fff;
}

.upgrade-cost {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
}

.upgrade-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  line-height: 1.3;
}

/* CENTER PANEL */
#center-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* THE KEY */
#key-display {
  position: relative;
  width: 100%;
  height: 250px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1rem;
}

.massive-key {
  font-size: 3rem;
  font-weight: 800;
  color: var(--text-main);
  background: rgba(30, 41, 59, 0.8);
  width: 280px;
  height: 120px;
  border-radius: 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;

  /* 3D Effect */
  box-shadow:
    0 15px 0 #0f172a,
    0 15px 20px rgba(0, 0, 0, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.05);

  transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  cursor: pointer;
  position: relative;
  z-index: 10;
}

/* Glowing ring behind key */
.massive-key::after {
  content: '';
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  background: linear-gradient(45deg, var(--primary), var(--secondary));
  z-index: -1;
  border-radius: 1.6rem;
  filter: blur(20px);
  opacity: 0.4;
  transition: opacity 0.3s;
}

.massive-key:hover::after {
  opacity: 0.6;
}

.massive-key:active,
.massive-key.pressed {
  transform: translateY(15px);
  box-shadow:
    0 0 0 #0f172a,
    inset 0 5px 10px rgba(0, 0, 0, 0.5);
}

.massive-key:active::after,
.massive-key.pressed::after {
  opacity: 0.8;
  filter: blur(10px);
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Floating Text */
.floating-text {
  position: absolute;
  color: var(--text-main);
  font-weight: 800;
  font-size: 1.8rem;
  pointer-events: none;
  animation: popUp 0.8s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-shadow: 0 0 10px var(--primary-glow);
  z-index: 20;
}

@keyframes popUp {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.5) rotate(-5deg);
  }

  50% {
    opacity: 1;
    transform: translateY(-50px) scale(1.2) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translateY(-100px) scale(1);
  }
}

.instruction {
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.7;
}

/* Active Keys Display */
#active-keys-list {
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem 1.5rem;
  border-radius: 2rem;
  border: 1px solid var(--border-light);
  color: var(--accent);
  font-weight: 600;
  margin-top: 1rem;
  backdrop-filter: blur(10px);
}

/* BUTTONS */
button,
.challenge-btn {
  font-family: var(--font-family);
  border: none;
  outline: none;
  cursor: pointer;
}

.challenge-btn {
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  color: white;
  padding: 0.8rem 1.5rem;
  font-size: 0.9rem;
  border-radius: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  text-transform: uppercase;
}

.challenge-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.5);
}

#view-upgrades-btn,
#view-achievements-btn {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid var(--border-light) !important;
  color: var(--text-muted) !important;
  padding: 0.4rem 0.8rem !important;
  border-radius: 0.5rem !important;
  transition: var(--transition);
}

#view-upgrades-btn:hover,
#view-achievements-btn:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
}

/* MINIGAME & OVERLAYS */
#minigame-selector-panel {
  background: transparent;
  border: none;
  padding: 0;
  margin-top: 2rem;
}

#minigame-selector-panel h3 {
  margin-bottom: 1rem;
  font-size: 0.8rem;
  opacity: 0.5;
}

.minigame-content,
.catalog-content {
  background: #0f172a;
  border: 1px solid var(--border-light);
  border-radius: 1.5rem;
  padding: 2.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  position: relative;
  max-width: 600px;
  width: 90%;
  text-align: center;
}

.catalog-content {
  max-width: 900px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  text-align: left;
}

/* Catalog Grid */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  overflow-y: auto;
  padding: 1rem;
}

.catalog-item {
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.catalog-item.unlocked {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.1);
}

.catalog-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.catalog-header h2 {
  font-size: 1.8rem;
  color: #fff;
}

/* OVERLAY SYSTEM */
#save-slot-overlay,
#minigame-overlay,
#achievement-catalog-overlay,
#upgrade-catalog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
}

#save-slot-overlay {
  background-color: #050505 !important;
  /* Solid background hiding everything */
  z-index: 10000 !important;
  /* Highest priority */
}

#minigame-overlay,
#achievement-catalog-overlay,
#upgrade-catalog-overlay {
  background: rgba(5, 5, 5, 0.95);
  backdrop-filter: blur(10px);
}

.save-slot {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.save-slot:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--primary);
  transform: scale(1.01);
}

.slot-name-display {
  color: #fff;
  font-size: 1.2rem;
}

.slot-action {
  background: var(--primary);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: bold;
}

/* PROGRESS BARS */
.progress-bar-bg {
  background: rgba(255, 255, 255, 0.1);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  height: 100%;
  transition: width 0.5s ease;
}

/* CORNER NOTIFICATIONS */
#corner-counter {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  backdrop-filter: blur(10px);
  border-radius: 0.5rem;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* UTILITY */
.hidden {
  display: none !important;
}

/* MINIGAME PLAY AREA */
#minigame-play-area {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
}

.rhythm-target {
  width: 70px;
  height: 70px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 800;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  background: rgba(255, 255, 255, 0.05);
  font-size: 1.5rem;
}

.rhythm-target.hit {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--primary-glow);
  transform: scale(1.1);
}

.rhythm-target.miss {
  background: #ef4444;
  border-color: #ef4444;
  animation: shake 0.3s;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}


#corner-counter {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem;
  z-index: 100;
  min-width: 150px;
  text-align: right;
}