/* ============================================================
   PORTLAND BIRDS — GRID TABLE VERSION
   @import must be first for fonts to load properly
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600&display=swap');

:root {
  --pb-bg: #f5f7fb;
  --pb-card-bg: #ffffff;
  --pb-border: #dde1ee;
  --pb-primary: #4a72c9;
  --pb-primary-soft: #edf2ff;
  --pb-text: #222638;
  --pb-muted: #70758a;
  --pb-gray-filled: #6b7280;
  --pb-gray-empty: #d0d4d8;
  --pb-row-shadow: 0 8px 28px rgba(0,0,0,0.18);
}

/* ============================================================
   RESET / GLOBAL
============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top left, #f2f2f2 0%, #ffffff 70%);
  font-family: 'Montserrat', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 24px;
  color: var(--pb-text);
  -webkit-text-size-adjust: 100%;
  touch-action: pan-y;
  overscroll-behavior: none;
}

html {
  overflow-y: scroll;
}

.pb-page {
  max-width: 1250px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  touch-action: pan-y;
}

/* ============================================================
   HEADER
============================================================ */

.pb-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.pb-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pb-logo {
  max-width: 100%;
  height: auto;
  display: block;
}

.pb-title {
  margin: 0;
  font-size: clamp(1.1rem, 1.5vw, 1.3rem);
}

.pb-subtitle {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--pb-muted);
}

/* ============================================================
   VIEW TOGGLE BUTTONS
============================================================ */

