:root {
  /* Comfort Dark Palette */
  --bg-color: #1a1b26;
  /* Deep Blue-Gray */
  --card-bg: #24283b;
  /* Lighter Blue-Gray */
  --card-border: 1px solid rgba(255, 255, 255, 0.05);

  --primary-color: #7aa2f7;
  /* Soft Blue */
  --secondary-color: #bb9af7;
  /* Soft Purple */
  --accent-color: #e0af68;
  /* Muted Gold */

  --text-main: #c0caf5;
  /* Off-white / Blue tint */
  --text-dim: #565f89;
  /* Muted Grey-Blue */

  --success-color: #9ece6a;
  /* Pastel Green */
  --danger-color: #f7768e;
  /* Pastel Red */

  --font-main: 'Noto Sans KR', 'Inter', sans-serif;
  --glass-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

body {
  margin: 0;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-main);
  /* Subtle mesh gradient */
  background-image:
    radial-gradient(circle at 0% 0%, rgba(122, 162, 247, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(187, 154, 247, 0.05) 0%, transparent 50%);
  min-height: 100vh;
}

/* Hide Scrollbar for ALL elements */
* {
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* IE/Edge */
}

/* Chrome, Safari, Opera */
*::-webkit-scrollbar {
  display: none;
}

#app {
  max-width: 520px;
  /* Slightly wider */
  margin: 0 auto;
  position: relative;
  min-height: 100vh;
  padding-bottom: 90px;
  padding-top: 120px;
  /* Add space for fixed header */
}

/* Typography */
h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.neon-text {
  color: var(--text-main);
  text-shadow: none;
  /* Removed neon glow for eye comfort */
}

/* Header */
header {
  padding: 20px;
  text-align: center;
  border-bottom: var(--card-border);
  background: rgba(26, 27, 38, 0.95);
  /* High opacity background */
  backdrop-filter: blur(10px);
  position: fixed;
  /* Fixed to viewport */
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

#user-status {
  max-width: 520px;
  margin: 10px auto 0;
  /* Center content matching app width */
  font-size: 0.9em;
  color: var(--text-dim);
  display: flex;
  justify-content: center;
  gap: 15px;
}

#user-money {
  color: var(--accent-color);
  font-weight: bold;
}

/* Views Logic - CRITICAL */
.view {
  display: none;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Login Card */
/* Cards (Modern & Clean) */
.glass-panel {
  background: var(--card-bg);
  border: var(--card-border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--glass-shadow);
  margin-bottom: 20px;
  font-weight: bold;
  /* User Request: Bold */
}

.input-group {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s;
  position: relative;
  z-index: 200;
  font-size: 16px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

/* Buttons (Softer) */
.btn {
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, filter 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  padding: 12px 20px;
  letter-spacing: 0.02em;
}

.btn:active {
  transform: scale(0.96);
}

.btn.primary {
  background: var(--primary-color);
  color: #1a1b26;
}

.btn.secondary {
  background: #292e42;
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn.danger {
  background: var(--danger-color);
  color: #1a1b26;
}

.btn.success {
  background: var(--success-color);
  color: #1a1b26;
}

.btn.small {
  padding: 8px 12px;
  font-size: 12px;
}

/* Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(10px);
  border-top: var(--glass-border);
  display: flex;
  justify-content: space-around;
  padding: 12px 0;
  z-index: 200;
}

.nav-item {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 15px;
  /* User Request: 15px */
  font-weight: bold;
  /* User Request: Bold */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.nav-item.active {
  color: var(--primary-color);
}

.nav-item i {
  font-size: 26px;
  /* 20px -> 26px (Bold visual) */
  font-style: normal;
}

/* Tabs */
.tab-btn {
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  font-weight: bold;
}

.tab-btn.active {
  background: var(--primary-color);
  color: #000;
  border-color: var(--primary-color);
}

/* Grid & Lists */
/* Inventory Grid - Breathing Room */
.grid-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 20px;
}

.list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 15px;
}

.building-card,
.rank-row {
  background: var(--card-bg);
  border: var(--glass-border);
  border-radius: 12px;
  padding: 15px;
  position: relative;
  overflow: hidden;
}

.market-row {
  background: var(--card-bg);
  border: var(--glass-border);
  border-radius: 12px;
  padding: 15px;
  position: relative;
  overflow: visible; /* Allow buttons to show fully */
}

/* Fix Market spacing */
#market-list > div:nth-child(2) {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.building-card {
  background: #1f2335;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 20px;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.building-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  background: #292e42;
}

