:root {
  --green: #16a765;
  --green-dark: #0e7a4a;
  --red: #ef4060;
  --earth: #b46a3c;
  --sky: #2f9bdb;
  --accent: #ffb703;
  --accent-dark: #f18f01;
  --bg: #f2f7f3;
  --card-bg: #ffffff;
  --text: #1e2a26;
  --text-muted: #5b6b65;
  --font-heading: "Fredoka", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  margin: 0;
  background:
    radial-gradient(circle at 0% 0%, #eaf7ef 0%, transparent 45%),
    radial-gradient(circle at 100% 0%, #fef6e6 0%, transparent 45%),
    var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

header {
  flex-shrink: 0;
  background: var(--card-bg);
  box-shadow: 0 2px 10px rgba(20, 40, 30, 0.08);
  position: relative;
  z-index: 10;
}

.header-bar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-emoji {
  font-size: 2rem;
  line-height: 1;
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--green-dark);
}

.brand-text p {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

#main-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 1.1rem;
}

#main-nav button {
  padding: 0.3rem 0.05rem;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

#main-nav button:hover {
  color: var(--green-dark);
}

#main-nav button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

@media (max-width: 640px) {
  .header-bar {
    justify-content: center;
    text-align: center;
    padding: 0.4rem 0.7rem;
  }

  .brand {
    justify-content: center;
  }

  .brand-emoji {
    font-size: 1.5rem;
  }

  .brand-text h1 {
    font-size: 1.05rem;
  }

  .brand-text p {
    display: none;
  }

  #main-nav {
    width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    gap: 0.9rem;
    -webkit-overflow-scrolling: touch;
  }

  #main-nav button {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.82rem;
  }
}

.tab-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tab-panel:not(#tab-jugar):not(#tab-estadisticas) {
  max-width: 560px;
  width: 100%;
  margin: 0.8rem auto;
  padding: 1.1rem 1.3rem;
  overflow-y: auto;
  display: block;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(20, 40, 30, 0.08);
}

#tab-estadisticas {
  max-width: 480px;
  width: 100%;
  margin: 0.6rem auto;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--card-bg);
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(20, 40, 30, 0.1);
}

#tab-estadisticas h2 {
  flex-shrink: 0;
  margin-bottom: 0.4rem;
  font-size: 1.15rem;
}

.stats-sections {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}

.stats-block {
  flex: 0 0 auto;
}

.tab-panel:not(#tab-jugar) h2 {
  margin-top: 0;
  font-family: var(--font-heading);
  color: var(--green-dark);
}

.tab-panel:not(#tab-jugar) h3 {
  margin-bottom: 0.2rem;
  font-size: 0.95rem;
  color: var(--sky);
  font-weight: 800;
}

.tab-panel:not(#tab-jugar) p {
  margin-top: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
}

.stats-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.8rem;
}

.stats-kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.8rem;
  background: var(--bg);
  border-radius: 14px;
  text-align: center;
}

.stats-kpi-value {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  color: var(--green-dark);
  line-height: 1.1;
}

.stats-kpi-label {
  font-size: clamp(0.72rem, 1.4vw, 0.9rem);
  line-height: 1.2;
  color: var(--text-muted);
}

.stats-section-title {
  margin: 0.6rem 0 0.3rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
}

.stats-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
}

#contact-form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

#contact-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 600;
  font-size: 0.9rem;
}

#contact-form input,
#contact-form textarea {
  font: inherit;
  padding: 0.5rem;
  border: 2px solid #dde5df;
  border-radius: 8px;
}

#contact-form input:focus,
#contact-form textarea:focus {
  outline: none;
  border-color: var(--sky);
}

#contact-form textarea {
  min-height: 6rem;
  resize: vertical;
}

#contact-form button {
  align-self: flex-start;
  padding: 0.55rem 1.3rem;
  border: none;
  border-radius: 10px;
  background: var(--green-dark);
  color: white;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s ease;
}

#contact-form button:hover {
  transform: translateY(-1px);
}

#contact-status {
  font-size: 0.85rem;
}

main {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 0.5rem 1rem;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#hud {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--green-dark);
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

#game-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#bird-image {
  display: block;
  width: 100%;
  flex: 0 0 auto;
  height: 42vh;
  min-height: 220px;
  object-fit: contain;
  border-radius: 12px;
  background: #ddd;
}

#answer-area {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

#options {
  display: grid;
  gap: 0.55rem;
  flex-shrink: 0;
}

@media (min-width: 640px), (orientation: landscape) {
  main {
    max-width: 800px;
  }

  #game-body {
    flex-direction: row;
    align-items: stretch;
  }

  #bird-image {
    flex: 1 1 55%;
    width: auto;
    min-width: 0;
    height: 100%;
  }

  #answer-area {
    flex: 1 1 45%;
    justify-content: center;
    overflow-y: auto;
  }
}

.option-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.option-row button {
  flex: 1 1 auto;
}

.ebird-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  font-size: 1.1rem;
  text-decoration: none;
  background: #eef4f0;
  border: 2px solid #dde5df;
}

#options button {
  padding: 0.75rem 1.1rem;
  border-radius: 10px;
  border: 2px solid #dde5df;
  background: white;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.1rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
  width: 100%;
}

#options button:hover:not(:disabled) {
  border-color: var(--sky);
  transform: translateY(-1px);
}

#options button:disabled {
  cursor: default;
}

#options button.correct {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

#options button.incorrect {
  background: var(--red);
  border-color: var(--red);
  color: white;
}

#expert-answer-area {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#expert-answer-input {
  font: inherit;
  font-size: 1.1rem;
  padding: 0.7rem 0.9rem;
  border: 2px solid #dde5df;
  border-radius: 10px;
}