.pb-view-toggle {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #d0d4da;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.pb-view-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-size: 0.9rem;
  color: #6a6f7a;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.pb-view-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.pb-view-btn.active {
  background: var(--pb-primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

/* ============================================================
   CONTROLS BAR
============================================================ */

.pb-controls {
  background: #ffffff;
  border-radius: 18px;
  border: 1px solid var(--pb-border);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  padding: 15px 18px;
  margin-bottom: 20px;
}

.pb-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.pb-search-group {
  display: flex;
  gap: 8px;
  flex: 1;
  align-items: center;
}

.pb-search-input {
  flex: 0 1 400px;
  max-width: 400px;
  padding: 9px 12px;
  border-radius: 999px;
  background: #f9fafb;
  border: 1px solid var(--pb-border);
  font-size: 1rem;
}

.pb-top-right {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 0.85rem;
  color: #4b5563;
}

.pb-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.pb-checkbox input {
  cursor: pointer;
}

.pb-checkbox span {
  font-size: 0.85rem;
  color: #4b5563;
}

#sortSelect,
#sortSelect option,
.pb-result-count {
  font-size: 0.85rem;
  color: #4b5563;
}

#sortSelect {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--pb-border);
  background: #ffffff;
  cursor: pointer;
}

.pb-result-count {
  white-space: nowrap;
}

/* ============================================================
   GALLERY SIZE SELECTOR
============================================================ */

.pb-gallery-size-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pb-gallery-size-label {
  font-size: 0.85rem;
  color: #4b5563;
}

.pb-gallery-size-toggle {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: #f3f4f6;
  border: 1px solid var(--pb-border);
}

.pb-size-btn {
  padding: 4px 12px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-size: 0.85rem;
  color: #6a6f7a;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.pb-size-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.pb-size-btn.active {
  background: var(--pb-primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

/* ============================================================
   GRID TABLE WRAPPER
============================================================ */

.pb-table-grid {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  overflow: visible;
}

/* ============================================================
   TABLE ROWS - with visible bottom borders
============================================================ */

.pb-row.header {
  display: grid;
  grid-template-columns:
    200px 140px 70px 1fr 145px;
  gap: 20px;
  padding: 0 20px;
  background: #f0f2f6;
  border-bottom: 1px solid #e0e3ea;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 18px 18px 0 0;
  align-items: center;
  min-height: 44px;
}

.pb-row.header .pb-cell {
  padding: 0;
  display: flex;
  align-items: center;
  height: 100%;
}

.pb-row {
  display: grid;
  grid-template-columns:
    200px 140px 70px 1fr 145px;
  gap: 20px;
  padding: 0 20px;
  align-items: center;
  background: #ffffff;
  transition: all 0.25s ease;
  position: relative;
  cursor: pointer;
  border-bottom: 1px solid #e5e7eb;
  border-left: 1px solid transparent;
  border-right: 1px solid transparent;
  border-top: 1px solid transparent;
  min-height: 114px;
  touch-action: pan-y;

  /* allow thumbnail growth */
  overflow: visible;
}

.pb-row:hover {
  background: #ffffff;
  box-shadow: var(--pb-row-shadow);
  z-index: 5;
  border-radius: 14px;
  border: 1px solid transparent;
}

/* Desktop click effect - compress then release */
.pb-row.pressed {
  transform: scale(0.98);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.pb-row.releasing {
  transform: scale(1);
  box-shadow: var(--pb-row-shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pb-cell {
  padding: 12px 0;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
}

/* Name column - no wrapping */
.pb-cell:first-child {
  white-space: nowrap;
}

/* Thumbnail */
.pb-thumb {
  width: 120px;
  height: 90px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  margin-left: 0;
}



/* Last row rounded bottom corners */
.pb-row:last-child {
  border-radius: 0 0 18px 18px;
  border-bottom: none;
}

/* Size dots */
.pb-size-dots {
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  white-space: nowrap;
}

.pb-size-dots .filled {
  color: var(--pb-gray-filled);
}

.pb-size-dots .empty {
  color: var(--pb-gray-empty);
}

/* ============================================================
   GALLERY (4-CARD LAYOUT - default)
============================================================ */

.pb-gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.pb-gallery-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.pb-gallery-grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

/* Adjust card image heights based on column count */
.pb-gallery-grid .pb-card-img {
  height: 200px;
}

.pb-gallery-grid.cols-3 .pb-card-img {
  height: 280px;
}

.pb-gallery-grid.cols-2 .pb-card-img {
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: linear-gradient(to bottom, #f5f5f5, #fafafa);
}

.pb-card {
  background: #ffffff;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  cursor: pointer;
  overflow: hidden;
  touch-action: pan-y;
}

.pb-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 38px rgba(0,0,0,0.2);
}

.pb-card-img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.pb-card-body {
  padding: 11px;
}

.pb-card-title {
  margin: 0 0 6px 0;
  font-size: 1rem;
  color: #111827;
  font-weight: 500;
}

.pb-card-description {
  margin: 0;
  font-size: 0.85rem;
  color: #4b5563;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pb-card-season {
  margin: 0 0 6px 0;
  font-size: 0.85rem;
  color: #6b7280;
}

.pb-card-text {
  margin: 0 0 8px 0;
  font-size: 0.9rem;
  color: #4b5563;
}

/* ============================================================
   MODAL
============================================================ */

.pb-modal.hidden {
  display: none;
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

.pb-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  z-index: 50;
}

.pb-polaroid {
  margin: auto;
  background: #ffffff;
  padding: 16px;
  border-radius: 16px;
  width: calc(100% - 32px);
  max-width: 1200px;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  position: relative;
}

.pb-modal-img,
.pb-modal-video {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  object-fit: contain;
  object-position: top left;
  opacity: 1;
  display: block;
  background: #f9fafb;
  border: 1px solid #d1d5db;
}

.pb-modal-video {
  background: #f9fafb;
}

.pb-modal-video.hidden,
.pb-modal-img.hidden {
  opacity: 0;
}

.pb-media-container {
  position: relative;
  width: 100%;
  height: 575px;
  overflow: hidden;
  background: #f9fafb;
  border-radius: 12px;
}

.pb-media-container .pb-modal-img,
.pb-media-container .pb-modal-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 575px;
  object-fit: contain;
  object-position: top center;
  border-radius: 12px;
  transform: translate3d(0, 0, 0);
  -webkit-transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  margin: 0;
  padding: 0;
}

.pb-polaroid-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#modalTitle {
  margin: 0;
  font-size: 1.3rem;
}

#modalMeta {
  font-size: 0.9rem;
  color: #4b5563;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#modalMeta .pb-size-dots {
  margin-left: 4px;
}

#modalMeta .pb-size-dots .filled {
  color: var(--pb-gray-filled);
}

#modalMeta .pb-size-dots .empty {
  color: var(--pb-gray-empty);
}

#modalDescription {
  margin: 6px 0 10px 0;
  font-size: 0.95rem;
  color: #374151;
}

