:root {
  --bg-base: #232528;
  --bg-darker: #181a1d;
  --bg-row: rgba(24, 26, 29, 0.72);
  --bg-row-hover: rgba(38, 41, 46, 0.85);
  --bg-row-active: rgba(18, 20, 22, 0.92);
  --bg-desc: rgba(18, 20, 22, 0.72);
  --lime: #ccff1e;
  --lime-border: #b8ef1a;
  --lime-glow: rgba(204, 255, 30, 0.22);
  --pink-hl: #e94173;
  --text-main: #f1f3f5;
  --text-muted: #aeb4bc;
  --divider: rgba(255, 255, 255, 0.14);
  --row-sep: rgba(255, 255, 255, 0.06);
  --font-display: 'Barlow Condensed', 'Impact', 'Arial Narrow', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== Background Atmospheric Layers ===== */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: radial-gradient(circle at 65% 35%, #2d3035 0%, #222427 55%, #1b1d20 100%);
}

.bg-diagonal {
  position: absolute;
  top: -20%;
  bottom: -20%;
  width: 240px;
  transform: skewX(-22deg);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.03) 0%,
    rgba(255, 255, 255, 0.008) 60%,
    transparent 100%
  );
}

.bg-diagonal-1 {
  left: 42%;
  width: 220px;
}

.bg-diagonal-2 {
  left: 56%;
  width: 120px;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.18) 0%,
    rgba(0, 0, 0, 0.05) 100%
  );
}

.bg-watermark {
  position: absolute;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  text-transform: uppercase;
  line-height: 0.85;
  letter-spacing: 0.02em;
  user-select: none;
  white-space: nowrap;
}

.bg-watermark-filled {
  top: -28px;
  left: -10px;
  font-size: clamp(220px, 32vw, 440px);
  color: rgba(255, 255, 255, 0.032);
}

.bg-watermark-outline {
  bottom: -40px;
  right: -30px;
  font-size: clamp(220px, 30vw, 430px);
  color: transparent;
  -webkit-text-stroke: 2px rgba(255, 255, 255, 0.055);
}

/* ===== Main Shell ===== */
.codex-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 22px 32px 24px 28px;
}

/* ===== Header ===== */
.codex-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.codex-logo {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: 46px;
  line-height: 0.95;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #ffffff;
}

/* Skewed Game Tabs */
.codex-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 4px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 126px;
  height: 36px;
  padding: 0 22px;
  background: var(--bg-darker);
  color: #e6e8ec;
  text-decoration: none;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transform: skewX(-12deg);
  border-radius: 3px;
  transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
  cursor: pointer;
}

.tab-btn > span {
  display: inline-block;
  transform: skewX(12deg);
}

.tab-btn:hover:not(.active) {
  background: #2b2e33;
  color: #ffffff;
}

.tab-btn.active {
  background: var(--lime);
  color: #141618;
  box-shadow: 0 0 18px var(--lime-glow);
}

/* Top Right Controls */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 6px;
}

.home-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 14px;
  background: rgba(20, 22, 25, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #e6e8ec;
  text-decoration: none;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transform: skewX(-12deg);
  border-radius: 3px;
  transition: all 0.15s ease;
}

.home-nav-btn > span {
  display: inline-block;
  transform: skewX(12deg);
}

.home-nav-btn:hover {
  background: var(--lime);
  border-color: var(--lime);
  color: #141618;
  box-shadow: 0 0 12px var(--lime-glow);
}

/* Language Switcher */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 5px;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 30px;
  padding: 0 11px;
  background: rgba(20, 22, 25, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transform: skewX(-12deg);
  border-radius: 3px;
  transition: all 0.15s ease;
}

.lang-btn > span {
  display: inline-block;
  transform: skewX(12deg);
}

.lang-btn:hover:not(.active) {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(42, 45, 50, 0.9);
}

.lang-btn.active {
  background: var(--lime);
  border-color: var(--lime);
  color: #141618;
  box-shadow: 0 0 12px var(--lime-glow);
}

/* ===== Main 2-Column Layout ===== */
.codex-main {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 32px;
}

