* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(to bottom, #bae6fd, #0284c7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.card {
  background: white;
  width: 100%;
  max-width: 480px;
  border-radius: 1.25rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.header {
  text-align: center;
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.header p {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: #6b7280;
}

.guess-row {
  display: flex;
  gap: 0.5rem;
}

.guess-row input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  font-size: 0.9rem;
}

.guess-row button {
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  border: none;
  background: #2563eb;
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.guess-row button:hover {
  background: #1d4ed8;
}

.results {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.result-tile {
  border-radius: 0.75rem;
  padding: 0.75rem 0.5rem;
  text-align: center;
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
}

.result-label {
  font-size: 0.8rem;
  opacity: 0.85;
  margin-bottom: 0.25rem;
}

.correct {
  background: #22c55e;
}

.partial {
  background: #eab308;
}

.wrong {
  background: #ef4444;
}

.higher {
  background: #3b82f6;
}

.lower {
  background: #8b5cf6;
}

.footer {
  text-align: center;
  font-size: 0.75rem;
  color: #6b7280;
}

@media (min-width: 640px) {
  .results {
    grid-template-columns: repeat(5, 1fr);
  }
}
.history-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.guess-block {
border-bottom: 1px solid #d1d5db;
padding-bottom: 0.75rem;
margin-bottom: 0.75rem;
align-items: center;
}

.history-row .attr-row:nth-child(4),
.history-row .attr-row:nth-child(5) {
grid-column: 2 / span 1; /* centers bottom two boxes */
justify-self: center;
}

@media (max-width: 480px) {
  .history-row {
    grid-template-columns: 1fr 1fr;
  }
}
.guess-counter {
  text-align: center;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #374151; /* dark gray */
  font-size: 0.875rem;
}
.autocomplete-dropdown {
  position: absolute;
  top: 100%;            /* places it BELOW the guess row */
  left: 0;
  width: 100%;
  margin-top: 0.25rem;
  background: white;
  border-radius: 0.5rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  max-height: 200px;
  overflow-y: auto;
  display: none;
  z-index: 50;
}

.autocomplete-item {
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.autocomplete-item:hover {
  background-color: #e5edff;
}
.top-bar {
  display: flex;
  justify-content: space-between; /* 🔥 spreads left + right */
  align-items: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e5e7eb;
}

.top-bar button {
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.top-bar button:hover {
  background: #1d4ed8;
}

.top-bar button::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  background: #1f2937;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 0.375rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10;
}

.top-bar button:hover::after {
  opacity: 1;
}
.autocomplete-item.active {
  background-color: #2563eb;
  color: white;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* End Screen Styles */
.end-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.end-box {
  background-color: white;
  padding: 2rem;
  border-radius: 1.25rem;
  text-align: center;
  min-width: 280px;
  max-width: 90%;
  box-shadow: 0 15px 40px rgba(0,0,0,0.35);
  position: relative;
}

.end-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
}

.end-image {
  width: 120px;
  border-radius: 0.5rem;
  margin: 0.75rem auto;
  display: block;
}

.end-title {
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.end-book-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.end-authors {
  font-size: 0.9rem;
  color: #374151;
}

.end-grid {
  font-family: monospace;
  font-size: 1.5rem;
  margin: 1rem 0 0.5rem;
  letter-spacing: 0.25rem;
}

.end-copy-btn {
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
}
.confetti {
  position: fixed;
  top: -10px;
  width: 10px;
  height: 14px;
  opacity: 0.9;
  pointer-events: none;
  animation: confetti-fall linear forwards;
  z-index: 2000;
}

@keyframes confetti-fall {
  to {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}
.autocomplete-item.active {
  background-color: #c7d2fe;
}
.guess-header {
  display: flex;
  align-items: center;      /* vertically center */
  justify-content: center;  /* center horizontally */

  margin-bottom: 0.25rem;
}

.guess-cover {
  width: 96px;              /* smaller cover */
  height: auto;
  border-radius: 0.25rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.guess-title {
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  flex: 1;                  /* take remaining space */
}

.result-tile {
  perspective: 800px;

}

.result-tile-inner {
  width: 100%;
  height: 100%;
  border-radius: 0.75rem;
  min-height: 60px;
  padding: 0.5rem;
  text-align: center;
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  background: #ef4444;

  transform-style: preserve-3d;
}

/* animation ONLY when flip class is present */
.result-tile-inner.flip {
  animation: flipTile 0.6s ease forwards;
}

@keyframes flipTile {
  0% {
    transform: rotateX(0deg);
  }
  50% {
    transform: rotateX(90deg);
  }
  100% {
    transform: rotateX(0deg);
  }
}
.result-tile-inner.correct { background: #22c55e; }
.result-tile-inner.wrong   { background: #ef4444; }
.result-tile-inner.higher  { background: #3b82f6; }
.result-tile-inner.lower   { background: #8b5cf6; }
.logo {
  text-align: center;
  margin-bottom: 1rem;
  animation: fadeIn 0.8s ease;
}

.logo-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: transform 0.3s ease;
}

.logo-text {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: linear-gradient(90deg, #22c55e, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: popIn 0.6s ease;
}

.book-icon {
  font-size: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
  animation: bounceBook 1.5s ease-in-out 5;
  width: fit-content;
}

.book-icon::before {
  content: "📖";
}

.book-icon::after {
  display: none;
}

.book-icon span {
  display: none;
}

.logo-underline {
  width: 60%;
  height: 4px;
  margin: 0.5rem auto 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #3b82f6, #8b5cf6);
  animation: growLine 0.8s ease;
  transition: width 0.3s ease;
}
@keyframes popIn {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes growLine {
  0% {
    width: 0%;
    opacity: 0;
  }
  100% {
    width: 60%;
    opacity: 1;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes bounceBook {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

body.dark {
  background: linear-gradient(
    to bottom,
    #1e1b4b,   /* dark blue */
    #020617    /* near black */
  );
}

body.dark .card {
  background: #111827;
  color: #e5e7eb;
}

body.dark .result-tile {
  color: white;
}

body.dark input {
  background: #1f2937;
  color: white;
  border: 1px solid #374151;
}

body.dark .autocomplete-dropdown {
  background: #1f2937;
  color: white;
}

body.dark .autocomplete-item:hover {
  background: #374151;
}

body.dark .top-bar button {
  background: #374151;
}

body.dark .top-bar button:hover {
  background: #4b5563;
}
