/* Geneguessr Styles */

#geneguessr-root {
  max-width: 700px;
  margin: 2rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 100vh;
  /* Ensure root itself doesn't create scroll context */
  position: relative;
}

/* Fixed sections that don't scroll */
#pg-clue-slot,
#pg-footer-slot {
  flex-shrink: 0;
}

/* Scrollable middle section containing guesses */
#pg-guesses-container {
  flex: 1 1 auto;
  overflow: visible;
  /* Create scroll context here, not on parent */
  min-height: 0;
}

#pg-guesses {
  /* No flex properties - just content inside scrollable container */
  padding-bottom: 1.5rem;
}

/* Sidebar Stats */
.pg-sidebar-stats {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--light);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.pg-sidebar-section {
  margin-bottom: 1rem;
}

.pg-sidebar-section:last-child {
  margin-bottom: 0;
}

.pg-sidebar-label {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--secondary);
  margin-bottom: 0.5rem;
}

.pg-sidebar-hints {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.pg-sidebar-stats-grid {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--dark);
}

.pg-sidebar-stat-label {
  color: var(--secondary);
  font-size: 0.85rem;
}

.pg-sidebar-practice-value {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--ui-border);
  background: var(--ui-bg);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--secondary);
}

.pg-sidebar-practice-value.is-active {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* Auth section */
.pg-auth-section {
  border-bottom: 1px solid var(--ui-border);
  padding-bottom: 1rem;
}

.pg-auth-signin {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #5865f2;
  color: white;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s;
}

.pg-auth-signin:hover {
  background: #4752c4;
  color: white;
}

.pg-auth-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pg-auth-username {
  font-weight: 600;
  color: var(--dark);
}

.pg-auth-tier {
  font-size: 0.85rem;
  color: var(--secondary);
  text-transform: capitalize;
}

.pg-auth-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-start;
  margin-top: 0.35rem;
}

.pg-auth-discord {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: transparent;
  border: 1.5px solid #5865f2;
  color: var(--dark);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease;
}

.pg-auth-discord:hover {
  background: color-mix(in srgb, #5865f2 10%, transparent);
  color: var(--dark);
  transform: translateY(-1px);
}

.pg-auth-discord svg,
.pg-auth-discord img {
  /* Keep Discord icon colored */
  color: #5865f2;
}

.pg-auth-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.9rem;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  border-radius: 999px;
  color: var(--dark);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.pg-auth-logout:hover {
  background: var(--light);
  border-color: var(--secondary);
}

/* Legacy structure card (no longer used) */
.pg-structure-card {
  margin-bottom: 1.5rem;
}

.pg-structure-viewer {
  position: relative;
  width: 100%;
  height: 320px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-bg);
  overflow: hidden;
}

/* Card-embedded structure viewer with 16:9 aspect ratio */
.pg-card-structure {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pg-card-structure-viewer {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-bg);
  overflow: hidden;
}

/* Chain label callouts for multi-protein complexes */
.pg-chain-callouts {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-width: 45%;
  z-index: 10;
  pointer-events: none;
}

.pg-chain-callout {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 4px;
  font-size: 0.7rem;
  line-height: 1.2;
  backdrop-filter: blur(4px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

:root[data-theme="dark"] .pg-chain-callout {
  background: rgba(30, 30, 30, 0.85);
  color: #e0e0e0;
}

.pg-chain-callout-target {
  background: rgba(76, 175, 80, 0.9);
  color: white;
  font-weight: 600;
}

:root[data-theme="dark"] .pg-chain-callout-target {
  background: rgba(56, 142, 60, 0.9);
}

.pg-chain-id {
  font-family: monospace;
  font-weight: 700;
  color: inherit;
  opacity: 0.8;
}

.pg-chain-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.pg-chain-more {
  font-style: italic;
  opacity: 0.7;
  font-size: 0.65rem;
}

.pg-structure-placeholder,
.pg-structure-loading,
.pg-structure-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  color: var(--secondary);
  gap: 0.5rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(245, 245, 245, 0.9));
}

.pg-structure-source {
  font-size: 0.85rem;
  text-align: right;
  color: var(--secondary);
  letter-spacing: 0.02em;
}