.pb-modal-nav {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.pb-modal-nav button {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  cursor: pointer;
  font-size: 0.9rem;
  color: #374151;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.pb-modal-nav button:hover {
  background: #e5e7eb;
}

.pb-modal-nav button:active {
  opacity: 0.6;
  background: #d1d5db;
}

.pb-modal-nav button:focus {
  outline: none;
}

.pb-modal-nav button.hidden {
  display: none;
}

/* Remove hover state persistence on touch devices */
@media (hover: none) {
  .pb-modal-nav button:hover {
    background: #f9fafb;
  }
  
  .pb-modal-nav button:active {
    background: #d1d5db;
    opacity: 0.6;
  }
}

.pb-close-btn {
  position: absolute;
  right: 10px;
  top: 9px;
  width: 28px;
  height: 28px;
  background: rgba(31, 41, 55, 0.85);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 100;
}

.pb-close-btn::before,
.pb-close-btn::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 2px;
  background: #ffffff;
  top: 50%;
  left: 50%;
}

.pb-close-btn::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.pb-close-btn::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* ============================================================
   RESPONSIVE
============================================================ */

@media (max-width: 1100px) {
  .pb-gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .pb-gallery-grid.cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  /* Hide 4-column option on smaller screens */
  .pb-size-btn[data-cols="4"] {
    display: none;
  }
}

@media (max-width: 800px) {
  .pb-gallery-grid,
  .pb-gallery-grid.cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  .pb-gallery-grid.cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  /* Hide 3 and 4 column options */
  .pb-size-btn[data-cols="3"],
  .pb-size-btn[data-cols="4"] {
    display: none;
  }
}

