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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  color: #e0e0e0;
  min-height: 100vh;
  line-height: 1.6;
}

/* ===== Header ===== */
header {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.header-content h1 {
  font-size: 1.8rem;
  background: linear-gradient(90deg, #00f5a0, #00d9f5);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  flex: 1;
  opacity: 0.7;
  font-size: 0.95rem;
}

#auth-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#user-profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

#user-name {
  font-size: 0.9rem;
}

/* ===== Main ===== */
main {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ===== Cards ===== */
.card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 2rem;
  backdrop-filter: blur(5px);
}

.card h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: #fff;
}

.card > p {
  margin-bottom: 1.5rem;
  opacity: 0.7;
}

/* ===== API Config ===== */
.api-key-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.api-key-row label {
  font-weight: 600;
  white-space: nowrap;
}

.api-key-row input {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.3);
  color: #e0e0e0;
  font-size: 0.95rem;
}

.provider-select {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.provider-select label {
  font-weight: 600;
}

.provider-select select,
.animal-dropdown {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.3);
  color: #e0e0e0;
  font-size: 0.95rem;
  cursor: pointer;
}

.provider-select select option,
.animal-dropdown option {
  background: #1a1a2e;
  color: #e0e0e0;
}

/* ===== Fusion Panels ===== */
.fusion-panels {
  display: flex;
  gap: 1.5rem;
  align-items: stretch;
}

.fusion-panel {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.fusion-panel h3 {
  font-size: 1.2rem;
  color: #00f5a0;
}

.animal-selectors {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.animal-select {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.animal-select label {
  font-size: 0.85rem;
  opacity: 0.7;
}

.fusion-symbol {
  font-size: 1.5rem;
  margin-top: 1rem;
}

.vs-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  font-size: 2rem;
  font-weight: 800;
  color: #ff6b6b;
  min-width: 60px;
}

/* ===== Chimera Result ===== */
.chimera-result, #battle-result {
  width: 100%;
  min-height: 300px;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.15);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  position: relative;
}

.chimera-result img, #battle-result img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
}

.placeholder {
  opacity: 0.4;
  font-style: italic;
}

.chimera-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  padding: 0.5rem 1rem;
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #00f5a0;
}

/* ===== Buttons ===== */
.btn {
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.15);
  color: #e0e0e0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-small:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.25);
}

.btn-primary {
  background: linear-gradient(135deg, #00f5a0, #00d9f5);
  color: #0f0c29;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 245, 160, 0.3);
}

.btn-battle {
  background: linear-gradient(135deg, #ff6b6b, #ff8e53);
  color: #fff;
  font-size: 1.2rem;
  padding: 1rem 3rem;
  margin: 0 auto;
  display: block;
}

.btn-battle:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(255, 107, 107, 0.4);
}

/* ===== Loading Overlay ===== */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  z-index: 1000;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: #00f5a0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#loading-text {
  font-size: 1.1rem;
  opacity: 0.8;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 2rem 1rem;
  opacity: 0.5;
  font-size: 0.85rem;
}

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .fusion-panels {
    flex-direction: column;
  }

  .vs-divider {
    flex-direction: row;
    gap: 0.5rem;
  }

  .header-content {
    flex-direction: column;
    text-align: center;
  }

  .btn-battle {
    font-size: 1rem;
    padding: 0.8rem 2rem;
  }
}
