@font-face {
  font-family: LHF_Billhead_1890;
  src: url(../../media/fonts/lhf_billhead_18901.ttf);
}

@font-face {
  font-family: Cruickshank;
  src: url(../../media/fonts/CRUICKSH.TTF);
}

@font-face {
  font-family: CherrySwash-Regular;
  src: url(../../media/fonts/GoogleFonts/Cherry_Swash/CherrySwash-Regular.ttf);
}

@font-face {
  font-family: SCOREBOARD;
  src: url(../../media/fonts/SCOREBOARD.ttf);
}

:root {
  --page: #0e1010;
  --panel: rgba(18, 20, 21, 0.94);
  --panel-soft: rgba(30, 29, 26, 0.9);
  --line: rgba(225, 208, 168, 0.24);
  --text: #f1eadc;
  --muted: #afa898;
  --gold: #c89b3c;
  --blue: #6cb6d9;
  --red: #8d3b32;
  --input: #202324;
}

* {
  box-sizing: border-box;
}

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  background: linear-gradient(90deg, rgba(6, 7, 7, 0.9), rgba(6, 7, 7, 0.58), rgba(6, 7, 7, 0.9));
  color: var(--text);
  font-family: CherrySwash-Regular, Georgia, serif;
}

button,
select,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #251d19;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: rgba(200, 155, 60, 0.78);
  background: #352720;
  color: white;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 66px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(225, 208, 168, 0.2);
  background: rgba(8, 9, 9, 0.92);
}

.header-title h1 {
  margin: 0;
  font-family: Cruickshank, Georgia, serif;
  font-size: clamp(29px, 4vw, 43px);
  font-weight: normal;
  letter-spacing: 0;
}

.right-controls {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.right-controls button {
  min-height: 40px;
  padding: 5px 12px;
  border-radius: 5px;
  font-family: LHF_Billhead_1890, Georgia, serif;
  font-size: 24px;
}

.almanach-layout {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) minmax(470px, 46vw);
  gap: 10px;
  min-height: 0;
  height: 100%;
  padding: 10px;
}

.almanach-left,
.hunter-stage,
.hunter-browser {
  min-width: 0;
  min-height: 0;
}

.almanach-left {
  display: flex;
  flex-direction: column;
}

.hunter-stage,
.hunter-browser {
  border: 1px solid rgba(225, 208, 168, 0.18);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.24);
}

.hunter-stage {
  flex: 1 1 auto;
  overflow: hidden;
}

.hunter-detail {
  display: grid;
  grid-template-columns: minmax(270px, 1.1fr) minmax(300px, 0.90fr);
  gap: 12px;
  height: 100%;
  padding: 10px;
}

.hunter-detail .image {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(13, 15, 15, 0.36), rgba(13, 15, 15, 0.9)),
    #080909;
  perspective: 1000px;
}

#hunterImage {
  max-width: 100%;
  max-height: 100%;
  padding: 6px;
  object-fit: contain;
  transform-origin: center center;
  backface-visibility: hidden;
  transition: transform 0.36s ease, opacity 0.18s ease;
  will-change: transform;
}

.hunter-ref-stage.is-flipping-forward #hunterImage {
  transform: rotateY(180deg);
}

.hunter-ref-stage.is-flipping-backward #hunterImage {
  transform: rotateY(-180deg);
}

.info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 8px 10px 8px 4px;
}

#hunterName {
  margin: 0;
  color: #fff7e7;
  font-family: CherrySwash-Regular, Georgia, serif;
  font-size: clamp(28px, 2.7vw, 38px);
  font-weight: normal;
  line-height: 1.05;
  letter-spacing: 0;
}

.hunter-aka {
  min-height: 1.4em;
  margin: 5px 0 12px;
  color: var(--muted);
  font-size: 18px;
}

.hunter-meta {
  flex: 0 0 auto;
  display: grid;
  gap: 4px;
  margin: 0 0 14px;
  font-size: 18px;
  line-height: 1.38;
}

