/* ==========================================================================
   元素・化学式クイズ - Style Sheet
   Aesthetics: Bright, Pop, Modern, Tactile & Responsive UI
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-gradient: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
  --header-bg: rgba(255, 255, 255, 0.85);
  --card-bg: #ffffff;
  --card-shadow: 0 12px 32px rgba(31, 38, 135, 0.12);
  
  --primary-pop: #5c67f2;
  --primary-hover: #4a54e1;
  --secondary-pop: #ff6b81;
  --accent-yellow: #ffbe0b;
  --accent-green: #2ed573;
  --accent-red: #ff4757;
  
  --text-main: #2f3542;
  --text-muted: #747d8c;
  --border-light: #e4e7eb;

  /* Level Colors */
  --color-elementary: #2ed573;
  --color-junior: #3742fa;
  --color-high: #ff5252;

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-pop: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Global Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 680px;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 32px);
  overflow: hidden;
  position: relative;
  backdrop-filter: blur(10px);
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: var(--header-bg);
  border-bottom: 2px solid var(--border-light);
  backdrop-filter: blur(8px);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.atom-icon {
  width: 36px;
  height: 36px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.atom-nucleus {
  width: 10px;
  height: 10px;
  background: var(--secondary-pop);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--secondary-pop);
}

.atom-orbit {
  position: absolute;
  width: 32px;
  height: 14px;
  border: 2px solid var(--primary-pop);
  border-radius: 50%;
}

.orbit-1 {
  transform: rotate(30deg);
  animation: spin 6s linear infinite;
}

.orbit-2 {
  transform: rotate(-30deg);
  animation: spin 6s linear infinite reverse;
}

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

.app-title {
  font-size: 1.35rem;
  font-weight: 800;
  background: linear-gradient(45deg, var(--primary-pop), var(--secondary-pop));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.icon-btn {
  background: #f1f2f6;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.icon-btn:hover {
  background: #e4e7eb;
  transform: scale(1.05);
}

.icon-btn:active {
  transform: scale(0.95);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

/* Screens System */
.screen {
  display: none;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  animation: fadeIn 0.3s ease-out forwards;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero & Card Styles */
.hero-card {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: white;
  padding: 24px;
  border-radius: var(--radius-md);
  text-align: center;
  box-shadow: 0 8px 20px rgba(108, 92, 231, 0.25);
}

.badge-pill {
  display: inline-block;
  background: rgba(255, 255, 255, 0.25);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 10px;
  backdrop-filter: blur(4px);
}

.hero-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.hero-sub {
  font-size: 0.95rem;
  opacity: 0.9;
}

/* Sections & Labels */
.section-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Level Cards */
.level-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.level-card {
  background: #f8f9fa;
  border: 2px solid #e9ecef;
  border-radius: var(--radius-md);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-pop);
  position: relative;
}

.level-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary-pop);
}

.level-card.active {
  background: #ffffff;
  border-color: var(--primary-pop);
  box-shadow: 0 6px 18px rgba(92, 103, 242, 0.2);
  transform: translateY(-2px);
}

.level-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 6px;
}

.level-badge.elementary { background: var(--color-elementary); }
.level-badge.junior { background: var(--color-junior); }
.level-badge.high { background: var(--color-high); }

.level-icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.level-name {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 4px;
}

.level-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Options Grid & Segmented Control */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.segmented-control {
  display: flex;
  background: #f1f3f5;
  padding: 4px;
  border-radius: var(--radius-sm);
  gap: 4px;
}

.segmented-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.segmented-btn.active {
  background: #ffffff;
  color: var(--primary-pop);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* Pop Buttons */
.pop-btn {
  border: none;
  border-radius: var(--radius-md);
  font-weight: 800;
  font-size: 1.1rem;
  padding: 16px 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-pop);
  user-select: none;
  position: relative;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary-pop), #4834d4);
  color: white;
  box-shadow: 0 8px 20px rgba(92, 103, 242, 0.35), inset 0 -4px 0 rgba(0,0,0,0.2);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(92, 103, 242, 0.4), inset 0 -4px 0 rgba(0,0,0,0.2);
}

.primary-btn:active {
  transform: translateY(2px);
  box-shadow: 0 4px 10px rgba(92, 103, 242, 0.3), inset 0 -1px 0 rgba(0,0,0,0.2);
}

