:root {
  --era-hover: #3b3b3b;
}

/* Glossary Layout */
.glossary {
  max-width: 700px;
  margin: 2em auto;
  text-align: left;
}
.glossary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100vw;
  max-width: 100vw;
  margin-left: 50%;
  transform: translateX(-50%);
  margin-bottom: 2em;
  gap: 0;
  box-sizing: border-box;
  padding: 0 2vw;
}
.glossary-filler-img {
  width: 180px;
  height: auto;
  object-fit: contain;
  opacity: 0.7;
  flex-shrink: 0;
}
.glossary-letters {
  display: flex;
  flex-wrap: wrap;
  gap: 2em;
  justify-content: center;
  flex: 1 1 0;
  min-width: 0;
}
.glossary-letter {
  position: relative;
  min-width: 48px;
  background: none;
  box-shadow: none;
}
.glossary-letter-btn {
  width: 56px;
  height: 56px;
  background: var(--acc, #b57edc);
  color: #fff;
  font-size: 1.5em;
  font-weight: bold;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid var(--card-border, #b57edc);
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  margin: 0.5em auto;
}
.glossary-term {
  margin-bottom: 1em;
  padding: 0.5em 0;
  color: var(--card-text, #222244);
  display: flex;
  flex-direction: column;
}
.glossary-word {
  font-weight: bold;
  font-size: 1.1em;
  margin-bottom: 0.2em;
}
.glossary-definition {
  font-size: 1em;
  line-height: 1.6;
}
.glossary-highlight {
  background: var(--nav-hover, #e7875b);
  color: var(--card-bg, #fff);
  border-radius: 4px;
  padding: 0 0.2em;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

/* Related Characters & IRL Tag */
.related-tag {
  font-weight: bold;
  margin-right: 0.5em;
  color: #b36b00;
}
.related-character-btn {
  background: #f5e6c8;
  border: 1px solid #b36b00;
  border-radius: 4px;
  padding: 0.2em 0.6em;
  margin: 0 0.2em;
  cursor: pointer;
  font-size: 1em;
}
.related-character-btn:hover {
  background: #ffe6a0;
}
.irl-tag {
  color: #e7b53b;
  font-weight: bold;
  font-size: 1.1em;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  border: 1px solid #e7b53b;
  display: inline-block;
  margin-top: 0.5em;
}

/* Glossary Modal & Entry List Modal */
.glossary-modal,
.entry-list-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0; top: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.6);
  justify-content: center;
  align-items: center;
}
.glossary-modal.show,
.entry-list-modal.show {
  display: flex;
}
.glossary-modal-content,
.entry-list-modal-content {
  background: var(--card-bg, #fff);
  color: var(--card-text, #222);
  padding: 2em;
  border-radius: 12px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 24px #0006;
  position: relative;
  text-align: left;
  margin: auto;
}
.entry-list-modal-content {
  max-width: 400px;
  max-height: 70vh;
  padding-right: 2.5em;
}
.glossary-modal-close,
.entry-list-modal-close {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  font-size: 2em;
  cursor: pointer;
  color: var(--acc, #b57edc);
  z-index: 10;
}

/* Entry List Modal List */
.entry-list-modal-content ul {
  margin-top: 2.5em;
  width: 100%;
  max-height: 50vh;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--card-border, #e7875b) var(--card-bg, #3b3b3b);
}
.entry-list-modal-content ul::-webkit-scrollbar {
  width: 8px;
  background: var(--card-bg, #3b3b3b);
}
.entry-list-modal-content ul::-webkit-scrollbar-thumb {
  background: var(--card-border, #e7875b);
  border-radius: 4px;
}
.entry-list-modal-content li {
  margin-bottom: 2em;
  list-style: none;
}
.entry-list-modal-content .glossary-word {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5em 2em 0.5em 0.5em;
  font-size: 1em;
  font-weight: normal;
  letter-spacing: 0.5px;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}
.entry-list-modal-content .glossary-word:hover,
.entry-list-modal-content .glossary-word:focus {
  background: var(--nav-hover, #b57edc);
  color: var(--nav-active-text, #222244);
  outline: none;
}
.entry-list-modal-content h2#entry-list-modal-title {
  margin-bottom: 0.5em;
  padding-bottom: 0.25em;
  border-bottom: 2px solid var(--card-border, #e7875b);
  font-size: 1.5em;
  font-weight: bold;
  letter-spacing: 1px;
}

/* Era Filter Buttons */
.era-filters {
  display: flex;
  justify-content: center;
  gap: 1em;
  margin-bottom: 2em;
  flex-wrap: wrap;
  text-align: center;
  margin-top: 2em;
}
.era-btn {
  background: var(--acc, #b57edc);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 0.7em 1.5em;
  font-size: 1em;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s, color 0.2s;
}
.era-btn.active,
.era-btn:hover {
  background: var(--nav-active, #e7875b);
  color: #fff;
}
.era-btn:focus {
  outline: none;
  background: var(--nav-active, #0077cc);
  color: #fff;
}

/* Responsive Adjustments */
@media (max-width: 900px) {
  .glossary-row { gap: 1em; }
  .glossary-filler-img { width: 64px; }
  .glossary-letters { gap: 1em; }
}
@media (max-width: 600px) {
  .glossary-row { flex-direction: column; gap: 0.5em; }
  .glossary-filler-img { width: 48px; min-width: 32px; height: 48px; }
  .glossary-letters { gap: 1em; }
  .era-filters { flex-direction: column; gap: 0.3em; }
  .era-btn { width: 100%; font-size: 1.1em; }
}