@media (max-width: 480px) {
  .pb-gallery-grid,
  .pb-gallery-grid.cols-3,
  .pb-gallery-grid.cols-2 {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  /* Match ID Wizard result-card styling */
  .pb-card {
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  }
  
  /* Match ID Wizard result-card-img styling - must override .pb-gallery-grid .pb-card-img */
  .pb-gallery-grid .pb-card-img,
  .pb-gallery-grid.cols-3 .pb-card-img,
  .pb-gallery-grid.cols-2 .pb-card-img,
  .pb-card-img {
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: #f3f4f6;
  }
  
  .pb-card-body {
    padding: 14px;
  }
  
  /* Hide entire gallery size control on mobile */
  .pb-gallery-size-control {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .pb-logo {
    max-width: 50%;
  }
  
  .pb-top-row {
    flex-direction: column;
    align-items: stretch;
  }

  /* On mobile, search group takes full width and includes result count */
  .pb-search-group {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
    gap: 8px;
    align-items: center;
  }

  .pb-search-input {
    flex: 1;
    min-width: 0;
    max-width: calc(100% - 140px);
  }

  /* Hide result count from top-right on mobile */
  .pb-top-right .pb-result-count {
    display: none;
  }

  /* Mobile result count shown next to Clear button */
  .pb-result-count-mobile {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: #4b5563;
    white-space: nowrap;
  }

  .pb-row.header,
  .pb-row {
    grid-template-columns:
      33% 42% 25%;
    gap: 8px;
    padding: 0 10px;
  }

  .pb-row.header {
    padding: 10px 10px;
  }

  /* Hide description column in mobile */
  .pb-row .pb-cell:nth-child(4) {
    display: none;
  }
  
  .pb-row.header .pb-cell:nth-child(4) {
    display: none;
  }

  /* Hide season column (5th column) in mobile */
  .pb-row .pb-cell:nth-child(5) {
    display: none;
  }
  
  .pb-row.header .pb-cell:nth-child(5) {
    display: none;
  }

  /* Allow Name column (1st column) to wrap in mobile */
  .pb-row .pb-cell:first-child,
  .pb-row.header .pb-cell:first-child {
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
  }

  /* Hide "Common " text on mobile, showing just "Name" */
  .desktop-only {
    display: none;
  }

  /* Disable thumbnail zoom on mobile - no border */
  .pb-row:hover .pb-thumb {
    transform: none;
    border: none;
  }

  /* Remove all hover effects on mobile including transform */
  .pb-row {
    transition: none !important;
    border-radius: 0 !important;
    border: 1px solid transparent !important;
    border-bottom: 1px solid #e5e7eb !important;
  }

  .pb-row .pb-thumb {
    transition: none !important;
    width: 160px;
    height: 120px;
  }

  .pb-row:hover {
    background: #ffffff !important;
    border: 1px solid transparent !important;
    border-bottom: 1px solid #e5e7eb !important;
    box-shadow: none !important;
    transform: none !important;
    z-index: auto !important;
    border-radius: 0 !important;
  }

  .pb-row:hover .pb-thumb {
    transform: none !important;
    border: none !important;
  }

  /* Add tap state for mobile - shadows only, no background */
  .pb-table-grid .pb-row.tapped,
  .pb-row.tapped {
    background: #ffffff !important;
    box-shadow: 0 8px 28px rgba(0,0,0,0.25) !important;
    z-index: 5 !important;
    border-radius: 14px !important;
    border: 1px solid transparent !important;
    border-bottom: 1px solid transparent !important;
  }

  /* Increase gallery card image height on mobile */
  .pb-card-img {
    height: 280px;
  }

  /* Remove gallery card hover effect on mobile */
  .pb-card:hover {
    transform: none;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  }

  /* Add tap state for gallery cards on mobile */
  .pb-card.tapped {
    transform: translateY(-3px) !important;
    box-shadow: 0 16px 38px rgba(0,0,0,0.2) !important;
  }

  .pb-polaroid {
    grid-template-columns: 1fr;
    overflow: hidden;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
  }

  /* Reduce media container height on mobile to remove gray bar */
  .pb-media-container {
    height: auto;
    min-height: unset;
    aspect-ratio: 4 / 3;
    background: transparent;
    overflow: hidden;
  }

  /* Center image on mobile to remove gray line on right */
  .pb-media-container .pb-modal-img,
  .pb-media-container .pb-modal-video {
    object-fit: cover;
    object-position: center center;
    background: transparent;
    height: 100%;
    top: 0;
    left: 0;
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
  }

  /* Fixed height for polaroid body based on longest description (American Robin) plus 20px */
  .pb-polaroid-body {
    min-height: auto;
    gap: 4px;
    padding-bottom: 20px;
  }

  /* Reduce title margin on mobile */
  #modalTitle {
    margin: 0;
  }
}

.pb-clear-pill {
  padding: 6px 14px;
  font-size: 0.85rem;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #4b5563;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.pb-clear-pill:hover {
  background: #f3f4f6;
  border-color: #cbd5e1;
}

/* Hide mobile result count on desktop */
@media (min-width: 769px) {
  .pb-result-count-mobile {
    display: none;
  }
}

/* ============================================================
   MOBILE SWIPE ANIMATIONS
============================================================ */
@keyframes slideOutToRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}

@keyframes slideOutToLeft {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(-120%);
    opacity: 0;
  }
}

@keyframes slideInFromRight {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInFromLeft {
  from {
    transform: translateX(-120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ============================================================
   BACK TO TOP TAB
============================================================ */
.pb-back-to-top {
  display: block;
  position: fixed;
  right: 0;
  bottom: 80px;
  transform: translateX(calc(100% + 10px));
  width: 36px;
  height: 56px;
  background: #f0f2f6;
  border: none;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  z-index: 40;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: none;
}

.pb-back-to-top.visible {
  transform: translateX(0);
  box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.2);
}

.pb-back-to-top::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 10px solid #6b7280;
}

.pb-back-to-top:active {
  background: #e0e3ea;
}

.pb-back-to-top:hover {
  background: #e5e7eb;
}

/* ============================================================
   ID WIZARD STYLES
============================================================ */

/* Wizard Controls Bar (floating header like table/gallery) */
.wizard-controls {
  margin-bottom: 20px;
}

.wizard-controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 38px;
}

.wizard-controls-row.hidden {
  display: none;
}

/* Header buttons for results mode */
.wizard-header-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  font-size: 0.9rem;
  font-family: inherit;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
}

