* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: linear-gradient(160deg, #1a1a2e 0%, #16213e 45%, #0f3460 100%);
  color: #f0f4ff;
  min-height: 100vh;
}

a.back-link {
  position: fixed;
  top: 12px;
  left: 12px;
  color: #b8c7ff;
  text-decoration: none;
  font-size: 0.95rem;
  z-index: 10;
}

a.back-link:hover {
  color: #fff;
}

.screen {
  max-width: 960px;
  margin: 0 auto;
  padding: 3rem 1rem 2rem;
}

.hidden {
  display: none !important;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  text-align: center;
}

.subtitle {
  text-align: center;
  color: #a8b8e8;
  margin-bottom: 1.5rem;
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.mode-tab {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  color: #dce4ff;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  font-size: 0.95rem;
}

.mode-tab.selected {
  border-color: #ba68c8;
  background: rgba(186, 104, 200, 0.22);
  color: #fff;
}

.mode-desc {
  text-align: center;
  color: #b0bddf;
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.theme-card {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 1rem;
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}

.theme-card:hover,
.theme-card.selected {
  transform: translateY(-3px);
  border-color: #ba68c8;
  background: rgba(186, 104, 200, 0.15);
}

.theme-icon {
  font-size: 2.4rem;
  margin-bottom: 0.4rem;
}

.theme-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.theme-card p {
  margin: 0;
  font-size: 0.78rem;
  color: #b0bddf;
}

.custom-theme {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.custom-theme label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.custom-theme input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 1rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

button {
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.4rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

button:hover:not(:disabled) {
  transform: scale(1.03);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(90deg, #ba68c8, #7b1fa2);
  color: #fff;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.status-bar {
  text-align: center;
  font-size: 0.9rem;
  color: #9eb0e8;
  min-height: 1.4rem;
  margin: 0.75rem 0 1rem;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.hud-pill {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
}

.target-panel {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(186, 104, 200, 0.5);
  border-radius: 16px;
  padding: 1.25rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.target-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  color: #e1bee7;
}

.target-creature {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.creature-visual {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.35);
  position: relative;
  overflow: hidden;
}

.creature-photo {
  width: 120px;
  height: 120px;
  object-fit: cover;
  object-position: center;
  border-radius: 16px;
  border: 3px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  background: #1a1a2e;
  display: block;
}

.creature-photo-sm {
  width: 88px;
  height: 88px;
  border-radius: 12px;
}

.creature-label {
  font-weight: 700;
  font-size: 1.05rem;
}

.creature-genotype {
  font-size: 0.78rem;
  color: #b8c7ff;
  font-family: Consolas, monospace;
}

.selection-section {
  margin-bottom: 1.5rem;
}

.selection-section h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: #c5cae9;
}

.parent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.75rem;
}

.parent-card {
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 0.65rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.parent-card:hover {
  background: rgba(255, 255, 255, 0.1);
}

.parent-card.selected {
  border-color: #4fc3f7;
  background: rgba(79, 195, 247, 0.12);
}

.parent-card .creature-visual {
  width: 64px;
  height: 64px;
  margin: 0 auto 0.4rem;
}

.parent-card .creature-label {
  font-size: 0.85rem;
}

.feedback {
  border-radius: 12px;
  padding: 1rem;
  margin: 1rem 0;
  line-height: 1.5;
}

.feedback.success {
  background: rgba(76, 175, 80, 0.2);
  border: 1px solid rgba(76, 175, 80, 0.5);
}

.feedback.error {
  background: rgba(244, 67, 54, 0.18);
  border: 1px solid rgba(244, 67, 54, 0.45);
}

.feedback.info {
  background: rgba(79, 195, 247, 0.15);
  border: 1px solid rgba(79, 195, 247, 0.35);
}

.science-note {
  font-size: 0.85rem;
  color: #b0bddf;
  margin-top: 0.5rem;
}

.color-target-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.color-target-swatch {
  width: 120px;
  height: 120px;
  border-radius: 16px;
  border: 3px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.color-target-label {
  font-weight: 700;
  font-size: 1.05rem;
}

.mix-preview-panel {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 1rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.mix-preview-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: #c5cae9;
}

.color-mix-preview {
  width: 100%;
  max-width: 280px;
  height: 56px;
  margin: 0 auto 0.5rem;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.2s;
}

.color-mix-label {
  font-size: 0.85rem;
  color: #b8c7ff;
  font-family: Consolas, monospace;
}

.color-pool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.75rem;
}

.color-card {
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 0.55rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.color-card:hover {
  background: rgba(255, 255, 255, 0.1);
}

.color-card.selected {
  border-color: #ffd54f;
  background: rgba(255, 213, 79, 0.12);
}

.color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  margin-bottom: 0.35rem;
}

.color-name {
  font-size: 0.8rem;
  font-weight: 600;
}

@media (max-width: 600px) {
  h1 { font-size: 1.6rem; }
  .parent-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .chooser-grid { grid-template-columns: repeat(2, 1fr); }
  .chooser-row { grid-template-columns: repeat(2, 1fr); }
  .mcq-grid { grid-template-columns: 1fr; }
}

.chooser-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.chooser-category {
  margin: 1.25rem 0 0.5rem;
  font-size: 1.05rem;
  color: #ce93d8;
  text-align: left;
  grid-column: 1 / -1;
}

.chooser-category:first-child {
  margin-top: 0;
}

.chooser-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-bottom: 0.5rem;
}

.chooser-card {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 0.85rem 0.65rem;
  cursor: pointer;
  text-align: center;
  color: inherit;
  transition: transform 0.15s, border-color 0.15s;
}

.chooser-card:hover {
  transform: translateY(-3px);
  border-color: #ba68c8;
  background: rgba(186, 104, 200, 0.15);
}

.chooser-icon {
  font-size: 2rem;
  margin-bottom: 0.3rem;
}

.chooser-card h3 {
  margin: 0 0 0.25rem;
  font-size: 0.92rem;
}

.chooser-card p {
  margin: 0;
  font-size: 0.72rem;
  color: #b0bddf;
  line-height: 1.3;
}

.chooser-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.08);
}

.chooser-card.locked:hover {
  transform: none;
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.08);
}

.progress-panel {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 213, 79, 0.35);
  border-radius: 16px;
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
}