.building-card.equipped {
  border: 1px solid var(--primary-color);
  background: rgba(122, 162, 247, 0.1);
}

/* Modern Tier Badges */
.tier-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 8px;
  letter-spacing: 0.5px;
}

/* Refined Tier Colors (Pastel/Muted) */
.tier-SSS,
.tier-EX {
  background: rgba(157, 78, 221, 0.2);
  color: #c77dff;
  border: 1px solid rgba(199, 125, 255, 0.3);
}

.tier-SS {
  background: rgba(247, 118, 142, 0.2);
  color: #f7768e;
  border: 1px solid rgba(247, 118, 142, 0.3);
}

.tier-S {
  background: rgba(224, 175, 104, 0.2);
  color: #e0af68;
  border: 1px solid rgba(224, 175, 104, 0.3);
}

.tier-A {
  background: rgba(115, 218, 202, 0.2);
  color: #73daca;
  border: 1px solid rgba(115, 218, 202, 0.3);
}

.tier-B,
.tier-C,
.tier-F {
  background: rgba(86, 95, 137, 0.2);
  color: #a9b1d6;
  border: 1px solid rgba(86, 95, 137, 0.3);
}

/* Typography Inside Card */
.b-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin: 10px 0 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.b-level {
  font-size: 13px;
  color: var(--primary-color);
  font-weight: 600;
  background: rgba(122, 162, 247, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
}

/* Building Icon Placeholder */
.b-icon {
  font-size: 32px;
  margin-bottom: 5px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.action-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

/* Toast */
#toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100000;
  /* Highest priority */
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 90%;
  max-width: 400px;
}

.toast {
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid var(--primary-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.3s ease;
  font-size: 14px;
}

.toast.error {
  border-left-color: var(--danger-color);
}

.toast.success {
  border-left-color: var(--success-color);
}

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

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Utility */
.hidden {
  display: none !important;
}

/* Filter Bar */
.filter-btn {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn.active {
  background: var(--primary-color);
  color: black;
  font-weight: bold;
  border-color: var(--primary-color);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  width: 90%;
  max-width: 380px; /* Increased from 320px */
  position: relative;
  background: #111;
  border: 1px solid var(--primary-color);
  box-shadow: 0 0 30px rgba(0, 243, 255, 0.2);
  font-size: 1.05em; /* Slightly larger text */
}

.btn-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* --- Ethereal Glass Design (Clean, Modern, Pastel Ambience) --- */

/* Base Card: Frosted Glass */
.building-card {
  background: rgba(255, 255, 255, 0.03);
  /* Very subtle milky fill */
  backdrop-filter: blur(16px) saturate(180%);
  /* Strong blur + vibrance */
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  /* Subtle rim */
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  /* Highlight top */
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  /* Shadow bottom */
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  /* Soft grounding shadow */
  border-radius: 16px;
  /* Smooth corners */
  overflow: visible;
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s ease;
}

.building-card:hover {
  transform: translateY(-5px);
  background: rgba(255, 255, 255, 0.07);
}

/* Tier Badges: Minimalist Glass Tags */
.tier-badge {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  font-weight: 600;
  letter-spacing: 1px;
}

/* Common "Breathing" for Ambience (Soft Pulse) */

/* Lv.11+: Arctic Mist (Soft Blue) */
@keyframes glassBlue {
  0% {
    box-shadow: 0 10px 40px rgba(100, 200, 255, 0.1), inset 0 0 20px rgba(100, 200, 255, 0.05);
    border-color: rgba(150, 220, 255, 0.3);
  }

  50% {
    box-shadow: 0 15px 60px rgba(100, 200, 255, 0.25), inset 0 0 30px rgba(100, 200, 255, 0.1);
    border-color: rgba(180, 230, 255, 0.5);
  }

  100% {
    box-shadow: 0 10px 40px rgba(100, 200, 255, 0.1), inset 0 0 20px rgba(100, 200, 255, 0.05);
    border-color: rgba(150, 220, 255, 0.3);
  }
}

.glow-11 {
  animation: glassBlue 4s infinite ease-in-out;
}

.glow-11 .b-name {
  color: #d0eeff;
  text-shadow: 0 0 10px rgba(100, 200, 255, 0.5);
}

/* Lv.13+: Morning Sunlight (Soft Gold) */
@keyframes glassGold {
  0% {
    box-shadow: 0 10px 40px rgba(255, 220, 150, 0.1), inset 0 0 20px rgba(255, 220, 150, 0.05);
    border-color: rgba(255, 230, 180, 0.3);
  }

  50% {
    box-shadow: 0 15px 60px rgba(255, 220, 150, 0.25), inset 0 0 30px rgba(255, 220, 150, 0.1);
    border-color: rgba(255, 240, 200, 0.5);
  }

  100% {
    box-shadow: 0 10px 40px rgba(255, 220, 150, 0.1), inset 0 0 20px rgba(255, 220, 150, 0.05);
    border-color: rgba(255, 230, 180, 0.3);
  }
}

.glow-13 {
  animation: glassGold 4s infinite ease-in-out;
}

.glow-13 .b-name {
  color: #fff8d0;
  text-shadow: 0 0 10px rgba(255, 220, 150, 0.5);
}

/* Lv.15+: Rose Quartz (Soft Pink/Red) */
@keyframes glassRose {
  0% {
    box-shadow: 0 10px 40px rgba(255, 150, 150, 0.1), inset 0 0 20px rgba(255, 150, 150, 0.05);
    border-color: rgba(255, 180, 180, 0.3);
  }

  50% {
    box-shadow: 0 15px 60px rgba(255, 120, 120, 0.25), inset 0 0 30px rgba(255, 150, 150, 0.1);
    border-color: rgba(255, 200, 200, 0.5);
  }

  100% {
    box-shadow: 0 10px 40px rgba(255, 150, 150, 0.1), inset 0 0 20px rgba(255, 150, 150, 0.05);
    border-color: rgba(255, 180, 180, 0.3);
  }
}

.glow-15 {
  animation: glassRose 4s infinite ease-in-out;
}

.glow-15 .b-name {
  color: #ffe0e0;
  text-shadow: 0 0 10px rgba(255, 150, 150, 0.5);
}

/* Lv.17+: Lavender Dream (Holographic Foil) */
@keyframes glassLavender {
  0% {
    box-shadow: 0 10px 40px rgba(200, 150, 255, 0.1), inset 0 0 20px rgba(200, 150, 255, 0.05);
    border-color: rgba(220, 180, 255, 0.3);
  }

  50% {
    box-shadow: 0 15px 60px rgba(200, 150, 255, 0.25), inset 0 0 30px rgba(200, 150, 255, 0.1);
    border-color: rgba(240, 210, 255, 0.5);
  }

  100% {
    box-shadow: 0 10px 40px rgba(200, 150, 255, 0.1), inset 0 0 20px rgba(200, 150, 255, 0.05);
    border-color: rgba(220, 180, 255, 0.3);
  }
}

@keyframes holoSheen {
  0% {
    background-position: 200% 50%;
    opacity: 0;
  }

  20% {
    opacity: 0.5;
  }

  80% {
    opacity: 0.5;
  }

  100% {
    background-position: -200% 50%;
    opacity: 0;
  }
}

.glow-17 {
  animation: glassLavender 4s infinite ease-in-out;
  position: relative;
  overflow: hidden;
}

.glow-17::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 0, 255, 0.2) 45%, rgba(0, 255, 255, 0.2) 50%, rgba(255, 255, 0, 0.2) 55%, transparent 70%);
  background-size: 200% 100%;
  animation: holoSheen 3s infinite linear;
  pointer-events: none;
  mix-blend-mode: overlay;
  z-index: 2;
}

