:root{
  /* tarot / parchment palette */
  --bg:#0f0a06;            /* deep near-black for outer frame */
  --parchment:#efe6d8;     /* warm parchment for cards */
  --card:linear-gradient(180deg,#fffaf2,#f2e9da);
  --muted:#6a5a48;
  --accent:#7a2f2f;        /* deep burgundy */
  --gold:#d4b063;          /* muted gold */
  --glass: rgba(255,250,240,0.04);
  --scroll-track: rgba(15,10,6,0.18); /* subtle dark translucent track (18%) */
  --scroll-thumb: rgba(180,130,85,0.7); /* warm gold-brown thumb at 70% */
  --scroll-thumb-hover: rgba(180,130,85,0.85);
  font-family: "Georgia", "Palatino Linotype", "Times New Roman", serif;
  color:var(--parchment);
}

/* fluid type scale for better readability across sizes */
html { font-size: 16px; }
@media (min-width:1200px){ html { font-size: 18px; } }
@media (max-width:420px){ html { font-size: 14px; } }

*{box-sizing:border-box}
html,body,#app{height:100%}
body{
  margin:0;
  /* subtle starry vignette + parchment center */
  background:
    radial-gradient(ellipse at 10% 10%, rgba(212,176,99,0.06) 0%, transparent 20%),
    radial-gradient(ellipse at 90% 90%, rgba(138,43,43,0.04) 0%, transparent 18%),
    linear-gradient(180deg,#080505 0%, #0f0a06 40%, #0f0a06 100%);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  display:flex;
  align-items:flex-start;
  justify-content:center;
  padding:16px;
  min-height:100vh;
  box-sizing:border-box;
}

/* ornate container to feel like a tarot board */
main#app{
  width:100%;
  max-width:1100px;
  background:
    radial-gradient(1200px 400px at 50% 0%, rgba(212,176,99,0.02), transparent 20%),
    var(--glass);
  border-radius:14px;
  padding:18px;
  box-shadow:
    0 10px 40px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(255,255,255,0.02);
  display:grid;
  grid-template-columns: 1fr minmax(280px, 380px);
  gap:18px;
  align-items:start;
  max-height: calc(100vh - 32px);
  overflow: hidden;
  border: 1px solid rgba(212,176,99,0.08);
}

/* mobile adapt: single column */
@media (max-width:820px){
  /* allow vertical scrolling on the app container so grid tiles aren't clipped on small screens */
  main#app{grid-template-columns:1fr; padding:12px; min-height:640px; overflow:auto; -webkit-overflow-scrolling:touch;}
  #panel{position:fixed; inset:auto 0 0 0; height:50%; border-radius:12px 12px 0 0; transform:translateY(100%); transition:transform .28s ease; z-index:30}
  #panel.open{transform:translateY(0)}
}

/* narrow phones: ensure content fits one-screen height */
@media (max-height:640px) and (max-width:480px){
  main#app{min-height:520px; padding:10px}
  #panel{height:54%}
}

/* header */
header{padding:6px 8px}
.siteTitle{
  font-size:18px;
  color:var(--gold);
  font-weight:700;
  letter-spacing:1px;
  margin:0 0 6px 0;
}
h1{
  margin:6px 0 2px;
  font-size:20px;
  color:var(--gold);
  text-shadow: 0 2px 0 rgba(0,0,0,0.6);
  letter-spacing:1px;
  font-weight:700;
}
.subtitle{margin:0; color:var(--parchment); opacity:0.9; font-size:13px}

/* grid of 22 — responsive auto-fit with minimums */
#grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap:14px;
  padding:12px;
  align-items:stretch;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.01), transparent 30%);
  border-radius:10px;
  border:1px dashed rgba(212,176,99,0.04);
}
@media (max-width:1100px){
  #grid{grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap:10px; padding:10px}
}
@media (max-width:820px){
  #grid{grid-template-columns: repeat(auto-fit, minmax(56px, 1fr)); gap:8px; padding:8px}
}