.progress-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.progress-rank {
  font-weight: 700;
  color: #ffe082;
}

.progress-points {
  font-size: 0.88rem;
  color: #b8c7ff;
}

.progress-bar-track {
  height: 10px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.45rem;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffd54f, #ba68c8);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.progress-next {
  font-size: 0.8rem;
  color: #9eb0e8;
  text-align: center;
}

.progress-auto-note {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  color: #9eb0e8;
  text-align: center;
  line-height: 1.35;
}

.save-panel {
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 0.85rem 1rem 1rem;
  margin-bottom: 1.25rem;
}

.save-panel summary {
  cursor: pointer;
  font-weight: 700;
  color: #c5cae9;
  list-style: none;
}

.save-panel summary::-webkit-details-marker {
  display: none;
}

.save-panel-desc {
  margin: 0.65rem 0 0.85rem;
  font-size: 0.85rem;
  color: #b0bddf;
  line-height: 1.45;
}

.save-panel label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0.5rem 0 0.35rem;
  color: #dce4ff;
}

.save-code-field,
.save-load-input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 0.82rem;
  font-family: Consolas, monospace;
}

.save-code-field {
  resize: vertical;
  min-height: 3rem;
}

.save-btn-row {
  margin: 0.5rem 0 0.25rem;
}

.save-reset-btn {
  font-size: 0.88rem;
}

.unlock-toast {
  background: linear-gradient(135deg, rgba(255, 213, 79, 0.25), rgba(186, 104, 200, 0.25));
  border: 2px solid rgba(255, 213, 79, 0.5);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  text-align: center;
  font-size: 0.92rem;
  line-height: 1.45;
  animation: toastIn 0.35s ease;
}

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

.ai-panel.ai-locked {
  opacity: 0.75;
}

.ai-lock-note {
  text-align: center;
  font-size: 0.88rem;
  color: #ffe082;
  margin: 0 0 0.75rem;
  line-height: 1.4;
}