.wizard-header-btn:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}

.wizard-controls-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1;
}

.wizard-step-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--pb-text);
  white-space: nowrap;
}

.wizard-controls .active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.live-match-count {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--pb-text);
  white-space: nowrap;
  line-height: 28px;
}

/* Wizard Content Area */
.wizard-content {
  background: #ffffff;
  border-radius: 18px;
  border: 1px solid var(--pb-border);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  padding: 24px;
}

/* Match Info (between question cards and results) */
.wizard-match-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 20px;
  margin-bottom: 8px;
  height: 36px;
}

.wizard-match-info .live-match-count {
  margin-right: 12px;
}

/* Question Cards */
.question-card {
  display: none;
  animation: wizardFadeIn 0.3s ease;
}

.question-card.active {
  display: block;
}

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

.question-title {
  margin: 0 0 6px 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--pb-text);
}

.question-hint {
  margin: 0 0 20px 0;
  font-size: 0.9rem;
  color: var(--pb-muted);
}

/* Options Row with Arrows */
.wizard-options-row {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 160px;
}

/* Arrow Navigation Buttons */
.wizard-arrow {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 2rem;
  line-height: 1;
  color: #374151;
  font-weight: 300;
  padding: 0;
  font-family: inherit;
}

.wizard-arrow:hover:not(:disabled) {
  background: #e5e7eb;
  border-color: #9ca3af;
}

.wizard-arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Option Grid */
.option-grid {
  display: grid;
  gap: 12px;
  flex: 1;
}

.size-grid {
  grid-template-columns: repeat(5, 1fr);
}

.habitat-grid,
.behavior-grid {
  grid-template-columns: repeat(6, 1fr);
}

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

/* Option Buttons */
.option-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  font-family: inherit;
}

.option-btn:hover {
  border-color: var(--pb-primary);
  background: var(--pb-primary-soft);
}

.option-btn.selected {
  border-color: var(--pb-primary);
  background: var(--pb-primary);
  color: #fff;
}

.option-btn.selected .option-desc {
  color: rgba(255,255,255,0.8);
}

.option-icon {
  font-size: 1.5rem;
  margin-bottom: 6px;
}

.option-icon.size-dots {
  font-size: 1.1rem;
  letter-spacing: 2px;
}

.option-icon.size-dots .filled {
  color: var(--pb-primary);
}

.option-icon.size-dots .empty {
  color: #d0d4d8;
}

.option-btn.selected .option-icon.size-dots .filled,
.option-btn.selected .option-icon.size-dots .empty {
  color: #fff;
}

.option-btn.selected .option-icon.size-dots .empty {
  opacity: 0.5;
}

.option-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.option-desc {
  font-size: 0.75rem;
  color: var(--pb-muted);
  margin-top: 4px;
}

/* Compact styles for habitat and behavior grids */
.habitat-grid .option-btn,
.behavior-grid .option-btn {
  padding: 14px 10px;
}

.habitat-grid .option-label,
.behavior-grid .option-label {
  font-size: 0.85rem;
}

.habitat-grid .option-desc,
.behavior-grid .option-desc {
  font-size: 0.7rem;
  display: block;
}

/* Color swatches */
.color-option {
  padding: 12px;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-bottom: 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.option-btn.selected .color-swatch {
  box-shadow: 0 0 0 3px #fff, 0 2px 8px rgba(0,0,0,0.2);
}

/* Skip & Continue Buttons */
.wizard-question-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.skip-btn {
  display: inline-block;
  padding: 8px 0;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--pb-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.2s ease;
}

.skip-btn:hover {
  color: var(--pb-text);
}

.restart-link {
  display: inline-block;
  padding: 8px 0;
  font-size: 0.9rem;
  font-family: inherit;
  color: #dc2626;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.2s ease;
}

.restart-link:hover {
  color: #b91c1c;
}

/* Wizard Nav */
.wizard-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
  margin-top: 20px;
}