.pg-structure-source[data-structure-source="alphafold"] {
  color: var(--accent);
  font-weight: 600;
}

.pg-structure-source-link {
  color: var(--secondary);
  text-decoration: none;
}

.pg-structure-source-link:hover {
  color: var(--tertiary);
  text-decoration: underline;
}

:root[data-theme="dark"] .pg-structure-source:not([data-structure-source="alphafold"]) {
  color: var(--gray);
}

:root[data-theme="dark"] .pg-structure-placeholder,
:root[data-theme="dark"] .pg-structure-loading,
:root[data-theme="dark"] .pg-structure-error {
  background: rgba(0, 0, 0, 0.5);
}

.pg-structure-tip {
  font-size: 0.85rem;
  color: var(--gray);
}

.pg-structure-error {
  color: #b00020;
  font-weight: 600;
}

.pg-structure-viewer,
.pg-structure-viewer canvas,
.pg-card-structure-viewer,
.pg-card-structure-viewer canvas {
  background-color: rgb(248, 241, 231);
}

:root[data-theme="dark"] .pg-structure-viewer,
:root[data-theme="dark"] .pg-structure-viewer canvas,
:root[data-theme="dark"] .pg-card-structure-viewer,
:root[data-theme="dark"] .pg-card-structure-viewer canvas {
  background-color: rgb(17, 12, 10);
}

.pg-structure-viewer canvas,
.pg-card-structure-viewer canvas {
  border-radius: 8px;
}

/* Hide remaining Molstar UI controls that can't be hidden via API */
.pg-structure-viewer .msp-viewport-controls button[title="Reset Camera"],
.pg-structure-viewer .msp-viewport-controls button[title*="Reset"],
.pg-structure-viewer .msp-viewport-controls button[title*="Screenshot"],
.pg-structure-viewer .msp-viewport-controls button[title*="State"],
.pg-card-structure-viewer .msp-viewport-controls button[title="Reset Camera"],
.pg-card-structure-viewer .msp-viewport-controls button[title*="Reset"],
.pg-card-structure-viewer .msp-viewport-controls button[title*="Screenshot"],
.pg-card-structure-viewer .msp-viewport-controls button[title*="State"] {
  display: none !important;
}

.pg-structure-viewer .msp-viewport-info,
.pg-structure-viewer .msp-hover-hint,
.pg-structure-viewer .msp-controls-wrapper,
.pg-structure-viewer .msp-top-left-controls,
.pg-structure-viewer .msp-top-center-controls,
.pg-structure-viewer .msp-bottom-left-controls,
.pg-structure-viewer .msp-bottom-center-controls,
.pg-structure-viewer .msp-highlight-info,
.pg-structure-viewer .msp-sequence-wrapper,
.pg-card-structure-viewer .msp-viewport-info,
.pg-card-structure-viewer .msp-hover-hint,
.pg-card-structure-viewer .msp-controls-wrapper,
.pg-card-structure-viewer .msp-top-left-controls,
.pg-card-structure-viewer .msp-top-center-controls,
.pg-card-structure-viewer .msp-bottom-left-controls,
.pg-card-structure-viewer .msp-bottom-center-controls,
.pg-card-structure-viewer .msp-highlight-info,
.pg-card-structure-viewer .msp-sequence-wrapper {
  display: none !important;
}

/* Disable pointer events on hover tooltips and info boxes */
.pg-structure-viewer .msp-highlight-info-wrapper,
.pg-card-structure-viewer .msp-highlight-info-wrapper {
  display: none !important;
  pointer-events: none !important;
}

.pg-tutorial-overlay {
  position: fixed;
  inset: 0;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1050;
}

.pg-tutorial-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.pg-tutorial-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
}

.pg-tutorial-card {
  position: relative;
  width: min(420px, calc(100% - 2rem));
  max-height: calc(100dvh - 3rem);
  padding: 1.5rem 1.5rem 1.25rem;
  border-radius: 16px;
  background: var(--light);
  color: var(--dark);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.5);
  z-index: 1;
  overflow-y: auto;
}

.pg-tutorial-skip {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 0.9rem;
  text-decoration: underline;
  cursor: pointer;
}

.pg-tutorial-status {
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--secondary);
}

.pg-tutorial-content h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.pg-tutorial-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pg-tutorial-list li {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.75rem;
}

