/* Books Quiz - Brown/Sepia Theme */
:root {
  --primary-color: #8b4513;
  --primary-hover: #a0522d;
  --success-color: #22c55e;
  --warning-color: #eab308;
  --error-color: #ef4444;
  --bg-color: #1a1612;
  --card-bg: #2a2420;
  --text-color: #f5f0e8;
  --text-muted: #a89888;
  --border-color: #4a3c30;
  --border-focus: #8b4513;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --match-bg: #064e3b;
  --match-color: #10b981;
  --higher-bg: #78350f;
  --higher-color: #fbbf24;
  --lower-bg: #78350f;
  --lower-color: #fbbf24;
  --different-bg: #7f1d1d;
  --different-color: #f87171;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Merriweather', 'Georgia', serif;
  background: var(--bg-color);
  background-image: 
    radial-gradient(ellipse at top, rgba(139, 69, 19, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(160, 82, 45, 0.08) 0%, transparent 50%);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  min-height: 100vh;
  line-height: 1.6;
}

header {
  text-align: center;
  padding: 1.5rem 1rem;
  background: linear-gradient(180deg, var(--card-bg) 0%, transparent 100%);
  width: 100%;
  border-bottom: 2px solid var(--primary-color);
}

header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--primary-color), #cd853f);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header p {
  margin: 0 0 0.5rem 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

header a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
  font-size: 0.9rem;
}

header a:hover {
  color: var(--primary-color);
}

main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  padding: 2rem 1rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
}

/* Game Info */
.game-info {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  width: 100%;
  box-sizing: border-box;
}

.game-info p {
  margin: 0 0 1rem 0;
  color: var(--text-muted);
}

.game-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

#game-status {
  color: var(--success-color);
  font-weight: 600;
}

#game-status.solved {
  color: var(--success-color);
}

#game-status.game-over {
  color: var(--error-color);
}

.answer-reveal {
  background: linear-gradient(135deg, rgba(127, 29, 29, 0.8) 0%, rgba(185, 28, 28, 0.6) 100%);
  border: 2px solid var(--error-color);
}

.answer-reveal-header {
  color: #fff !important;
}

.answer-reveal-feedback {
  color: #fff !important;
  background: rgba(0,0,0,0.2) !important;
}

/* Guess Section */
.guess-section {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  box-sizing: border-box;
}

.guess-section label {
  font-weight: 600;
  color: var(--text-color);
}

.autocomplete-wrapper {
  position: relative;
  width: 100%;
}

#book-input {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  font-size: 1rem;
  background: rgba(0,0,0,0.3);
  color: var(--text-color);
  transition: all 0.2s ease;
  box-sizing: border-box;
  font-family: inherit;
}

#book-input::placeholder {
  color: var(--text-muted);
}

#book-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.2);
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 10px 10px;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  display: none;
  margin-top: -2px;
}

.autocomplete-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-color);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: rgba(139, 69, 19, 0.15);
}

.submit-btn {
  padding: 0.875rem 1.5rem;
  border: none;
  background: linear-gradient(135deg, var(--primary-color), #cd853f);
  color: white;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  transition: all 0.2s ease;
  font-family: inherit;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 69, 19, 0.3);
}

.submit-btn:active {
  transform: translateY(0);
}

.submit-btn:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

.submit-btn.secondary {
  background: var(--text-muted);
}

.submit-btn.secondary:hover {
  background: #6b7280;
}

.button-group {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.button-group .submit-btn {
  flex: 1;
}

/* Share section styling now in shared.css */

/* Guesses Container */
.guesses-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.guess-card {
  background: var(--card-bg);
  padding: 0.875rem 1rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
}

.guess-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.guess-book-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  min-width: 200px;
  flex-shrink: 0;
}

.book-emoji-inline {
  font-size: 1.5rem;
  line-height: 1;
}

.book-name-inline {
  font-size: 0.95rem;
  color: var(--text-color);
  font-style: italic;
}

.guess-book-header.correct .book-name-inline {
  color: var(--success-color);
}

.correct-badge {
  color: var(--success-color);
  font-size: 1.2rem;
  margin-left: 0.25rem;
}

.wrong-badge {
  color: var(--text-muted);
  font-size: 1.2rem;
  margin-left: 0.25rem;
  opacity: 0.7;
}

.property-feedback {
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  white-space: normal;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem;
}

/* Feedback Styles */
.feedback-match {
  background: var(--match-bg);
  color: var(--match-color);
}

.feedback-higher {
  background: var(--higher-bg);
  color: var(--higher-color);
}

.feedback-lower {
  background: var(--lower-bg);
  color: var(--lower-color);
}

.feedback-different {
  background: var(--different-bg);
  color: var(--different-color);
}

/* How to Play */
.how-to-play {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  width: 100%;
}

.how-to-play h3 {
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
  color: var(--text-color);
}

.how-to-play ul {
  margin: 0;
  padding-left: 1.5rem;
  color: var(--text-muted);
}

.how-to-play li {
  margin-bottom: 0.5rem;
}

/* Ad Containers */
.ad-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  overflow: hidden;
}

.ad-header {
  min-height: 90px;
  max-width: 728px;
  margin: 0 auto 1rem;
}

.ad-in-content {
  min-height: 250px;
  max-width: 336px;
  margin: 1rem auto;
}

