:root {
  --bg: #0d0b16;
  --bg2: #161226;
  --ink: #f3efe4;
  --muted: #c9c0d4;
  --gold: #e6c56a;
  --gold2: #f6e3a1;
  --ruby: #b1243a;
  --sapphire: #2a5cad;
  --stone: #1c1730;
  --panel: rgba(22, 16, 38, 0.86);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(177,36,58,0.22), transparent 42%),
    radial-gradient(ellipse at 80% 10%, rgba(42,92,173,0.22), transparent 40%),
    linear-gradient(180deg, #140f24 0%, #0d0b16 40%, #0a0912 100%);
  color: var(--ink);
  font: 16px/1.6 Georgia, "Times New Roman", serif;
  min-height: 100%;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--gold2); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
.skip {
  position: absolute; left: -999px; top: 0;
}
.skip:focus { left: 12px; top: 12px; background: #111; padding: 8px 12px; z-index: 20; }

.light-wash {
  pointer-events: none;
  position: fixed; inset: 0;
  background:
    linear-gradient(180deg, rgba(246,227,161,0.07), transparent 28%),
    repeating-linear-gradient(105deg, transparent 0 18px, rgba(177,36,58,0.03) 18px 19px, transparent 19px 36px, rgba(42,92,173,0.03) 36px 37px);
  z-index: 0;
}
.wrap { position: relative; z-index: 1; max-width: 1120px; margin: 0 auto; padding: 22px 18px 60px; }

.topnav {
  display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center;
  margin-bottom: 18px; font-size: 14px;
}
.topnav a { color: var(--gold2); text-decoration: none; border-bottom: 1px solid transparent; }
.topnav a:hover { border-bottom-color: var(--gold); }

.hero {
  text-align: center;
  margin: 0 0 28px;
}
.hero .kicker {
  margin: 0 0 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--gold);
  font-family: "Cinzel", Georgia, serif;
}
.hero h1 {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 600;
  font-size: clamp(28px, 5vw, 48px);
  line-height: 1.15;
  margin: 0 0 10px;
  color: var(--gold2);
}
.hero .lede {
  max-width: 640px;
  margin: 0 auto 18px;
  color: var(--muted);
  font-size: 17px;
}
.rose {
  width: min(280px, 58vw);
  margin: 0 auto 16px;
  filter: drop-shadow(0 0 24px rgba(230,197,106,0.35));
}
.search-row {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  margin: 8px auto 0; max-width: 640px;
}
.search-row input[type="search"] {
  flex: 1 1 260px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid #7a6230;
  border-radius: 4px;
  background: #12101c;
  color: var(--ink);
  font: 16px/1.4 Georgia, serif;
}
.search-row button, .btn {
  appearance: none;
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, #3a2a12, #24180c);
  color: var(--gold2);
  font: 600 14px/1 "Cinzel", Georgia, serif;
  letter-spacing: 0.06em;
  padding: 11px 16px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.search-row button:hover, .btn:hover { background: #4a3618; }

.floor {
  margin: 28px 0 12px;
}
.floor h2, .stacks h2, .results h2 {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 600;
  font-size: 22px;
  color: var(--gold2);
  margin: 0 0 8px;
}
.floor p, .hint { color: var(--muted); margin: 0 0 16px; }

.map-world {
  position: relative;
  background:
    linear-gradient(180deg, rgba(20,16,36,0.2), rgba(10,8,18,0.4)),
    #1a152c;
  border: 2px solid #7a6230;
  border-image: linear-gradient(135deg, #f6e3a1, #c23b4a, #3a6bb0, #f6e3a1) 1;
  padding: 18px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35), inset 0 0 40px rgba(42,92,173,0.08);
}
.map-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.wing {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  color: inherit;
  cursor: pointer;
  background: linear-gradient(180deg, #221a38 0%, #161226 100%);
  border: 1px solid #5a4860;
  border-top: 3px solid var(--gold);
  border-radius: 4px;
  padding: 16px 14px 14px;
  min-height: 110px;
  transition: background 0.15s ease, transform 0.15s ease;
}
.wing:hover, .wing:focus-visible { background: #2a2044; transform: translateY(-2px); }
.wing.glow-wing { border-top-color: #f0d78a; box-shadow: 0 0 18px rgba(230,197,106,0.28); }
.wing .w-name { display: block; font-family: "Cinzel", Georgia, serif; font-size: 16px; color: var(--gold2); margin-bottom: 4px; }
.wing .w-tag { display: block; font-size: 13px; color: var(--muted); line-height: 1.4; }
.wing .w-count { display: block; margin-top: 8px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }

.stacks, .results { margin-top: 28px; }
.hidden { display: none !important; }

.back-row { margin: 0 0 14px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin: 0 0 24px;
}
.card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: #161226;
  border: 1px solid #5a4860;
  border-top: 3px solid var(--gold);
  border-radius: 4px;
  overflow: hidden;
  min-height: 100%;
  transition: background 0.15s ease;
}
.card:hover { background: #1e1830; }
.card.coming { cursor: default; opacity: 0.9; border-top-color: #8a8070; }
.card .thumb {
  aspect-ratio: 16 / 10;
  background: #100e18;
  overflow: hidden;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 12px 14px 16px; }
.card h3 {
  font-family: "Cinzel", Georgia, serif;
  font-size: 16px;
  line-height: 1.3;
  margin: 0 0 6px;
  color: var(--gold2);
  font-weight: 600;
}
.card p { margin: 0; font-size: 14px; color: var(--muted); }
.card .open { margin-top: 10px; font-size: 13px; font-weight: 700; color: var(--gold); }
.card.glow-card {
  box-shadow: 0 0 0 1px #f0d78a, 0 0 24px rgba(230,197,106,0.4);
  animation: bookglow 2.2s ease-in-out infinite;
}
@keyframes bookglow {
  0%, 100% { box-shadow: 0 0 0 1px #f0d78a, 0 0 16px rgba(230,197,106,0.3); }
  50% { box-shadow: 0 0 0 2px #fff3c0, 0 0 28px rgba(230,197,106,0.55); }
}

.shelf-wrap {
  background: #1a1428;
  border: 1px solid #5a4860;
  border-radius: 4px;
  padding: 16px 14px 20px;
  margin: 0 0 22px;
}
.shelf-wrap h3 {
  font-family: "Cinzel", Georgia, serif;
  font-size: 16px;
  margin: 0 0 12px;
  color: var(--gold2);
}
.shelf {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 5px 6px;
  padding: 10px 6px 0;
  border-bottom: 10px solid #5a3a22;
  background: linear-gradient(180deg, #2a1c16, #1a120e);
  min-height: 150px;
}
.book {
  appearance: none;
  text-decoration: none;
  color: #f7f0dc;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  height: 132px;
  width: 28px;
  padding: 8px 4px;
  border-radius: 2px 2px 0 0;
  font: 600 10px/1.15 "Cinzel", Georgia, serif;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: inset -4px 0 0 rgba(0,0,0,0.18);
  cursor: pointer;
  display: block;
}
.book:hover { filter: brightness(1.12); }
.book.glow-book {
  width: 36px;
  height: 148px;
  outline: 2px solid #f6e3a1;
  box-shadow: 0 0 16px rgba(230,197,106,0.7), inset -4px 0 0 rgba(255,255,200,0.2);
  animation: bookglow 2.2s ease-in-out infinite;
  color: #fffdf4;
}

.pager { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; color: var(--muted); font-size: 14px; }
.pager button { cursor: pointer; }

.zoom-in .shelf-wrap, .zoom-in .cards {
  animation: zoomin 0.45s ease;
}
@keyframes zoomin {
  from { transform: scale(0.92); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .wing, .card, .glow-card, .glow-book, .zoom-in .shelf-wrap, .zoom-in .cards { animation: none; transition: none; transform: none; }
}

.foot {
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid #3a3050;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.foot a { color: var(--gold2); }

@media (max-width: 700px) {
  .map-grid { grid-template-columns: 1fr; }
  .rose { width: min(200px, 64vw); }
  .book { height: 118px; width: 24px; font-size: 9px; }
  .book.glow-book { height: 132px; width: 30px; }
}