.pg-tutorial-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  color: var(--secondary);
  margin-top: 0.1rem;
}

.pg-tutorial-img-wrapper {
  position: relative;
  flex-shrink: 0;
}

.pg-tutorial-img {
  display: block;
  max-width: 120px;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--ui-border);
}

.pg-tutorial-finger {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.pg-tutorial-item-text {
  font-size: 0.95rem;
  color: var(--dark);
  line-height: 1.5;
}

.pg-tutorial-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.pg-tutorial-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--ui-border);
  background: var(--light);
  color: var(--dark);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.pg-tutorial-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pg-tutorial-forward.is-play {
  border-radius: 999px;
  width: auto;
  padding: 0.5rem 1.5rem;
}

.pg-tutorial-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex: 1;
}

.pg-tutorial-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: none;
  background: var(--ui-border);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.pg-tutorial-dot.is-active {
  transform: scale(1.2);
  background: var(--dark);
}

.pg-tutorial-footer {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.pg-tutorial-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--secondary);
}

.pg-tutorial-locked {
  overflow: hidden;
}

@media (max-width: 600px) {
  .pg-tutorial-overlay {
    padding: 1rem;
  }
  
  .pg-tutorial-card {
    padding: 1.25rem;
  }

  .pg-tutorial-nav-btn {
    width: 36px;
    height: 36px;
  }
  
  .pg-tutorial-icon {
    width: 20px;
    height: 20px;
  }
  
  .pg-tutorial-img {
    max-width: 100px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pg-tutorial-overlay {
    transition: none;
  }

  .pg-tutorial-dot,
  .pg-tutorial-nav-btn {
    transition: none;
  }
}

@media (max-width: 600px) {
  .pg-structure-viewer {
    height: 260px;
  }

  /* Card viewer maintains 16:9 ratio on mobile */
  .pg-card-structure-viewer {
    aspect-ratio: 16 / 9;
  }
}

/* Clue Card */
/* Unified Card Styling */
.pg-clue-card,
.pg-feedback-card {
  position: relative;
  background: var(--light);
  border-radius: 8px;
  margin-bottom: 1.5rem;
  overflow: hidden;
  isolation: isolate;
}

.pg-clue-card::after,
.pg-feedback-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--ui-border);
  z-index: 1;
}

.pg-clue-card>*,
.pg-feedback-card>* {
  position: relative;
  z-index: 2;
}

.pg-clue-card {
  padding: 0.75rem 1rem;
}

/* Unified Section Styling - used by both clue and feedback cards */
.pg-section {
  margin-bottom: 0.4rem;
  line-height: 1.5;
  font-size: 1rem;
  color: var(--dark);
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
  text-wrap: pretty;
}

@supports not (overflow-wrap: anywhere) {
  .pg-section {
    overflow-wrap: break-word;
  }
}

.pg-section:last-child {
  margin-bottom: 0;
}

.pg-section-label {
  font-weight: 600;
  color: var(--secondary);
}

/* Clue card: use monospace font for category labels to match redacted text */
.pg-clue-card .pg-section-label {
  font-family: var(--codeFont);
}

/* Clue card sections: slightly smaller to balance monospace appearance */
.pg-clue-card .pg-section {
  font-size: 0.9rem;
}

.pg-section-entry {
  display: inline;
  vertical-align: baseline;
  max-width: 100%;
}

/* Show commas between revealed entries, spaces between redacted entries */
.pg-section-entry:not(:last-child)::after {
  content: ", ";
}

/* When entry contains only a redaction (unrevealed), use space instead of comma */
.pg-section-entry:has(.pg-redaction:only-child):not(:last-child)::after {
  content: "  ";
  white-space: pre;
}

.pg-section-entry.matched-highlight {
  color: var(--accent);
  font-weight: 600;
  text-shadow: 0 0 6px color-mix(in srgb, var(--accent) 40%, transparent);
}

/* Gene summary styling */
.pg-gene-summary {
  font-style: italic;
  font-size: 0.9rem;
  color: var(--secondary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--lightgray);
}

.pg-gene-summary-source {
  opacity: 0.7;
  font-size: 0.85rem;
  margin-left: 0.35rem;
  font-style: normal;
  text-decoration: none;
  color: var(--secondary);
}