/* Left Sidebar */
.codex-sidebar {
  width: clamp(280px, 28vw, 430px);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-right: 12px;
  border-right: 1px solid var(--divider);
  position: relative;
}

.codex-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 2px 6px 12px 2px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Custom thin game-style scrollbar */
.codex-list::-webkit-scrollbar {
  width: 4px;
}

.codex-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.codex-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 4px;
}

.codex-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.85);
}

.codex-list-item {
  border-bottom: 1px solid var(--row-sep);
}

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

.codex-item-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 13px 16px;
  background: var(--bg-row);
  color: #d7dbe0;
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 2px solid transparent;
  border-radius: 4px;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
  cursor: pointer;
}

.codex-item-btn:hover:not(.active) {
  background: var(--bg-row-hover);
  color: #ffffff;
}

.codex-item-btn.active {
  background: var(--bg-row-active);
  color: #ffffff;
  font-weight: 600;
  border-color: var(--lime-border);
  box-shadow: 0 0 12px rgba(184, 239, 26, 0.16), inset 0 0 8px rgba(184, 239, 26, 0.06);
}

.item-label-wrap {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #f1f3f5;
}

.item-icon svg {
  width: 19px;
  height: 19px;
}

.item-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  opacity: 0.7;
  flex-shrink: 0;
  margin-left: 8px;
}

.codex-item-btn.active .item-label-wrap {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #f1f3f5;
}

.item-icon svg {
  width: 19px;
  height: 19px;
}

.item-dot {
  opacity: 1;
}

/* Right Detail Panel */
.codex-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding-top: 2px;
  padding-right: 4px;
}

.entry-heading {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: clamp(34px, 2.7vw, 46px);
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #ffffff;
  margin-bottom: 18px;
}

.entry-media-wrap {
  width: 100%;
  margin-bottom: 18px;
}

.entry-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42);
  cursor: zoom-in;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: fadeSlideIn 0.22s ease;
}

.entry-image:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.52);
}

.entry-placeholder {
  width: 100%;
  aspect-ratio: 16 / 4.2;
  min-height: 190px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(20, 22, 25, 0.85), rgba(34, 37, 42, 0.65));
  border: 1px dashed rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeSlideIn 0.22s ease;
}

.placeholder-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
}

.placeholder-icon {
  width: 40px;
  height: 40px;
  opacity: 0.45;
}

.placeholder-text {
  font-size: 13.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
}

/* Description Bar */
.entry-description {
  width: 100%;
  background: var(--bg-desc);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  padding: 20px 26px;
  font-size: 16px;
  line-height: 1.55;
  color: #e6e9ed;
  backdrop-filter: blur(4px);
  animation: fadeSlideIn 0.22s ease;
}

.entry-description .hl {
  color: var(--pink-hl);
  font-weight: 600;
}

.hl-lime {
  color: var(--lime);
  font-weight: 600;
}

/* 3-Column Role / Info Cards attached under triptych image */
.entry-media-wrap.has-cards .entry-image {
  border-radius: 6px 6px 0 0;
}

.entry-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  animation: fadeSlideIn 0.22s ease;
}

.entry-card {
  background: rgba(24, 26, 29, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 16px 16px 20px;
}

.entry-card-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #ffffff;
  margin-bottom: 8px;
}

.entry-card-text {
  font-size: 13.5px;
  line-height: 1.5;
  color: #dcdfe4;
}

@media (max-width: 720px) {
  .entry-cards {
    grid-template-columns: 1fr;
  }
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Lightbox Modal ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 12, 14, 0.9);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.lightbox.open {
  display: flex;
}

.lightbox-img {
  max-width: 94vw;
  max-height: 88vh;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 26px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.lightbox-close:hover {
  background: var(--lime);
  color: #141618;
  border-color: var(--lime);
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  html,
  body {
    overflow: auto;
  }

  .codex-shell {
    height: auto;
    min-height: 100vh;
    padding: 16px;
  }

  .codex-header {
    flex-direction: column;
    align-items: stretch;
  }

  .lang-switcher {
    justify-content: flex-start;
  }

  .codex-main {
    flex-direction: column;
    gap: 22px;
  }

  .codex-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--divider);
    padding-right: 0;
    padding-bottom: 12px;
    max-height: 260px;
  }
}