/* tiles styled like small tarot plates */
.tile{
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.02)),
    var(--parchment);
  border-radius:12px;
  padding:12px;
  box-shadow:
    0 8px 24px rgba(0,0,0,0.6),
    inset 0 -2px 0 rgba(0,0,0,0.04);
  display:flex;
  flex-direction:column;
  gap:8px;
  align-items:center;
  justify-content:center;
  min-height:92px;
  cursor:pointer;
  transition:transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  user-select:none;
  text-align:center;
  padding-inline:12px;
  border:1px solid rgba(122,47,47,0.06);
}
.tile:active{transform:translateY(2px)}
.tile:hover{
  transform:translateY(-6px) rotate(-0.6deg);
  box-shadow:0 18px 46px rgba(0,0,0,0.75);
  border-color: rgba(212,176,99,0.14);
}
/* clamp ensures letters scale smoothly across sizes */
.letter{
  font-size: clamp(22px, 4.2vw, 42px);
  font-weight:800;
  line-height:1;
  color:#2b1b12;
  text-shadow: 0 3px 0 rgba(255,255,255,0.08), 0 1px 12px rgba(122,47,47,0.06);
}
.name{
  font-size: clamp(11px, 1.8vw, 13px);
  color:var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:100%;
  letter-spacing:0.6px;
  font-style:italic;
}

/* modal (centered card) */
#modal{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(4,3,2,0.55);
  z-index:60;
  opacity:0;
  pointer-events:none;
  transition:opacity .18s ease;
}
#modal.open{
  opacity:1;
  pointer-events:auto;
}
#modalCard{
  width:min(720px, calc(100% - 48px));
  max-height:84vh;
  overflow:auto;
  background:
    linear-gradient(180deg,#fff8ef,#f1e6d3);
  border-radius:12px;
  padding:18px;
  position:relative;
  box-shadow:
    0 30px 80px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(255,255,255,0.04);
  border:1px solid rgba(122,47,47,0.08);
}
#close{
  position:absolute;
  right:10px;
  top:8px;
  background:transparent;
  border:none;
  color:var(--accent);
  font-size:18px;
  cursor:pointer;
  padding:6px;
}
#detail h2{
  margin:6px 0 0;
  font-size:18px;
  color:#6a3b2b;
  letter-spacing:0.6px;
}
/* ensure modal h3 headings match h2 color for visual consistency */
#modalCard h3,
#modalCard h3 a {
  margin:6px 0 2px;
  font-size:14px;
  color:#6a3b2b;
  letter-spacing:0.4px;
}
.row{display:flex;gap:8px;align-items:center;margin:8px 0}
.badge{
  background:linear-gradient(180deg,#fffaf2,#f4e9d8);
  border-radius:10px;
  padding:10px 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  font-weight:700;
  letter-spacing:.8px;
  color:#3b2314;
  border:1px solid rgba(0,0,0,0.06);
}
.small{font-size:13px; color:var(--muted); line-height:1.4}

.footer{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--muted);margin-top:10px;}

/* floating home / article / info buttons */
#homeBtn,
#articleBtn,
#infoBtn{
  position:fixed;
  right:20px;
  width:48px;
  height:48px;
  border-radius:50%;
  color:var(--parchment);
  border: 2px solid rgba(212,176,99,0.12);
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
  font-weight:700;
  font-size:18px;
  cursor:pointer;
  z-index:70;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: background .12s ease, transform .08s ease;
}

/* home button above article */
#homeBtn{
  bottom:140px;
  /* semi-transparent (70%) warm gradient */
  background: linear-gradient(180deg, rgba(138,107,74,0.7), rgba(120,89,59,0.7));
}

/* article button sits between home and info */
#articleBtn{
  bottom:80px;
  /* semi-transparent (70%) muted gradient */
  background: linear-gradient(180deg, rgba(106,90,72,0.7), rgba(90,74,58,0.7));
}

/* info button lower */
#infoBtn{
  bottom:20px;
  /* semi-transparent (70%) accent gradient */
  background: linear-gradient(180deg, rgba(122,47,47,0.7), rgba(90,31,31,0.7));
}