/* Mobile */
@media (max-width: 768px) {
  .ad-header {
    display: none;
  }
  
  .ad-in-content {
    max-width: 320px;
    min-height: 250px;
  }
  
  main {
    padding: 1rem;
    gap: 1rem;
  }
  
  header {
    padding: 1rem 0.75rem;
  }
  
  header h1 {
    font-size: 1.75rem;
  }
  
  .game-info,
  .guess-section,
  .how-to-play {
    padding: 1rem;
  }
  
  .guess-line {
    gap: 0.5rem;
    font-size: 0.85rem;
  }
  
  .guess-book-header {
    min-width: 160px;
    font-size: 0.9rem;
  }
  
  .book-emoji-inline {
    font-size: 1.25rem;
  }
  
  .book-name-inline {
    font-size: 0.85rem;
  }
  
  .property-feedback {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
}

@media (min-width: 769px) {
  .ad-header {
    display: flex;
  }
}

/* Mode Toggle */
.mode-toggle {
  background: var(--card-bg);
  padding: 1rem 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  width: 100%;
  box-sizing: border-box;
}

.toggle-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color);
  transition: 0.3s;
  border-radius: 28px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, var(--primary-color), #cd853f);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

.toggle-label {
  font-weight: 600;
  color: var(--text-color);
  font-size: 1rem;
}

.toggle-description {
  margin: 0 0 0 auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  gap: 0.15rem;
}

.toggle-description .current-mode {
  color: var(--text-color);
  font-size: 0.9rem;
}

.toggle-description .current-mode strong {
  color: var(--primary-color);
}

.toggle-description .mode-action {
  font-size: 0.8rem;
  opacity: 0.7;
}

.toggle-description.easy-active .current-mode strong {
  color: var(--success-color);
}

/* Disabled toggle state */
.toggle-switch.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.toggle-switch.disabled .toggle-slider {
  cursor: not-allowed;
}

/* Autocomplete with author info */
.autocomplete-item .book-title {
  font-weight: 600;
  color: var(--text-color);
}

.autocomplete-item .author-name {
  color: var(--text-muted);
  font-size: 0.9em;
  margin-left: 0.5rem;
}

.autocomplete-item .author-name::before {
  content: "by ";
  font-style: italic;
}

@media (max-width: 500px) {
  .toggle-container {
    flex-wrap: wrap;
  }
  
  .toggle-description {
    width: 100%;
    margin: 0.5rem 0 0 0;
    align-items: flex-start;
    text-align: left;
  }
  
  .mode-toggle {
    padding: 1rem;
  }
}

/* Clues Summary Panel */
.clues-panel { background: var(--card-bg); border: 1px solid var(--primary-color); border-radius: 10px; margin-bottom: 1rem; overflow: hidden; width: 100%; max-width: 800px; }
.clues-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: rgba(139, 69, 19, 0.15); cursor: pointer; }
.clues-title { font-size: 0.85rem; font-weight: 600; color: var(--primary-color); }
.clues-toggle { background: none; border: none; color: var(--primary-color); font-size: 0.8rem; cursor: pointer; transition: transform 0.2s; }
.clues-toggle.collapsed { transform: rotate(-90deg); }
.clues-content { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.clues-content.collapsed { display: none; }
.clues-row { display: flex; gap: 8px; flex-wrap: wrap; }
.clues-ranges { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.clues-confirmed { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.clues-ranges + .clues-confirmed { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(255, 255, 255, 0.1); }
.clue-item { display: flex; flex-direction: column; align-items: center; text-align: center; background: rgba(0,0,0,0.3); border: 1px solid var(--border-color); border-radius: 8px; padding: 12px 16px; min-height: 58px; justify-content: center; }
.clue-item.confirmed { border-color: var(--success-color); background: rgba(34, 197, 94, 0.15); }
.clue-item.narrowed { border-color: var(--warning-color); background: rgba(234, 179, 8, 0.1); }
.clue-label { font-size: 0.6rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.4px; margin-bottom: 4px; }
.clue-value { font-size: 0.95rem; font-weight: 600; color: var(--text-color); }
.clue-item.confirmed .clue-value { color: var(--success-color); }
.clue-item.narrowed .clue-value { color: var(--warning-color); }
.clues-excluded { padding-top: 8px; border-top: 1px solid var(--border-color); align-items: center; gap: 6px; }
.clues-excluded .clue-label { display: inline; margin-bottom: 0; font-size: 0.65rem; color: var(--error-color); }
.clue-excluded-values { font-size: 0.7rem; color: var(--text-muted); }

/* Book Cover Image */
.book-cover-small {
  width: 30px;
  height: 45px;
  object-fit: cover;
  border-radius: 3px;
  margin-right: 0.5rem;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.book-cover-small.clickable {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.book-cover-small.clickable:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* Image Lightbox */
.image-lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.image-lightbox.open {
  display: flex;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: white;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2001;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.1);
}

.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: default;
  max-width: 90vw;
  max-height: 80vh;
}

.lightbox-content img {
  max-width: 300px;
  max-height: 450px;
  width: auto;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  object-fit: contain;
}

.lightbox-title {
  margin-top: 16px;
  color: white;
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
}

@media (max-width: 600px) {
  .lightbox-close {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    font-size: 24px;
  }
  
  .lightbox-content img {
    max-width: 80vw;
    max-height: 60vh;
  }
  
  .lightbox-title {
    font-size: 1rem;
    padding: 0 16px;
  }
}
