/* ---- Birdle Styles — Clean Minimal ---- */
:root {
  --bg: #f5f5f0;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --text: #1a1a1a;
  --text-dim: #6b7280;
  --accent: #2d6a4f;
  --match: #2d6a4f;
  --partial: #d4a017;
  --miss: #e8e8e3;
  --border: #d4d4cc;
  --radius: 8px;
  --logo-color: #2d6a4f;
  --svg-stroke: #2d6a4f;
  --svg-fill: #2d6a4f;
  --highlight-hover: #f0f0ea;
  --row-border: #eee;
  --dot-border: #ccc;
  --shadow-overlay: rgba(0, 0, 0, 0.3);
  --shadow-card: rgba(0, 0, 0, 0.06);
  --shadow-modal: rgba(0, 0, 0, 0.12);
  --shadow-suggest: rgba(0,0,0,0.08);
}

[data-theme="dark"] {
  --bg: #1e1e1e;
  --bg-card: #2a2a2a;
  --bg-input: #333333;
  --text: #e0e0e0;
  --text-dim: #999999;
  --accent: #4ade80;
  --match: #22c55e;
  --partial: #eab308;
  --miss: #333333;
  --border: #444444;
  --logo-color: #4ade80;
  --svg-stroke: #4ade80;
  --svg-fill: #4ade80;
  --highlight-hover: #383838;
  --row-border: #3a3a3a;
  --dot-border: #555555;
  --shadow-overlay: rgba(0, 0, 0, 0.6);
  --shadow-card: rgba(0, 0, 0, 0.2);
  --shadow-modal: rgba(0, 0, 0, 0.4);
  --shadow-suggest: rgba(0,0,0,0.3);
}

[data-theme="dark"] .logo-icon svg {
  stroke: var(--svg-stroke);
}
[data-theme="dark"] .logo-icon svg circle[fill],
[data-theme="dark"] .logo-icon svg [fill]:not([fill="none"]) {
  fill: var(--svg-fill);
}

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---- Header ---- */
header {
  width: 100%;
  max-width: 1100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 30px;
  line-height: 1;
  display: flex;
  align-items: center;
}

.logo-img {
  height: 48px;
  width: auto;
  mix-blend-mode: multiply;
}

[data-theme="dark"] .logo-img {
  mix-blend-mode: screen;
  filter: invert(1) brightness(1.2);
}

.logo h1 {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--text);
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--highlight-hover);
  border-color: var(--text-dim);
}

/* ---- Main ---- */
main {
  width: 100%;
  max-width: 1100px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* ---- Input area ---- */
.input-area {
  width: 100%;
  max-width: 480px;
  display: flex;
  gap: 10px;
  position: relative;
}

#guess-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 15px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#guess-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

#guess-input::placeholder {
  color: var(--text-dim);
}

#guess-input.shake {
  animation: shake 0.4s ease;
  border-color: #dc2626;
}

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

#guess-btn {
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  white-space: nowrap;
}

#guess-btn:hover {
  opacity: 0.9;
}

#guess-btn:active {
  transform: scale(0.97);
}

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

/* ---- Suggestions ---- */
#suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 80px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 240px;
  overflow-y: auto;
  z-index: 100;
  display: none;
  box-shadow: 0 4px 12px var(--shadow-suggest);
}

#suggestions.active {
  display: block;
}