/* remove transparency on hover / focus / active for better affordance */
#homeBtn:hover,
#homeBtn:focus,
#homeBtn:active{
  background: linear-gradient(180deg, rgb(138,107,74), rgb(120,89,59));
  transform:translateY(-4px);
  outline: none;
}
#articleBtn:hover,
#articleBtn:focus,
#articleBtn:active{
  background: linear-gradient(180deg, rgb(106,90,72), rgb(90,74,58));
  transform:translateY(-4px);
  outline: none;
}
#infoBtn:hover,
#infoBtn:focus,
#infoBtn:active{
  background: linear-gradient(180deg, rgb(122,47,47), rgb(90,31,31));
  transform:translateY(-4px);
  outline: none;
}

/* small modal for info text */
#infoModal{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(4,3,2,0.45);
  z-index:80;
  opacity:0;
  pointer-events:none;
  transition:opacity .18s ease;
}
#infoModal.open{
  opacity:1;
  pointer-events:auto;
}
.modalCardSmall{
  width:min(480px, calc(100% - 48px));
  max-height:60vh;
  overflow:auto;
  background:
    linear-gradient(180deg,#fff8ef,#f1e6d3);
  border-radius:10px;
  padding:14px;
  position:relative;
  box-shadow:
    0 22px 60px rgba(0,0,0,0.65),
    inset 0 1px 0 rgba(255,255,255,0.03);
  border:1px solid rgba(122,47,47,0.06);
}
.modalCardSmall .closeInfo{
  position:absolute;
  right:8px;
  top:6px;
  background:transparent;
  border:none;
  color:var(--accent);
  font-size:16px;
  cursor:pointer;
  padding:6px;
}
.modalCardSmall h2{ margin:8px 0 4px; color:#6a3b2b; }
.modalCardSmall .small{ color:var(--muted); line-height:1.4; margin:0; }

/* responsive image inside the info modal */
.modalCardSmall .infoImage{
  display:block;
  width:100%;
  max-width:420px;
  height:auto;
  margin-top:12px;
  border-radius:8px;
  box-shadow:0 12px 36px rgba(0,0,0,0.55);
  border:1px solid rgba(122,47,47,0.06);
  background:linear-gradient(180deg,#fff8ef,#f1e6d3);
  align-self:center;
}
@media (max-width:420px){
  .modalCardSmall .infoImage{ max-width:320px; }
}

/* ensure info modal uses custom scrollbars */
.modalCardSmall{ scrollbar-gutter: stable; }

/* subtle decorative emblems using pseudo-elements */
header::before{
  content:"✦";
  display:block;
  font-size:22px;
  color:var(--gold);
  opacity:0.85;
  transform:translateY(-4px);
}

/* ensure internal scrolling when content is taller than available space */
#grid{ overflow:auto; -webkit-overflow-scrolling:touch; }

/* on wider screens limit grid height to keep modal centered */
@media (min-width:821px){
  #grid{ max-height: calc(100vh - 160px); }
}

/* on small screens keep modal card size reasonable */
@media (max-width:820px){
  main#app{ max-height: 100vh; }
  #modalCard{ width: calc(100% - 28px); max-height:70vh; }
}

/* Custom thin semi-transparent scrollbars matching the tarot palette */
/* WebKit-based browsers (Chrome, Safari, Edge) */
*::-webkit-scrollbar{
  height:10px;
  width:10px;
}
*::-webkit-scrollbar-track{
  background: var(--scroll-track);
  border-radius:10px;
}
*::-webkit-scrollbar-thumb{
  background: var(--scroll-thumb);
  border-radius:10px;
  border: 2px solid rgba(255,250,240,0.06);
}
*::-webkit-scrollbar-thumb:hover{
  background: var(--scroll-thumb-hover);
}

/* Firefox: thin scrollbar with translucent colors */
*{
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

/* ensure modal card and grid use the custom scrollbars clearly */
#grid, #modalCard{
  scrollbar-gutter: stable;
}