* {
  box-sizing: border-box;
}

button,
input {
  font-family: inherit;
}

* {
  scrollbar-color: #9A7E5A #E2BB96;
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

*::-webkit-scrollbar-track {
  background: #E2BB96;
  border-radius: 4px;
}

*::-webkit-scrollbar-thumb {
  background: #E2BB96;
  border: 1px solid #444;
  border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
  background: #7A5E3A;
}

body {
  position: relative;
  margin: 0;
  font-family: 'MedievalSharp', cursive, serif;
  color: #000000;
  background-color: #0d0f14;
  background-image: url('../assets/abyss_map.png');
  background-repeat: no-repeat;
  background-position: top center;
  background-size: max(1708px, 100vw) auto;
  min-height: max(2642px, calc(100vw * 1.5468), 100vh);
  transition: background-size 1.4s ease;
}

body.zoomed-in {
  background-size: max(6000px, 100vw) auto;
  min-height: max(9281px, calc(100vw * 1.5468), 100vh);
  overflow: hidden;
}

body.descending {
  background-size: max(1300px, 100vw) auto;
  min-height: max(2011px, calc(100vw * 1.5468), 100vh);
}

.abyss-marker {
  position: absolute;
  left: 50%;
  width: 32px;
  height: 32px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background-color: #ff4444;
  background-size: cover;
  background-position: center;
  border: 3px solid #ff4444;
  box-shadow: 0 0 10px rgba(255, 68, 68, 0.9);
  z-index: 10;
  cursor: pointer;
}

/* stays in layout (so page scrollHeight includes it, allowing scroll-to-marker)
   while visually absent until placeMarker's reveal step flips this off */
.abyss-marker.pending {
  opacity: 0;
  pointer-events: none;
}

body.zoomed-in .abyss-marker,
body.panning .abyss-marker {
  display: none;
}

header {
  position: relative;
  text-align: center;
  padding: 2rem 1rem;
}

header h1 {
  margin: 0;
  font-size: 2.5rem;
}

#details-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 20;
  padding: 0.4rem 0.9rem;
  border: 1px solid #444;
  border-radius: 4px;
  background: #9A7E5A;
  color: #000000;
  cursor: pointer;
}

#details-btn:hover {
  background: #7A5E3A;
}

#back-btn {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 20;
  padding: 0.4rem 0.9rem;
  border: 1px solid #444;
  border-radius: 4px;
  background: #9A7E5A;
  color: #000000;
  cursor: pointer;
}

#back-btn:hover {
  background: #7A5E3A;
}

main {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
}

#search {
  display: flex;
  gap: 0.5rem;
}

#search[hidden] {
  display: none;
}

#anime-input {
  flex: 1;
  padding: 0.75rem;
  border-radius: 4px;
  border: 1px solid #444;
  background: #9A7E5A;
  color: #000000;
}

#anime-input::placeholder {
  color: #000000;
}

#anime-input:-webkit-autofill,
#anime-input:-webkit-autofill:hover,
#anime-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #9A7E5A inset;
  box-shadow: 0 0 0 1000px #9A7E5A inset;
  -webkit-text-fill-color: #000000;
  caret-color: #000000;
  transition: background-color 5000s ease-in-out 0s;
}

#search-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  background: #8A6E4A;
  color: #000000;
  cursor: pointer;
}

#search-btn:hover {
  background: #7A5E3A;
}

#result {
  position: fixed;
  top: 5rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(600px, 90vw);
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  border: 1px solid #333;
  border-radius: 4px;
  background: #E2BB96;
  z-index: 15;
}

#contributions-table {
  max-height: 40vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#result-header {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 1rem;
}

#result-text {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
}

#result-cover {
  width: 140px;
  align-self: stretch;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #444;
  flex-shrink: 0;
}

#result-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#judgement-details {
  margin-top: 2rem;
}

#judgement-details-btn {
  margin-top: 1rem;
  margin-left: 0.5rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid #444;
  border-radius: 4px;
  background: #9A7E5A;
  color: #000000;
  cursor: pointer;
}

#judgement-details-btn:hover {
  background: #8A6E4A;
}

#tag-table {
  max-height: 40vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.subtitle {
  color: #000000;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.explanation {
  color: #000000;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-top: 0.75rem;
}

.data-table {
  color: #000000;
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid #2a2d34;
}

.data-table th {
  color: #000000;
  font-weight: 600;
}

#result-error {
  color: #e57373;
}

#error-popup {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  max-width: 24rem;
  padding: 1rem 1.25rem;
  background: #0d0f14;
  border: 2px solid #9A7E5A;
  border-radius: 0.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  text-align: center;
}

#error-popup-message {
  color: #e57373;
  margin: 0 0 0.75rem;
}

#error-popup-close {
  background: #9A7E5A;
  color: #000000;
  border: none;
  border-radius: 0.25rem;
  padding: 0.35rem 1rem;
  cursor: pointer;
}

#error-popup-close:hover {
  background: #7A5E3A;
}

#contributions-btn {
  margin-top: 1rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid #444;
  border-radius: 4px;
  background: #9A7E5A;
  color: #000000;
  cursor: pointer;
}

#contributions-btn:hover {
  background: #8A6E4A;
}