.pg-gene-summary-source:hover {
  opacity: 1;
  text-decoration: underline;
}

/* Legacy aliases for backward compatibility */
.pg-clue-section {
  margin-bottom: 0.4rem;
  line-height: 1.5;
  font-size: 0.9rem;
  color: var(--dark);
  overflow-wrap: break-word;
  word-break: break-word;
}

.pg-clue-section:last-child {
  margin-bottom: 0;
}

.pg-clue-label-inline {
  font-weight: 600;
  color: var(--secondary);
}

.pg-clue-entry {
  display: inline-block;
  vertical-align: top;
  max-width: 100%;
  margin-right: 0.35rem;
}

.pg-clue-entry:last-child {
  margin-right: 0;
}

/* Redaction/Spoiler Styling */
.pg-redaction {
  display: inline;
  cursor: pointer;
  user-select: none;
  color: transparent;
  background: var(--dark);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  transition: opacity 0.15s ease;
  /* Monospace ensures consistent width per character, preventing reflow when revealed */
  font-family: var(--codeFont);
  /* letter-spacing: 0 ensures redaction bar width matches revealed text width */
  letter-spacing: 0;
}

/* Dark mode: use lightgray (1 step brighter than background) for spoiler bars */
@media (prefers-color-scheme: dark) {
  .pg-redaction {
    background: var(--lightgray);
  }
}
:root[data-theme="dark"] .pg-redaction {
  background: var(--lightgray);
}

/* Text revealed from redaction - must match redaction font for consistent reflow */
.pg-revealed-text {
  font-family: var(--codeFont);
  letter-spacing: 0;
}

.pg-redaction:hover,
.pg-redaction:focus-visible {
  opacity: 0.85;
}

.pg-redaction:focus-visible {
  outline: 2px solid var(--secondary);
  outline-offset: 2px;
}

.pg-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pg-chip {
  background: var(--light);
  border: 1px solid var(--darkgray);
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: var(--codeFont);
  color: var(--dark);
}

.pg-chip.matched {
  background: oklch(50% 0.08 185);
  color: white;
  border-color: oklch(50% 0.08 185);
}

/* Dark mode override for matched chips */
@media (prefers-color-scheme: dark) {
  .pg-chip.matched {
    background: oklch(68% 0.08 185);
    border-color: oklch(68% 0.08 185);
  }
}

:root[data-theme="dark"] .pg-chip.matched {
  background: oklch(68% 0.08 185);
  border-color: oklch(68% 0.08 185);
}

.pg-chip.unmatched {
  background: var(--gray);
  color: var(--light);
  border-color: var(--gray);
}

.pg-flags {
  display: flex;
  gap: 1rem;
}

.pg-flag {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--dark);
}

.pg-subtext {
  font-size: 0.85rem;
  color: var(--secondary);
  margin-top: 0.35rem;
}

.pg-flag-icon {
  font-size: 1.2rem;
}

/* Input */
#pg-input-slot {
  /* DO NOT TOUCH THIS BLOCK. Sticky top+bottom was the only setup that survived many regressions. */
  /* STICKY GUTTERS (top/bottom) MUST MATCH: altering them breaks docking in either direction. */
  /* NO helper classes, NO JS observers: pure CSS sticky is intentional and battle-tested. */
  position: relative;
  background: var(--light);
  border-radius: 8px;
  margin-bottom: 1.5rem;
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  overflow: visible;
  isolation: isolate;
  box-sizing: border-box;
  /* Sticky positioning */
  position: sticky;
  top: 1rem;
  bottom: 1rem; /* mirror sticky gutter at bottom for dual docking without extra classes */
  z-index: 100;
  padding: 0.75rem 1rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

#pg-input-slot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--ui-border);
  z-index: 1;
}

#pg-input-slot > * {
  position: relative;
  z-index: 2;
}

#pg-input-placeholder {
  display: none;
}

.pg-input-section {
  margin-bottom: 0;
}

.pg-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.pg-autocomplete-wrapper {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: center;
  background: var(--light);
  border-radius: 8px;
}

#pg-input {
  flex: 1 1 0;
  min-width: 0;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: transparent;
  color: var(--dark);
  outline: none;
}

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