.suggestion-item {
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.suggestion-item:hover,
.suggestion-item.highlighted {
  background: var(--highlight-hover);
  color: var(--accent);
}

.suggestion-item.eliminated {
  opacity: 0.45;
}

.suggestion-item.eliminated .suggestion-name {
  text-decoration: line-through;
  text-decoration-color: currentColor;
  text-decoration-thickness: 1px;
}

.suggestion-item.eliminated:hover,
.suggestion-item.eliminated.highlighted {
  opacity: 0.75;
}

.suggestion-x {
  font-size: 11px;
  opacity: 0.7;
  margin-left: 8px;
  flex-shrink: 0;
}

/* ---- Info strip ---- */
.info-strip {
  display: flex;
  gap: 24px;
  align-items: center;
  font-size: 14px;
  color: var(--text-dim);
}

.info-strip strong {
  color: var(--text);
}

/* ---- Guesses table ---- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.guesses-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 5px;
  font-size: 13px;
  min-width: 900px;
}

.guesses-table thead th {
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}

.guesses-table td {
  padding: 9px 10px;
  background: var(--bg-card);
  white-space: nowrap;
  border-top: 1px solid var(--row-border);
  border-bottom: 1px solid var(--row-border);
}

.guesses-table tr td:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
  border-left: 1px solid var(--row-border);
}

.guesses-table tr td:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-right: 1px solid var(--row-border);
}

/* Cell states */
td.match {
  background: var(--match) !important;
  color: #fff;
  font-weight: 600;
  border-color: var(--match) !important;
}

td.partial {
  background: var(--partial) !important;
  color: #fff;
  font-weight: 600;
  border-color: var(--partial) !important;
}

td.miss {
  background: var(--bg-card);
}

.heat-cell {
  font-weight: 700;
  text-align: center;
  min-width: 58px;
  border-radius: var(--radius) 0 0 var(--radius) !important;
}

.name-cell {
  font-weight: 600;
  min-width: 150px;
}

/* Color dots */
.color-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right: 3px;
  vertical-align: middle;
  border: 1.5px solid var(--dot-border);
}

.color-dot.color-match {
  border-color: var(--match);
  box-shadow: 0 0 5px color-mix(in srgb, var(--match) 50%, transparent);
}

/* Row animation */
.guess-row.fade-in {
  animation: fadeSlideIn 0.3s ease;
}

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

/* ---- Result panel ---- */
.result-panel {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px;
  background: var(--bg-card);
  border: 2px solid var(--match);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 2px 12px var(--shadow-card);
}

.result-panel.active {
  display: flex;
}

.bird-image-wrap {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.bird-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.bird-image.loaded {
  display: block;
}

.bird-image-placeholder {
  font-size: 13px;
  color: var(--text-dim);
}

.bird-image.loaded + .bird-image-placeholder {
  display: none;
}

.result-panel h2 {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-top: 4px;
}

#result-message {
  font-size: 15px;
}

#result-fact {
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
}

#share-btn {
  padding: 10px 28px;
  font-size: 14px;
  font-weight: 600;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.2s;
}

#share-btn:hover {
  opacity: 0.85;
}

.share-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--match);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-weight: 600;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 999;
}

.share-toast.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ---- Modals ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--shadow-overlay);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 28px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 8px 30px var(--shadow-modal);
}

.modal h2 {
  font-size: 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal p,
.modal li {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-dim);
}

.modal ul {
  padding-left: 20px;
  margin: 10px 0;
}

.close-modal {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
}

.close-modal:hover {
  color: var(--text);
}

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.legend-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-box {
  text-align: center;
}

.stat-box .num {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.stat-box .label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.dist-label {
  width: 20px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.dist-bar-wrap {
  flex: 1;
}

.dist-bar {
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  min-width: 24px;
}

/* Smooth transition for theme switch */
body,
header,
main,
.modal,
#guess-input,
#suggestions,
.guesses-table td,
.guesses-table thead th,
.icon-btn,
.result-panel,
.logo h1 {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  header {
    padding: 14px 16px;
  }

  .logo h1 {
    font-size: 24px;
  }

  .logo-icon {
    font-size: 24px;
  }

  main {
    padding: 16px 12px;
  }

  .input-area {
    max-width: 100%;
  }

  #guess-btn {
    padding: 12px 16px;
  }

  .guesses-table {
    font-size: 12px;
  }

  .info-strip {
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
  }
}