.secondary-btn {
  background: linear-gradient(135deg, #2ed573, #26af5f);
  color: white;
  box-shadow: 0 6px 16px rgba(46, 213, 115, 0.3), inset 0 -4px 0 rgba(0,0,0,0.2);
}

.secondary-btn:hover {
  transform: translateY(-2px);
}

.outline-btn {
  background: white;
  color: var(--text-main);
  border: 2px solid var(--border-light);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.outline-btn:hover {
  border-color: var(--primary-pop);
  color: var(--primary-pop);
}

.large-btn {
  width: 100%;
  font-size: 1.25rem;
  padding: 18px;
  border-radius: 20px;
}

.start-action {
  margin-top: 8px;
}

/* ==========================================================================
   QUIZ SCREEN STYLES
   ========================================================================== */

.quiz-status-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8f9fa;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.progress-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.mini-tag {
  background: var(--primary-pop);
  color: white;
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 12px;
}

.progress-bar-bg {
  width: 100%;
  height: 10px;
  background: #e9ecef;
  border-radius: 5px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #00c6ff, #0072ff);
  border-radius: 5px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.stats-pills {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 800;
  border: 1px solid var(--border-light);
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.combo-pill {
  color: var(--accent-red);
}

.score-pill {
  color: var(--accent-yellow);
}

/* Question Card */
.question-card {
  background: #ffffff;
  border: 3px solid #e0e6ed;
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: center;
  position: relative;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.question-header {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.mode-badge {
  background: #f0f3ff;
  color: var(--primary-pop);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid rgba(92, 103, 242, 0.2);
}

.category-badge {
  background: #fff0f3;
  color: var(--secondary-pop);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 107, 129, 0.2);
}

.question-prompt {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.question-display {
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--text-main);
  letter-spacing: 1px;
  line-height: 1.2;
}

.question-display sub {
  font-size: 2.2rem;
  bottom: -0.2em;
}

.question-hint {
  font-size: 0.88rem;
  color: #ff9f43;
  background: #fff8ee;
  padding: 8px 14px;
  border-radius: 12px;
  display: inline-block;
  margin-top: 6px;
  font-weight: 600;
}

/* Choices Grid */
.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.choice-btn {
  background: #ffffff;
  border: 2.5px solid #e4e7eb;
  border-radius: var(--radius-md);
  padding: 20px 16px;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-pop);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 #e4e7eb;
  position: relative;
  min-height: 72px;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--primary-pop);
  box-shadow: 0 6px 0 var(--primary-pop);
  transform: translateY(-2px);
  color: var(--primary-pop);
}

.choice-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--primary-pop);
}

.choice-btn.correct {
  background: #e8fadf !important;
  border-color: var(--accent-green) !important;
  color: #1e824c !important;
  box-shadow: 0 4px 0 var(--accent-green) !important;
  animation: popSuccess 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.choice-btn.incorrect {
  background: #ffe5e7 !important;
  border-color: var(--accent-red) !important;
  color: #c0392b !important;
  box-shadow: 0 4px 0 var(--accent-red) !important;
  animation: shake 0.4s ease-in-out;
}

@keyframes popSuccess {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Feedback Banner */
.feedback-banner {
  background: #ffffff;
  border: 2.5px solid var(--primary-pop);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: slideUp 0.3s ease-out;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.hidden,
.feedback-banner.hidden {
  display: none !important;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.feedback-top-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.feedback-icon {
  font-size: 2.2rem;
  line-height: 1;
  flex-shrink: 0;
}

.feedback-title-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.feedback-title {
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap; /* Prevents awkward 3-character wrapping on mobile */
  margin: 0;
}

.feedback-detail {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
}

.feedback-trivia {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: #f8f9fa;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  line-height: 1.4;
}

.feedback-action {
  width: 100%;
  margin-top: 2px;
}

.full-btn {
  width: 100%;
  font-size: 1.05rem;
  padding: 14px;
}

/* ==========================================================================
   RESULT SCREEN STYLES
   ========================================================================== */

.result-card {
  background: linear-gradient(180deg, #ffffff 0%, #f4f6f9 100%);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  border: 2px solid var(--border-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

.result-badge {
  background: linear-gradient(45deg, #ff9f43, #ff6b6b);
  color: white;
  font-weight: 800;
  font-size: 1rem;
  padding: 6px 20px;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(255, 159, 67, 0.3);
}

.result-title {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--text-main);
}

.score-display {
  margin: 8px 0;
}

.score-number-wrapper {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}

.score-big {
  font-size: 4rem;
  font-weight: 900;
  color: var(--primary-pop);
  line-height: 1;
}

.score-unit {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-muted);
}

.accuracy-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 6px;
}

.result-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-top: 8px;
}

.result-actions button {
  flex: 1;
}

/* Review Accordion */
.review-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.review-title {
  font-size: 1.1rem;
  font-weight: 800;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.review-item {
  background: #f8f9fa;
  border-radius: var(--radius-sm);
  padding: 14px;
  border-left: 5px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.review-item.is-correct {
  border-left-color: var(--accent-green);
  background: #f4fbf7;
}

.review-item.is-incorrect {
  border-left-color: var(--accent-red);
  background: #fff5f5;
}

.review-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.review-q-text {
  font-size: 1.1rem;
}

.review-ans-row {
  font-size: 0.9rem;
  color: var(--text-main);
}

.review-trivia {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  background: rgba(255,255,255,0.5);
}

/* ==========================================================================
   MOBILE RESPONSIVE (100dvh Fit without Scrolling)
   ========================================================================== */
@media (max-width: 600px) {
  body {
    padding: 0;
  }
  
  .app-container {
    border-radius: 0;
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .app-header {
    padding: 10px 14px;
    flex-shrink: 0;
  }

  .app-title {
    font-size: 1.15rem;
  }

  .main-content {
    padding: 10px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }

  /* Compact Hero Card for Mobile */
  .hero-card {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
  }

  .badge-pill {
    font-size: 0.72rem;
    padding: 2px 8px;
    margin-bottom: 4px;
  }

  .hero-title {
    font-size: 1.15rem;
    margin-bottom: 2px;
  }

  .hero-sub {
    font-size: 0.78rem;
  }

  /* Quiz Screen Mobile Compact Fit */
  #quizScreen {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    height: 100%;
  }

  #quizScreen.active {
    display: flex;
  }

  .quiz-status-bar {
    padding: 8px 10px;
    gap: 6px;
  }

  .question-card {
    padding: 12px 10px;
    gap: 6px;
  }

  .question-header {
    gap: 6px;
  }

  .mode-badge, .category-badge {
    font-size: 0.72rem;
    padding: 2px 8px;
  }

  .question-prompt {
    font-size: 0.85rem;
    margin-bottom: 2px;
  }

  .question-display {
    font-size: 2.2rem;
  }

  .question-display sub {
    font-size: 1.3rem;
  }

  .question-hint {
    font-size: 0.75rem;
    padding: 4px 8px;
    margin-top: 2px;
  }

  /* 2x2 Grid for choice buttons on mobile (prevents long vertical stack) */
  .choices-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
  }

  .choice-btn {
    padding: 8px 6px;
    font-size: 0.98rem;
    min-height: 48px;
    box-shadow: 0 3px 0 #e4e7eb;
  }

  .level-cards {
    grid-template-columns: 1fr;
  }

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

  .result-actions {
    flex-direction: column;
  }

  .feedback-banner {
    padding: 10px 12px;
    gap: 6px;
  }

  .feedback-icon {
    font-size: 1.6rem;
  }

  .feedback-title {
    font-size: 1.1rem;
  }

  .feedback-detail {
    font-size: 0.85rem;
  }

  .feedback-trivia {
    font-size: 0.78rem;
    padding: 6px 8px;
  }

  .full-btn {
    padding: 10px;
    font-size: 0.92rem;
  }

  .app-footer {
    padding: 6px;
    font-size: 0.7rem;
    flex-shrink: 0;
  }
}

/* ==========================================================================
   3D MOLECULAR & STEREOCHEMICAL VIEWER STYLES
   ========================================================================== */

.question-mol-box, .feedback-mol-box {
  margin-top: 12px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.15);
  border: 1px solid rgba(255,255,255,0.1);
  overflow: hidden;
}

.mol-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.mol-header-tag, .mol-header-badge {
  display: inline-block;
  background: rgba(92, 103, 242, 0.25);
  color: #a5b4fc;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid rgba(165, 180, 252, 0.3);
}

.mol-viewer-body {
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.mol3d-container {
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  border-radius: var(--radius-sm);
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
  user-select: none;
}

.mol3d-canvas-wrapper {
  width: 100%;
  position: relative;
  cursor: grab;
}

.mol3d-canvas-wrapper:active {
  cursor: grabbing;
}

.mol3d-toolbar {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  padding: 8px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.mol3d-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mol3d-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  transform: translateY(-1px);
}

.mol3d-btn.active {
  background: var(--primary-pop);
  border-color: var(--primary-pop);
  color: #ffffff;
  box-shadow: 0 0 8px rgba(92, 103, 242, 0.5);
}

.review-3d-action {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.mol-view-btn {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.mol-view-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

/* Modal Styles */
.mol3d-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.mol3d-modal.active {
  display: flex;
  animation: fadeIn 0.25s ease-out;
}

.mol3d-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
}

.mol3d-modal-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: linear-gradient(145deg, #1e293b, #0f172a);
  color: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
}

.mol3d-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mol3d-modal-badge {
  font-size: 0.75rem;
  color: #818cf8;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mol3d-modal-title {
  font-size: 1.3rem;
  font-weight: 800;
  margin-top: 2px;
}

.mol3d-modal-formula {
  font-size: 1rem;
  color: #94a3b8;
  font-weight: 600;
}

.mol3d-modal-close {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.mol3d-modal-close:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.mol3d-modal-viewer {
  width: 100%;
  padding: 8px;
}

.mol3d-modal-details {
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.mol3d-atom-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.mol3d-atom-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.mol3d-modal-footer {
  padding: 10px 20px 16px;
  text-align: center;
  font-size: 0.78rem;
  color: #94a3b8;
}