.nav-btn {
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn:hover:not(:disabled) {
  background: #e5e7eb;
}

.nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.next-btn {
  background: var(--pb-primary);
  color: #fff;
  border-color: var(--pb-primary);
}

.next-btn:hover:not(:disabled) {
  background: #3d5fc7;
  border-color: #3d5fc7;
}

.next-btn.restart-btn {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.next-btn.restart-btn:hover {
  background: #fee2e2;
}

/* Results Only Nav */
.results-only-nav {
  margin-bottom: 20px;
}

.results-only-nav.hidden {
  display: none;
}

.results-only-nav .restart-btn {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.results-only-nav .restart-btn:hover {
  background: #fee2e2;
}

/* Live Results (always visible below questions) */
.wizard-live-results {
  margin-top: 30px;
}

.live-results-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.live-results-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--pb-text);
}

.live-results-title span {
  color: var(--pb-primary);
}

/* Results Match Header (shown in results-only mode) */
.results-match-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.results-match-header.hidden {
  display: none;
}

.results-match-count {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--pb-text);
}

/* Active Filters */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-tag {
  display: inline-block;
  padding: 4px 10px;
  background: var(--pb-primary-soft);
  color: var(--pb-primary);
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 999px;
}

/* Results Grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.result-card {
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.result-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.15);
}

.result-card-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #f3f4f6;
  display: block;
}

.result-card-body {
  padding: 14px;
}

.result-card-title {
  margin: 0 0 6px 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--pb-text);
}

.result-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--pb-muted);
}

.result-size-dots {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
}

.result-size-dots .filled {
  color: var(--pb-gray-filled);
}

.result-size-dots .empty {
  color: var(--pb-gray-empty);
}

.result-card-desc {
  margin: 0;
  font-size: 0.85rem;
  color: #4b5563;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* No Results */
.no-results {
  text-align: center;
  padding: 60px 20px;
}

.no-results.hidden {
  display: none;
}

.no-results-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.no-results h3 {
  margin: 0 0 8px 0;
  font-size: 1.2rem;
  color: var(--pb-text);
}

.no-results p {
  margin: 0 0 20px 0;
  color: var(--pb-muted);
}

.restart-btn-large {
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  color: #fff;
  background: var(--pb-primary);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.restart-btn-large:hover {
  background: #3d5fc7;
}

/* Wizard Responsive */
@media (max-width: 768px) {
  .wizard-content {
    padding: 16px;
  }
  
  .wizard-controls-row {
    flex-wrap: wrap;
  }
  
  .wizard-controls-left {
    flex: 1;
    min-width: 0;
  }
  
  .wizard-options-row {
    gap: 8px;
  }
  
  .wizard-arrow {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
  }
  
  .question-title {
    font-size: 1.1rem;
  }
  
  .option-grid {
    gap: 10px;
  }
  
  .size-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .size-grid .option-btn {
    padding: 10px 6px;
  }
  
  .size-grid .option-label {
    font-size: 0.8rem;
  }
  
  .size-grid .option-desc {
    font-size: 0.65rem;
  }
  
  .wizard-options-row {
    height: auto;
    min-height: 200px;
  }
  
  .habitat-grid,
  .behavior-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Show descriptions again on mobile since we have more space per card */
  .habitat-grid .option-desc,
  .behavior-grid .option-desc {
    display: block;
  }
  
  .color-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .option-btn {
    padding: 12px 8px;
  }
  
  .option-icon {
    font-size: 1.25rem;
  }
  
  .option-label {
    font-size: 0.85rem;
  }
  
  .option-desc {
    font-size: 0.7rem;
  }
  
  .wizard-nav {
    flex-direction: column;
  }
  
  .results-grid {
    grid-template-columns: 1fr;
  }
  
  .results-filters {
    flex-direction: column;
    align-items: flex-start;
  }
}