#expert-answer-input:focus {
  outline: none;
  border-color: var(--sky);
}

#expert-answer-input.correct {
  border-color: var(--green);
  background: #eafbf1;
}

#expert-answer-input.incorrect {
  border-color: var(--red);
  background: #fdeef1;
}

#expert-submit-button {
  padding: 0.65rem 1.6rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green), var(--sky));
  color: white;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(22, 167, 101, 0.35);
}

#expert-submit-button:disabled {
  opacity: 0.6;
  cursor: default;
}

#expert-answer-feedback {
  margin: 0;
  font-weight: 700;
}

#report-section {
  flex-shrink: 0;
  margin-top: 0.4rem;
}

#report-toggle-button {
  display: block;
  margin: 0 auto;
  padding: 0.3rem 0.7rem;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
}

#report-toggle-button:disabled {
  cursor: default;
  opacity: 0.7;
}

#report-panel {
  max-width: 320px;
  margin: 0.4rem auto 0;
  padding: 0.8rem;
  background: #f7faf7;
  border: 2px solid #dde5df;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#report-category-fieldset {
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

#report-category-fieldset legend {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--green-dark);
  padding: 0;
}

#report-category-fieldset label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 400;
}

#report-note {
  font: inherit;
  padding: 0.45rem;
  border: 2px solid #dde5df;
  border-radius: 8px;
  font-size: 0.85rem;
}

#report-note:focus {
  outline: none;
  border-color: var(--sky);
}

.report-actions {
  display: flex;
  gap: 0.5rem;
}

#report-submit-button {
  flex: 1 1 auto;
  padding: 0.45rem 0.9rem;
  border: none;
  border-radius: 8px;
  background: var(--green-dark);
  color: white;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

#report-submit-button:disabled {
  opacity: 0.6;
  cursor: default;
}

#report-cancel-button {
  padding: 0.45rem 0.9rem;
  border: 2px solid #dde5df;
  border-radius: 8px;
  background: white;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
}

#report-status {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.score-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.score-card-brand {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--green-dark);
}

.score-card-date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.score-card-daily-badge {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 700;
}

.score-card-message {
  margin: 0.3rem 0 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}

.score-card-grid {
  margin-top: 0.7rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.9rem;
}

.score-card-item {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.score-card-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 12px;
  border: 3px solid transparent;
  background: #ddd;
}

.score-card-item.correct img {
  border-color: var(--green);
}

.score-card-item.incorrect img {
  border-color: var(--red);
}

.score-card-item figcaption {
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.25;
}

#end-screen-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.6rem;
  flex-shrink: 0;
}

#share-button {
  flex: 1 1 0;
  padding: 0.6rem 1rem;
  border: 2px solid var(--accent-dark);
  border-radius: 10px;
  background: var(--accent);
  color: var(--text);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s ease;
}

#share-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

#share-button:disabled {
  opacity: 0.6;
  cursor: default;
}

#share-status {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

#next-button {
  display: block;
  margin: 0.6rem auto 0;
  padding: 0.65rem 1.6rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green), var(--sky));
  color: white;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(22, 167, 101, 0.35);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

#restart-button {
  flex: 1 1 0;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green), var(--sky));
  color: white;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(22, 167, 101, 0.35);
  transition: transform 0.15s ease;
}

#next-button:hover,
#restart-button:hover {
  transform: translateY(-1px);
}

#setup-screen {
  max-width: 480px;
  width: 100%;
  margin: 0.6rem auto;
  padding: 1.1rem;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
  background: var(--card-bg);
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(20, 40, 30, 0.1);
}

#setup-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

#setup-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 600;
}

#setup-form select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font: inherit;
  padding: 0.5rem 1.9rem 0.5rem 0.5rem;
  border: 2px solid #dde5df;
  border-radius: 8px;
  background: white
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235b6b65' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat right 0.7rem center;
  background-size: 0.7rem;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

#setup-form select:focus {
  outline: none;
  border-color: var(--sky);
}

.setup-checklist {
  border: 2px solid #dde5df;
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

#setup-form .setup-checklist label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
}

#setup-name-mode-error {
  color: var(--red);
  font-size: 0.85rem;
  margin: 0;
}

#setup-pool-warning {
  margin: 0;
  font-size: 0.85rem;
  color: var(--red);
  font-weight: 600;
}

.setup-buttons {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

#setup-form button:disabled {
  opacity: 0.5;
  cursor: default;
}

#setup-form button[type="submit"] {
  flex: 1 1 auto;
  padding: 0.65rem 1.6rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green), var(--sky));
  color: white;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(22, 167, 101, 0.35);
  transition: transform 0.15s ease;
}

#setup-form button:not(:disabled):hover {
  transform: translateY(-1px);
}

#daily-quiz-section {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 2px solid #eef3ee;
  text-align: center;
}

#daily-quiz-button {
  padding: 0.6rem 1.4rem;
  border: 2px solid var(--accent-dark);
  border-radius: 10px;
  background: var(--accent);
  color: var(--text);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s ease;
}

#daily-quiz-button:not(:disabled):hover {
  transform: translateY(-1px);
}

#daily-quiz-button:disabled {
  opacity: 0.6;
  cursor: default;
}

#daily-quiz-status,
#daily-quiz-streak {
  margin: 0.3rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

#end-screen {
  max-width: 720px;
  width: 100%;
  margin: 1rem auto;
  padding: 1.3rem;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--card-bg);
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(20, 40, 30, 0.1);
}

#share-button,
#restart-button {
  text-align: center;
}