.hunter-meta-row {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.hunter-meta-row-short {
  grid-template-columns: 68px minmax(0, 1fr);
}

.hunter-meta-row-date {
  grid-template-columns: 132px minmax(0, 1fr);
}

.hunter-meta dt,
.lore-title {
  color: var(--gold);
  font-size: 18px;
}

.hunter-meta dt {
  white-space: nowrap;
}

.hunter-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.lore {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.lore-title {
  flex: 0 0 auto;
  margin-bottom: 5px;
}

.lore-text {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid rgba(225, 208, 168, 0.19);
  border-radius: 6px;
  background: rgba(9, 10, 10, 0.58);
  line-height: 1.38;
  font-size: 18px;
}

.hunter-wiki {
  flex: 0 0 auto;
  margin-top: 10px;
  font-size: 18px;
  line-height: 1.38;
}

.hunter-wiki[hidden] {
  display: none;
}

.hunter-wiki a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 4px 12px;
  border: 1px solid rgba(245, 222, 179, 0.45);
  border-radius: 6px;
  color: #fff7e7;
  background: rgba(33, 25, 20, 0.72);
  text-decoration: none;
}

.hunter-wiki a:hover,
.hunter-wiki a:focus-visible {
  border-color: rgba(245, 222, 179, 0.9);
  color: #ffffff;
}

.hunter-trailer {
  flex: 0 0 auto;
  margin-top: 12px;
}

.hunter-trailer[hidden] {
  display: none;
}

.hunter-trailer-title {
  margin-bottom: 5px;
  color: var(--gold);
  font-size: 18px;
}

.hunter-trailer-frame {
  position: relative;
  width: 100%;
  height: clamp(150px, 21vh, 240px);
  overflow: hidden;
  border: 1px solid rgba(225, 208, 168, 0.19);
  border-radius: 6px;
  background: rgba(9, 10, 10, 0.58);
}

.hunter-trailer-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.hunter-browser {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.controls {
  z-index: 2;
  padding: 10px;
  border-bottom: 1px solid rgba(225, 208, 168, 0.18);
  background: rgba(9, 10, 10, 0.86);
}

.controls-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.controls-row + .controls-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(225, 208, 168, 0.1);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 175px;
  min-width: 0;
}

.control-group label {
  flex: 0 0 auto;
  color: var(--muted);
  white-space: nowrap;
}

.control-group input,
.control-group select {
  width: 100%;
  min-height: 32px;
  min-width: 0;
  padding: 4px 7px;
  border: 1px solid rgba(225, 208, 168, 0.18);
  border-radius: 5px;
  background: var(--input);
  color: var(--text);
}

.control-sort {
  flex: 0 1 310px;
}

.controls-row-search .control-group {
  flex-basis: 260px;
}

.controls-row-filter .control-group {
  flex-basis: 155px;
}

#sortDirection {
  flex: 0 0 56px;
  min-height: 32px;
  border-radius: 5px;
  font-size: 13px;
}

.head-counter {
  margin: 0;
  color: var(--muted);
  white-space: nowrap;
}

#headCounter {
  display: inline-block;
  min-width: 3ch;
  color: var(--blue);
  font-family: SCOREBOARD, monospace;
  font-size: 26px;
  line-height: 1;
  text-align: right;
  transform-origin: center;
}

#headCounter.is-updating {
  animation: head-count-tick 0.28s ease-out;
}

@keyframes head-count-tick {
  0% {
    color: var(--gold);
    transform: scale(1.14);
    text-shadow: 0 0 9px rgba(200, 155, 60, 0.65);
  }
  100% {
    color: var(--blue);
    transform: scale(1);
    text-shadow: none;
  }
}

.browser-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  background: rgba(9, 10, 10, 0.86);
}

.browser-heading h2 {
  margin: 0;
  font-family: Cruickshank, Georgia, serif;
  font-size: 26px;
  font-weight: normal;
  letter-spacing: 0;
}

.matrix {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
}

.matrix-item {
  width: 92px;
  height: 92px;
  padding: 2px;
}

.matrix-item img {
  display: block;
  width: 88px;
  height: 88px;
  border: 1px solid rgba(225, 208, 168, 0.28);
  border-radius: 4px;
  object-fit: cover;
  background: #070808;
  cursor: pointer;
}

.matrix-item img:hover {
  border-color: rgba(255, 255, 255, 0.85);
}

.matrix-item img.active {
  border: 2px solid var(--blue);
  box-shadow: 0 0 0 2px rgba(108, 182, 217, 0.17), 0 0 12px rgba(108, 182, 217, 0.55);
}

.hunter-ref-button,
.hunter-ref-nav,
.hunter-ref-overlay-toggle {
  border: 1px solid rgba(245, 222, 179, 0.65);
  background: rgba(11, 13, 16, 0.74);
  color: wheat;
}

.hunter-ref-button {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  width: 126px;
  min-height: 48px;
  max-width: calc(100% - 24px);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 15px;
  line-height: 1.1;
  text-align: center;
  white-space: normal;
  background: rgba(11, 13, 16, 0.78);
  color: rgba(245, 222, 179, 0.94);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.48);
  text-shadow: 0 1px 2px black;
}

