:root {
  --bg: #06241a;
  --surface: #0c382a;
  --panel: #144d3b;
  --line: #1e6d54;
  --text: #f0fdf4;
  --muted: #a7f3d0;
  --emerald: #10b981;
  --lime: #84cc16;
  --gold: #f59e0b;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Lexend", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--surface);
  border-bottom: 2px solid var(--line);
  padding: 0.75rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  font-size: 2rem;
  background: linear-gradient(135deg, #10b981, #047857);
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.brand h1 {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
}

.brand p {
  font-size: 0.8rem;
  color: var(--muted);
}

.controls-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.controls-bar select {
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: #fff;
  cursor: pointer;
  outline: none;
}

.btn-header {
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-header:hover {
  background: var(--emerald);
  border-color: var(--emerald);
}

main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* Eco Banner */
.eco-banner {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 0.8rem 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.eco-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.eco-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
}

.eco-val {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
}

.habitat-info-box {
  flex: 1;
  text-align: center;
}

.hab-tag {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--lime);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hab-mission {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
}

.eco-streak {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--lime);
}

/* Arena */
.habitat-arena {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 22px;
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

/* Food Chain Slots Row */
.chain-stage {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  align-items: center;
}

.chain-slots-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  width: 100%;
}

.chain-slot-box {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  min-width: 150px;
  flex: 1;
  max-width: 190px;
}

.slot-role-tag {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--lime);
}

.drop-zone {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #06241a;
  border: 2px dashed #1e6d54;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.drop-zone:hover {
  border-color: var(--lime);
  background: #0c382a;
}

.zone-placeholder {
  font-size: 0.78rem;
  color: #64748b;
  font-style: italic;
}

.chain-arrow {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--lime);
}

.chain-actions {
  display: flex;
  gap: 0.8rem;
}

.btn-action {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 800;
  padding: 0.75rem 1.8rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
  transition: all 0.2s;
}

.btn-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-subaction {
  font-family: var(--body);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.75rem 1.4rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: #fff;
  cursor: pointer;
}

/* Pool Cards */
.pool-section {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.pool-title {
  font-size: 0.82rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
}

.organisms-rack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  justify-content: center;
}

.org-card {
  background: #ffffff;
  border: 2px solid #a7f3d0;
  border-radius: 14px;
  padding: 0.6rem 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-width: 130px;
  max-width: 160px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.org-card:hover {
  transform: translateY(-4px) scale(1.06);
  border-color: var(--emerald);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

.org-card.selected {
  border-color: var(--gold);
  background: #fefce8;
}

.org-card.placed {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.card-emoji {
  font-size: 2.4rem;
}

.card-name-ga {
  font-family: var(--display);
  font-size: 0.92rem;
  font-weight: 800;
  color: #064e3b;
}

.card-name-en {
  font-size: 0.78rem;
  color: #4b5563;
}

/* Classification Stage */
.classify-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
}

.target-organism-card {
  background: var(--panel);
  border: 2px solid var(--emerald);
  border-radius: 18px;
  padding: 1.2rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  max-width: 540px;
  width: 100%;
}

.org-emoji {
  font-size: 4rem;
}

.org-title {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
}

.org-sub {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.4;
}

.classify-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.8rem;
  width: 100%;
  max-width: 600px;
}

.btn-class-choice {
  font-family: var(--body);
  font-size: 1.05rem;
  font-weight: 700;
  padding: 1rem 1.4rem;
  border-radius: 14px;
  background: var(--panel);
  border: 2px solid var(--line);
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-class-choice:hover {
  border-color: var(--lime);
  background: #1c634d;
}

.btn-class-choice.correct {
  background: #064e3b;
  border-color: var(--emerald);
  color: #a7f3d0;
}

.btn-class-choice.wrong {
  background: #7f1d1d;
  border-color: #ef4444;
  color: #fecaca;
}

/* Eco Fact Card */
.fact-card {
  background: linear-gradient(135deg, #047857, #064e3b);
  border: 2px solid var(--lime);
  border-radius: 14px;
  padding: 0.9rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  animation: popIn 0.3s ease-out;
}

.fact-icon {
  font-size: 2.2rem;
}

.fact-body {
  font-size: 0.95rem;
  color: #f0fdf4;
  line-height: 1.5;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 36, 26, 0.85);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--surface);
  border: 3px solid var(--lime);
  border-radius: 22px;
  padding: 2.2rem 2rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}

.modal-card h2 {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 800;
  color: #fff;
}

.modal-card p {
  color: var(--muted);
  margin: 0.6rem 0 1.2rem;
}

.badge-award {
  background: var(--panel);
  border: 2px solid var(--gold);
  padding: 0.8rem 1.4rem;
  border-radius: 12px;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 1.5rem;
}

.modal-btn {
  font-family: var(--body);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.8rem 1.8rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}