.pg-input:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.pg-guesses-badge,
.pg-hints-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  background: var(--light);
  box-shadow: inset 0 0 0 1px var(--ui-border);
  border: none;
  border-radius: 999px;
  white-space: nowrap;
  height: 44px;
  box-sizing: border-box;
}

.pg-guesses-label,
.pg-hints-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--secondary);
  font-weight: 700;
}

.pg-guesses-value,
.pg-hints-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
  letter-spacing: -0.01em;
}

.pg-hints-badge.has-hints {
  /* No background change - keep it neutral */
  background: var(--light);
  box-shadow: inset 0 0 0 1px var(--ui-border);
}

.pg-hints-badge.has-hints .pg-hints-value {
  /* Only the numeral gets accent color to draw attention */
  color: oklch(55% 0.14 185);
  font-weight: 700;
}

.pg-hints-badge.has-hints .pg-hints-label {
  /* Label stays muted */
  color: var(--secondary);
  font-weight: 700;
}

.pg-how-to-play {
  background: var(--lightgray);
  border: 1px solid var(--ui-border);
  color: var(--darkgray);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pg-how-to-play:hover {
  background: var(--light);
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

:root[data-theme="dark"] .pg-how-to-play {
  color: var(--darkgray);
}

.pg-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  bottom: auto;
  left: 0;
  right: 0;
  margin-top: 4px;
  margin-bottom: 0;
  background: var(--light);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 300px;
  overflow-y: auto;
}

.pg-suggestions.pg-suggestions-above {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 8px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
}

.pg-suggestion {
  padding: 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--ui-border);
  color: var(--dark);
  transition: background 0.15s ease;
}

.pg-suggestion:hover,
.pg-suggestion.selected {
  background: var(--ui-bg);
}

.pg-suggestion-title {
  font-weight: 600;
  color: var(--dark);
}

.pg-suggestion-sub {
  font-size: 0.85rem;
  color: var(--secondary);
  margin-top: 0.15rem;
}

.pg-suggestion:last-child {
  border-bottom: none;
}

@media (max-width: 600px) {
  .pg-input-row {
    gap: 0.5rem;
    min-inline-size: 0;
  }

  .pg-autocomplete-wrapper {
    width: 100%;
  }

  .pg-guesses-badge,
  .pg-hints-badge {
    padding: 0.4rem 0.75rem;
  }

  .pg-practice-badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
  }
}

/* Feedback Panel */
.pg-feedback {
  background: var(--light);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.pg-feedback-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--ui-border);
}

.pg-feedback-protein {
  font-weight: 800;
  font-size: 1rem;
  color: var(--dark);
}

.pg-feedback-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
}

.pg-feedback-label {
  font-size: 0.9rem;
  color: var(--secondary);
}

.pg-feedback-value {
  font-weight: 600;
  color: var(--dark);
}

.pg-feedback-note {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--secondary);
}

.pg-bar {
  height: 6px;
  background: var(--lightgray);
  border-radius: 3px;
  overflow: hidden;
  flex: 1;
  margin: 0 0.75rem;
}

.pg-bar-fill {
  height: 100%;
  background: var(--secondary);
  transition: width 0.3s ease;
}

/* Collapsible Feedback Cards - now using unified card styling above */
.pg-feedback-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.pg-collapse-toggle {
  width: 100%;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  transition: background-color 0.2s ease;
}

.pg-collapse-toggle:hover {
  background-color: var(--lightgray);
}

.pg-collapse-toggle:focus {
  outline: none;
}

.pg-static-toggle {
  cursor: default;
}

.pg-static-toggle:hover {
  background-color: transparent;
}

.pg-static-toggle:focus {
  outline: none;
}

.pg-collapse-chevron {
  font-size: 0.9rem;
  color: var(--secondary);
  flex-shrink: 0;
  width: 1rem;
  transition: transform 0.2s ease;
}

.pg-feedback-gene {
  font-weight: 700;
  font-size: 1rem;
  color: var(--dark);
  flex-shrink: 0;
}