.glow-17 .b-name {
  color: #f0e0ff;
  text-shadow: 0 0 10px rgba(200, 150, 255, 0.5);
  position: relative;
  z-index: 3;
}

/* Lv.19+: Prism Fog (Ultimate Hologram) - Toned Down */
@keyframes glassPrism {
  0% {
    box-shadow: 0 10px 40px rgba(255, 255, 255, 0.1), inset 0 0 20px rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.4);
  }

  50% {
    box-shadow: 0 15px 50px rgba(255, 255, 255, 0.25), inset 0 0 30px rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.8);
  }

  100% {
    box-shadow: 0 10px 40px rgba(255, 255, 255, 0.1), inset 0 0 20px rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.4);
  }
}

.glow-19 {
  background: rgba(255, 255, 255, 0.05) !important;
  animation: glassPrism 3s infinite ease-in-out;
  border: 1px solid rgba(255, 255, 255, 0.5) !important;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  /* Ensure border doesn't add width */
}

.glow-19::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg, transparent, rgba(255, 0, 0, 0.1), rgba(0, 255, 0, 0.1), rgba(0, 0, 255, 0.1), transparent);
  animation: spin 4s linear infinite;
  pointer-events: none;
  mix-blend-mode: color-dodge;
  z-index: 2;
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