.ai-panel {
  background: linear-gradient(135deg, rgba(186, 104, 200, 0.2), rgba(79, 195, 247, 0.15));
  border: 2px solid rgba(186, 104, 200, 0.45);
  border-radius: 16px;
  padding: 1.25rem;
  margin-top: 0.5rem;
}

.ai-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  text-align: center;
  color: #e1bee7;
}

.ai-panel-desc {
  text-align: center;
  font-size: 0.88rem;
  color: #b8c7ff;
  margin: 0 0 1rem;
}

.ai-panel label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.ai-panel input[type="text"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.ai-type-row {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.ai-type-row label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  font-weight: normal;
}

.mcq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.65rem;
}

.mcq-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  color: #f0f4ff;
  text-align: left;
  font-size: 0.88rem;
}

.mcq-option:hover {
  background: rgba(255, 255, 255, 0.1);
}

.mcq-option.selected {
  border-color: #ffd54f;
  background: rgba(255, 213, 79, 0.12);
}

.mcq-num {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.mcq-label {
  flex: 1;
}

.mcq-swatches {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.mcq-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.mcq-plus {
  font-size: 0.75rem;
  color: #b0bddf;
}

.mix-preview-panel.compact {
  margin: 0.75rem 0 0;
  padding: 0.65rem;
}

.mix-preview-panel.compact .color-mix-preview {
  height: 40px;
  max-width: 100%;
}

.combine-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  width: 22px;
  height: 22px;
}

.combine-visual {
  border-radius: 16px !important;
  width: 100px !important;
  height: 100px !important;
}

.breeding-hint {
  margin: 0.35rem 0 0.5rem;
  font-size: 0.85rem;
  color: #b0bddf;
  text-align: center;
}

.breed-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  margin-bottom: 1rem;
  min-height: 4rem;
}

.breed-card {
  width: 108px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 0.35rem;
  cursor: grab;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  user-select: none;
  touch-action: manipulation;
}

.breed-card:hover {
  transform: translateY(-3px);
  border-color: #ba68c8;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.breed-card.dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.breed-card-inner {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.breed-card-photo,
.creature-photo {
  background: #1a1a2e;
}

.breed-card-photo {
  width: 100%;
  height: 72px;
  object-fit: cover;
  object-position: center top;
  border-radius: 10px;
  pointer-events: none;
  display: block;
}

.breed-card-fallback {
  width: 100%;
  height: 72px;
  border-radius: 10px;
}

.breed-card-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  text-align: center;
}

.breed-sex-badge {
  font-size: 0.68rem;
  color: #ce93d8;
  font-weight: 700;
}

.breed-card-label {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  color: #e8eaf6;
}

.breeding-pen {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 0.5rem 0 1rem;
  padding: 1rem;
  background: rgba(186, 104, 200, 0.12);
  border: 2px dashed rgba(186, 104, 200, 0.45);
  border-radius: 18px;
}

.pen-slot {
  width: 118px;
  min-height: 118px;
  background: rgba(0, 0, 0, 0.22);
  border: 2px dashed rgba(255, 255, 255, 0.25);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  transition: border-color 0.15s, background 0.15s;
}

.pen-slot.pen-hover {
  border-color: #ffd54f;
  background: rgba(255, 213, 79, 0.1);
}

.pen-slot.filled {
  border-style: solid;
  border-color: #4fc3f7;
  background: rgba(79, 195, 247, 0.08);
  cursor: pointer;
}

.pen-slot.filled .breed-card-inner {
  width: 100%;
}

.pen-slot.filled .breed-card-photo,
.pen-slot.filled .breed-card-fallback {
  height: 68px;
  width: 100%;
  object-fit: cover;
  object-position: center top;
  background: #1a1a2e;
  border-radius: 10px;
}

.pen-placeholder {
  font-size: 0.72rem;
  color: #9eb0e8;
  text-align: center;
  padding: 0.5rem;
  line-height: 1.35;
}

.pen-heart {
  font-size: 1.6rem;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .breeding-pen {
    flex-wrap: wrap;
  }
  .pen-heart {
    width: 100%;
    text-align: center;
  }
}