.pg-feedback-score {
  font-weight: 600;
  color: var(--dark);
  font-size: 0.9rem;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.pg-feedback-content {
  padding: 0 1rem;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.2s ease;
}

.pg-feedback-protein-name {
  font-size: 0.9rem;
  color: var(--secondary);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

@media (prefers-reduced-motion: reduce) {
  .pg-feedback-content {
    transition: none;
  }
}

.pg-feedback-card.collapsed .pg-feedback-content {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.pg-feedback-card.expanded .pg-feedback-content {
  opacity: 1;
  padding: 0.75rem 1rem;
  padding-top: 0.5rem;
}

.pg-feedback-final .pg-feedback-content {
  opacity: 1;
  padding: 0.75rem 1rem;
  padding-top: 0.5rem;
  overflow: visible;
}

.pg-play-again {
  border: 1px solid var(--ui-border);
  background: var(--light);
  color: var(--dark);
  border-radius: 999px;
  padding: 0.5rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.pg-play-again:hover {
  background: var(--ui-bg);
  border-color: var(--secondary);
}

.pg-link-btn {
  padding: 0.5rem 1rem;
  background: white;
  color: oklch(50% 0.08 185);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.pg-link-btn:hover {
  background: rgba(255, 255, 255, 0.9);
}

/* Failed card in light mode: cream bg with dark text on medium brown card */
.pg-practice-badge {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--secondary);
}

.pg-practice-btn {
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  border: 1px solid var(--ui-border);
  background: var(--ui-bg);
  color: var(--dark);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.pg-practice-btn:hover {
  background: var(--light);
  border-color: var(--secondary);
}

.pg-practice-badge {
  align-self: flex-start;
  flex-shrink: 0;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--ui-border);
  background: var(--ui-bg);
}

.pg-gameover-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.pg-gameover-left {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.pg-gameover-title {
  font-weight: 800;
  font-size: 1rem;
  color: var(--dark);
}

.pg-gameover-protein {
  font-weight: 600;
  color: var(--secondary);
  overflow-wrap: anywhere;
}

.pg-gameover-protein a {
  color: var(--secondary);
  text-decoration: none;
}

.pg-gameover-protein a:hover {
  text-decoration: underline;
}

.pg-gameover-guesses {
  font-size: 0.9rem;
  color: var(--secondary);
}

.pg-gameover-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pg-gameover-links {
  margin-top: 0.35rem;
}

.pg-gameover-links .pg-link-btn {
  display: inline-block;
}

/* Share */
.pg-share-section {
  text-align: center;
  margin-top: 1.5rem;
}

.pg-share-btn {
  padding: 0.75rem 1.5rem;
  background: var(--dark);
  color: var(--light);
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.pg-share-btn:hover {
  opacity: 0.9;
}

.pg-share-feedback {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--secondary);
}

/* Stats */
.pg-stats {
  display: flex;
  justify-content: space-around;
  padding: 1rem;
  background: var(--light);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  margin-bottom: 1rem;
}

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

.pg-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark);
}

.pg-stat-label {
  font-size: 0.85rem;
  color: var(--secondary);
  text-transform: uppercase;
}

/* Hide wiki Tags section when GeneGuessr is active */
#geneguessr-root ~ .right .tags,
article:has(#geneguessr-root) ~ .right .tags,
.right:has(~ article #geneguessr-root) .tags {
  display: none;
}

/* Also hide via sidebar class when game root exists */
body:has(#geneguessr-root) .sidebar.right > .tags {
  display: none;
}

/* Attribution panel styling */
.pg-attribution-panel {
  padding: 1rem;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  margin-top: 0.5rem;
}

.pg-attribution-panel ul {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.pg-attribution-panel li {
  font-size: 0.9rem;
  color: var(--dark);
}

.pg-attribution-panel a {
  color: var(--accent);
  text-decoration: none;
}

.pg-attribution-panel a:hover {
  text-decoration: underline;
}

/* Chevron icon for attribution toggle */
.pg-chevron-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.5rem;
  transition: transform 0.2s ease;
}

.pg-chevron-icon.is-expanded {
  transform: rotate(90deg);
}

.pg-chevron-icon svg {
  width: 12px;
  height: 12px;
}

/* Mobile */
@media (max-width: 600px) {
  #geneguessr-root {
    padding: 0 0.5rem;
  }

  .pg-stats {
    flex-wrap: wrap;
  }

  #pg-input-slot {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}