.glow-19 .tier-badge {
  background: #fff;
  color: #000;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
  position: absolute;
  /* Restore absolute positioning to prevent layout shift */
  z-index: 3;
}

.glow-19 .b-name {
  background: linear-gradient(135deg, #fff 0%, #a0a0ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.6);
  font-weight: 900;
  position: relative;
  z-index: 3;
}
/* Lineup View Styles */
.lineup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.lineup-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 100px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.lineup-slot {
  aspect-ratio: 1/1.2;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 10px;
  color: var(--text-dim);
}

.lineup-slot::before {
  content: attr(data-pos);
  position: absolute;
  top: 5px;
  left: 5px;
  font-size: 10px;
}

.lineup-item {
  width: 100%;
  height: 100%;
  padding: 5px;
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: grab;
  text-align: center;
}

.lineup-item:active {
  cursor: grabbing;
}

.lineup-item .t-icon {
  font-size: 20px;
}

.lineup-item .t-name {
  font-size: 10px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.lineup-item .t-level {
  font-size: 9px;
  color: var(--primary-color);
}

.pool-item {
  width: 70px;
  height: 80px;
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: grab;
  padding: 5px;
  text-align: center;
}

.sortable-ghost {
  opacity: 0.4;
  background: var(--primary-color) !important;
}

.lineup-slot.highlight {
  border-color: var(--primary-color);
  background: rgba(122, 162, 247, 0.1);
}

/* Modal Tabs */
.modal-tabs {
  display: flex !important;
  justify-content: space-around;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 5px;
}

.tab-link {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  transition: all 0.2s;
  text-align: center;
}

.tab-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.tab-link.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  background: rgba(122, 162, 247, 0.05);
}

.tab-pane {
  animation: fadeIn 0.2s ease;
}

/* Unique Option Badge in Header */
#m-unique-container {
  margin-top: 5px;
  min-height: 20px;
}

/* Potential System */
.potential-container {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  backdrop-filter: blur(4px);
}

.potential-list {
  box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}