.hunter-ref-stage.is-reference-mode .hunter-ref-button {
  right: 68px;
  bottom: 10px;
  z-index: 6;
  width: auto;
  min-width: 56px;
  min-height: 30px;
  padding: 4px 9px;
  font-size: 14px;
  line-height: 1.15;
}

.hunter-ref-nav {
  position: absolute;
  top: 50%;
  z-index: 4;
  width: 34px;
  height: 48px;
  padding: 0;
  margin: 0;
  border-radius: 6px;
  font-size: 34px;
  line-height: 1;
  transform: translateY(-50%);
}

.hunter-ref-nav[hidden],
.hunter-variant-nav[hidden] {
  display: none;
}

.hunter-ref-nav-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  font-family: Arial, sans-serif;
  transform: translate(-50%, -50%);
}

.hunter-ref-prev {
  left: 10px;
}

.hunter-ref-next {
  right: 10px;
}

.hunter-ref-overlay {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 5;
  max-height: 46%;
  overflow-y: auto;
  padding: 10px 56px 10px 12px;
  border: 1px solid rgba(245, 245, 245, 0.25);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.78);
  color: #f4f0e7;
  font-size: 15px;
  line-height: 1.3;
}

.hunter-ref-stage.is-reference-mode .hunter-ref-overlay:not(.is-text-hidden) {
  padding-bottom: 46px;
}

.hunter-ref-title {
  margin-bottom: 3px;
  color: wheat;
  font-size: 19px;
}

.hunter-ref-meta {
  margin-bottom: 6px;
  color: #b8c4d4;
  font-size: 12px;
}

.hunter-ref-text {
  margin-bottom: 6px;
}

.hunter-ref-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hunter-ref-links a {
  color: var(--blue);
  text-decoration: none;
}

.hunter-ref-links a:hover {
  text-decoration: underline;
}

.hunter-ref-overlay-toggle {
  position: absolute;
  right: 8px;
  top: 8px;
  margin: 0;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 12px;
}

.hunter-ref-overlay.is-text-hidden {
  left: auto;
  right: 10px;
  bottom: 10px;
  width: auto;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.hunter-ref-overlay.is-text-hidden .hunter-ref-title,
.hunter-ref-overlay.is-text-hidden .hunter-ref-meta,
.hunter-ref-overlay.is-text-hidden .hunter-ref-text,
.hunter-ref-overlay.is-text-hidden .hunter-ref-links {
  display: none;
}

.hunter-ref-overlay.is-text-hidden .hunter-ref-overlay-toggle {
  position: static;
  min-height: 30px;
  padding: 4px 9px;
  font-size: 14px;
  line-height: 1.15;
}

.hunter-ref-fallback {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.66);
  color: wheat;
  font-size: 14px;
  transform: translate(-50%, -50%);
}

.hunter-variant-nav {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  border: 1px solid rgba(245, 222, 179, 0.35);
  border-radius: 6px;
  background: rgba(11, 13, 16, 0.48);
}

.hunter-variant-label {
  padding: 0 5px 0 3px;
  color: rgba(245, 222, 179, 0.96);
  font-size: 14px;
  line-height: 28px;
  text-shadow: 0 1px 2px black;
}

.hunter-variant-button {
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  border-radius: 4px;
  border: 1px solid rgba(245, 222, 179, 0.65);
  background: rgba(11, 13, 16, 0.54);
  color: wheat;
  font-size: 15px;
  line-height: 26px;
  text-align: center;
  text-shadow: 0 1px 2px black;
}

.hunter-variant-button.active,
.hunter-variant-button:disabled {
  background: rgba(245, 222, 179, 0.9);
  color: #0b0d10;
  cursor: default;
  text-shadow: none;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .almanach-layout {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .almanach-left {
    grid-template-rows: auto auto;
  }

  .hunter-detail {
    grid-template-columns: 1fr;
    min-height: 720px;
  }

  .hunter-detail .image {
    min-height: 420px;
  }

  .hunter-browser {
    min-height: 520px;
  }

  .controls-row {
    align-items: stretch;
  }

  .control-group {
    flex: 1 1 220px;
  }

  .head-counter {
    padding-top: 6px;
  }
}

@media (max-width: 560px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .right-controls {
    width: 100%;
  }

  .right-controls button {
    width: 100%;
  }

  .hunter-detail {
    min-height: 680px;
  }

  .hunter-detail .image {
    min-height: 340px;
  }

  .hunter-meta-row {
    grid-template-columns: 1fr;
  }

  .matrix-item {
    width: 76px;
    height: 76px;
  }

  .matrix-item img {
    width: 72px;
    height: 72px;
  }
}
