:root {
  --ink: #07060a;
  --navy: #101525;
  --panel: rgba(10, 12, 20, 0.88);
  --gold: #d4b056;
  --gold-dim: #8a7030;
  --ivory: #f3e6c4;
  --muted: #b7a88a;
  --danger: #a33b4a;
  --ok: #6ea56a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #05040a;
  color: var(--ivory);
  font-family: "Cormorant Garamond", Georgia, serif;
  overflow: hidden;
}

button {
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: .08em;
  cursor: pointer;
}

.hidden { display: none !important; }

.screen { position: absolute; inset: 0; }

#title {
  background: #05040a url("../assets/art/cantifold-banner.png") center 38% / cover no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 6vh 8vw 7vh;
}
#title::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(5,4,10,.18) 8%, rgba(5,4,10,.42) 48%, rgba(5,4,10,.94) 100%);
  pointer-events: none;
}
#title .inner { position: relative; z-index: 1; max-width: 920px; }
#title h1 {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700;
  font-size: clamp(42px, 6vw, 84px);
  margin: 0 0 6px;
  letter-spacing: .18em;
  line-height: .95;
}
#title h1 span {
  display: block;
  font-size: .42em;
  letter-spacing: .42em;
  color: var(--gold);
  margin-bottom: 10px;
}
#title .sub {
  font-size: 22px;
  color: var(--muted);
  margin: 0 0 28px;
  max-width: 640px;
}
.row-btns { display: flex; gap: 14px; flex-wrap: wrap; }
.btn {
  background: transparent;
  color: var(--ivory);
  border: 1px solid var(--gold);
  padding: 12px 22px;
  font-size: 13px;
  text-transform: uppercase;
}
.btn:hover { background: rgba(212,176,86,.16); }
.btn.solid { background: var(--gold); color: #1a1408; border-color: var(--gold); }
.btn.solid:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .4; cursor: default; }

#folds, #rules, #gallery, #campaign, #deckbuild {
  background: #0b0c14;
  overflow: auto;
  padding: 36px 48px 60px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 22px;
}
.topbar h2 {
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: .16em;
  font-size: 22px;
  margin: 0;
  color: var(--gold);
}
.pick-note { color: var(--muted); margin: 0 0 18px; font-size: 18px; }
.rules-col { max-width: 72ch; font-size: 18px; line-height: 1.5; color: var(--ivory); }
.rules-col h3 {
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: .1em;
  color: var(--gold);
  font-size: 16px;
  margin: 28px 0 8px;
}
.rules-col ul { padding-left: 1.2em; }
.rules-col li { margin: 0 0 8px; }

.fold-grid, .campaign-grid, .gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
#galleryFilters .btn {
  font-size: 11px;
  padding: 8px 14px;
}
.fold-card, .campaign-card, .gallery-card {
  border: 1px solid #3a3428;
  background: #11141c;
  padding: 18px 18px 20px;
  cursor: pointer;
  min-height: 220px;
}
.fold-card:hover, .campaign-card:hover { border-color: var(--gold); }
.fold-card.you { box-shadow: inset 0 0 0 2px var(--gold); }
.fold-card.foe { box-shadow: inset 0 0 0 2px #8a5cb3; }
.fc-glyph {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  font-size: 28px;
  border: 1px solid var(--fold);
  background: color-mix(in srgb, var(--fold) 22%, #0a0a12);
  margin-bottom: 12px;
}
.fold-card h3, .campaign-card h3, .gallery-card h3 {
  font-family: "Cinzel", Georgia, serif;
  margin: 6px 0 4px;
  letter-spacing: .04em;
  font-size: 20px;
}
.fold-card p, .campaign-card p, .gallery-card p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.35;
}
.epi { color: var(--gold) !important; font-style: italic; margin-bottom: 8px !important; }
.kind {
  margin: 0;
  font-family: "Cinzel", Georgia, serif;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
}

.gallery-card { padding: 0; overflow: hidden; cursor: default; }
.g-wash, .pin-art {
  height: 88px;
  display: grid;
  place-items: center;
  font-size: 36px;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--fold) 55%, #0a0a12), #0a0a12 72%);
  border-bottom: 1px solid #3a3428;
}
.gallery-card .copy { padding: 12px 14px 16px; }

.deck-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; }
.deck-h { font-family: "Cinzel", Georgia, serif; color: var(--gold); letter-spacing: .1em; font-size: 14px; }
.deck-list { display: grid; gap: 6px; }
.deck-item {
  border: 1px solid #3a3428;
  padding: 8px 10px;
  cursor: pointer;
}
.deck-item.on { border-color: var(--gold); background: rgba(212,176,86,.08); }
.deck-item b { font-family: "Cinzel", Georgia, serif; font-size: 14px; }
.deck-item .mini { color: var(--muted); font-size: 13px; }

#stage {
  position: absolute; inset: 0;
  background: #08070d;
  overflow: hidden;
}
#stage-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, color-mix(in srgb, var(--you, #d4b056) 18%, transparent), transparent 42%),
    radial-gradient(ellipse at 70% 80%, color-mix(in srgb, var(--foe, #8a5cb3) 16%, transparent), transparent 46%);
  filter: blur(8px);
}
#hud {
  position: absolute; left: 0; right: 0; top: 0; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  background: linear-gradient(#141821, rgba(12,13,22,.9));
  border-bottom: 1px solid #2f2a20;
  z-index: 5;
}
#hud .title {
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: .2em;
  font-size: 13px;
  color: var(--gold);
}
#hud .phase { font-size: 18px; }
.hud-destiny {
  font-size: 13px;
  color: var(--muted);
  text-align: right;
  max-width: 520px;
  line-height: 1.25;
}
.hud-destiny b { color: var(--gold); font-weight: 600; }

.meters { display: flex; gap: 18px; align-items: center; font-size: 16px; flex-wrap: wrap; justify-content: flex-end; }
.meters-block { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.meter-row { display: flex; gap: 18px; }
.destiny-line { font-size: 13px; color: var(--muted); }
.destiny-line .hit { color: var(--ok); }
.meter { display: flex; gap: 8px; align-items: center; }
.meter b { font-family: "Cinzel", Georgia, serif; font-size: 12px; color: var(--muted); letter-spacing: .1em; }
.pip {
  min-width: 28px; text-align: center;
  border: 1px solid #4a4030; padding: 2px 8px;
  color: var(--gold);
}

#ai-row, #you-row {
  position: absolute; left: 18px; right: 280px;
  display: flex; justify-content: space-between; align-items: center;
  z-index: 4;
}
#ai-row { top: 76px; }
#you-row { bottom: 168px; }
.who { display: flex; gap: 12px; align-items: center; }
.who-glyph {
  width: 54px; height: 54px;
  display: grid; place-items: center;
  font-size: 26px;
  border: 1px solid var(--fold);
  background: color-mix(in srgb, var(--fold) 25%, #0a0a12);
}
.who .name { font-family: "Cinzel", Georgia, serif; font-size: 15px; letter-spacing: .08em; }
.who .mini { color: var(--muted); font-size: 14px; }

#sites {
  position: absolute;
  left: 40px; right: 300px;
  top: 140px; bottom: 210px;
}
.site {
  position: absolute;
  width: 360px; height: 250px;
  border: 1px solid #3a3428;
  background: #111;
  overflow: hidden;
  cursor: pointer;
}
.site:nth-child(1) { left: 50%; top: 0; transform: translateX(-50%); }
.site:nth-child(2) { left: 4%; bottom: 0; }
.site:nth-child(3) { right: 4%; bottom: 0; }
.s-wash {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(6,5,10,.82) 0%, rgba(6,5,10,.25) 42%, rgba(6,5,10,.82) 100%),
    linear-gradient(160deg, color-mix(in srgb, var(--fold) 35%, #111), #111 70%);
}
.site .s-head { position: absolute; left: 10px; right: 10px; top: 8px; }
.site h4 {
  margin: 0;
  font-family: "Cinzel", Georgia, serif;
  font-size: 15px;
  letter-spacing: .06em;
}
.site .s-text { font-size: 13px; color: #d8c9a6; line-height: 1.25; }
.site .claims {
  position: absolute; top: 8px; right: 10px;
  font-family: "Cinzel", Georgia, serif; font-size: 12px; color: var(--gold);
}
.site .pieces {
  position: absolute; left: 8px; right: 8px; bottom: 8px;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.mini-piece {
  width: 54px; height: 74px;
  border: 1px solid var(--fold, #5a4e32);
  background: color-mix(in srgb, var(--fold) 30%, #1a140c);
  position: relative;
}
.mini-piece .mg {
  display: grid; place-items: center;
  height: 48px;
  font-size: 20px;
}
.mini-piece.ai { filter: saturate(.85); }
.mini-piece.frozen { filter: grayscale(.8) brightness(1.2); outline: 1px solid #9cf; }
.mini-piece .will {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,.72); text-align: center; color: var(--gold);
  font-family: "Cinzel", Georgia, serif; font-size: 11px;
}
.site.valid { box-shadow: 0 0 0 2px var(--gold); }
.site.contested { box-shadow: 0 0 0 2px var(--danger); }

#hand {
  position: absolute; left: 18px; right: 280px; bottom: 12px; height: 148px;
  display: flex; gap: 10px; align-items: flex-end; justify-content: center;
  z-index: 6;
}
.card {
  width: 108px; height: 148px;
  border: 1px solid #6a5a32;
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
  box-shadow: 0 8px 18px rgba(0,0,0,.45);
  transition: transform .15s ease;
  overflow: hidden;
  background: #1a140c;
}
.card .c-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, transparent 28%, rgba(8,6,4,.94) 78%),
    linear-gradient(160deg, color-mix(in srgb, var(--fold) 50%, #1a140c), #1a140c 68%);
}
.card .c-glyph {
  position: absolute; left: 0; right: 0; top: 28px;
  text-align: center;
  font-size: 32px;
  z-index: 1;
}
.card:hover { transform: translateY(-12px); z-index: 2; }
.card.selected { transform: translateY(-18px); box-shadow: 0 0 0 2px var(--gold); }
.card.unaffordable { filter: grayscale(.5) brightness(.7); }
.card .cost, .card .willstat {
  position: absolute; top: 4px; width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: "Cinzel", Georgia, serif; font-size: 11px;
  background: #1a1408; border: 1px solid var(--gold);
  z-index: 2;
}
.card .cost { left: 4px; color: var(--gold); }
.card .willstat { right: 4px; color: var(--ivory); border-color: #aaa; }
.card .cname {
  position: absolute; left: 6px; right: 6px; bottom: 22px;
  font-family: "Cinzel", Georgia, serif; font-size: 11px; letter-spacing: .03em;
  line-height: 1.15;
  z-index: 1;
}
.card .ctype {
  position: absolute; left: 6px; right: 6px; bottom: 6px;
  font-size: 10px; color: var(--gold); text-transform: uppercase; letter-spacing: .08em;
  z-index: 1;
}

#side {
  position: absolute; top: 64px; right: 0; bottom: 0; width: 268px;
  background: var(--panel);
  border-left: 1px solid #2f2a20;
  display: flex; flex-direction: column;
  z-index: 5;
}
#pin.pin {
  padding: 10px 12px 8px;
  border-bottom: 1px solid #2f2a20;
  min-height: 168px;
  font-size: 14px;
  line-height: 1.3;
}
#pin.empty { color: var(--muted); display: grid; place-items: center; font-style: italic; }
#pin .pin-copy b {
  display: block;
  font-family: "Cinzel", Georgia, serif;
  font-size: 14px;
  margin-bottom: 2px;
}
#pin .pin-copy span { color: var(--gold); font-size: 12px; }
#pin .pin-copy div { margin: 6px 0 4px; }
#pin .pin-copy i { color: var(--muted); font-size: 13px; }
#side .actions { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
#side .actions .btn { width: 100%; }
#log {
  flex: 1; overflow: auto; padding: 10px 14px 16px;
  font-size: 14px; color: var(--muted); line-height: 1.35;
  border-top: 1px solid #2f2a20;
}
#log div { margin: 0 0 8px; }
#log .you { color: var(--gold); }
#log .them { color: #8b5cb3; }

#prompt {
  position: absolute; left: 40px; right: 300px; top: 108px;
  text-align: center; z-index: 6;
  font-size: 18px; color: var(--ivory);
  text-shadow: 0 2px 10px #000;
  pointer-events: none;
}
#coach {
  position: absolute; left: 48px; right: 300px; top: 104px;
  z-index: 7;
  text-align: center;
}
#coach .coach-card {
  display: inline-block;
  background: rgba(18, 16, 10, .92);
  border: 1px solid var(--gold);
  padding: 8px 16px;
  font-size: 16px;
  color: var(--ivory);
  max-width: 680px;
}
#coach b { color: var(--gold); font-family: "Cinzel", Georgia, serif; letter-spacing: .08em; }

.modal {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(5,4,10,.72);
  display: grid; place-items: center;
}
.modal .box {
  width: min(720px, 90%);
  background: #12141c;
  border: 1px solid var(--gold-dim);
  padding: 28px 32px;
}
.modal h3 { font-family: "Cinzel", Georgia, serif; color: var(--gold); letter-spacing: .12em; margin: 0 0 12px; }
.glimpse-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.inspect {
  position: absolute; z-index: 12; width: 240px; pointer-events: none;
  background: #12141c; border: 1px solid var(--gold-dim); padding: 10px 12px;
  font-size: 14px; line-height: 1.3;
}
.inspect b { font-family: "Cinzel", Georgia, serif; display: block; margin-bottom: 4px; }

#stage.compact #hud { height: 52px; }
#stage.compact #ai-row { top: 60px; }
#stage.compact #you-row { bottom: 148px; }
#stage.compact #prompt { top: 96px; font-size: 16px; }
#stage.compact #sites { top: 122px; bottom: 188px; }
#stage.compact .site { width: 340px; height: 230px; }
#stage.compact #hand { height: 128px; }
#stage.compact .card { width: 96px; height: 128px; }
#stage.compact #side { top: 52px; width: 250px; }

@media (max-width: 900px) {
  #folds, #rules, #gallery, #campaign, #deckbuild { padding: 24px 18px 48px; }
  .deck-cols { grid-template-columns: 1fr; }
}

/* Illustrated cards share the same artwork across every game surface. */
.card .c-art { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.card .c-shade { background:linear-gradient(180deg,rgba(4,5,9,.08) 35%,rgba(4,5,9,.88) 76%,#040509 100%); }
.g-wash { height:auto; aspect-ratio:3/4; }
.g-wash .card-art, .pin-art .card-art { width:100%; height:100%; object-fit:cover; display:block; }
.pin-art { height:160px; overflow:hidden; flex-shrink:0; }
.inspect-art { width:100%; height:190px; object-fit:cover; display:block; margin-bottom:10px; }
.inspect { max-height:calc(100vh - 16px); overflow:auto; }
.piece-art { width:100%; height:100%; object-fit:cover; position:absolute; inset:0; }
.mini-piece { overflow:hidden; }
.mini-piece .will { z-index:1; }
.deck-art { width:48px; height:64px; object-fit:cover; float:left; margin-right:12px; border-radius:3px; }
.deck-item { min-height:84px; }
.site-art { width:100%; height:100%; object-fit:cover; opacity:.26; }
.site .s-wash { overflow:hidden; }
.btn { font-size:.875rem; }
#title { overflow-y:auto; }
#title h1 { line-height:1.1; }
@media(max-width:700px) {
 .topbar { flex-wrap:wrap; }
 .deck-cols { grid-template-columns:1fr; }
 .gallery-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr)); }
 #title { padding:32px 22px; }
 #title .sub { font-size:1.125rem; }
 #title h1 { font-size:clamp(2rem,10vw,4rem); }
 #title h1 span { letter-spacing:.2em; }
 .row-btns { gap:10px; }
 .btn { padding:12px 16px; }
}

.inspect { position:fixed; }
#galleryFilters { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:20px; }
#galleryFilters .btn { margin:0; font-size:.875rem; }

#title { background:radial-gradient(ellipse at 75% 35%,#263142 0%,#0d121e 42%,#05060b 80%); justify-content:center; }
#title::after { background:linear-gradient(90deg,rgba(5,6,11,.3),transparent); }
#title .inner { max-width:48%; }
#title .sub { font-size:1.375rem; line-height:1.45; margin-top:22px; }
.title-hand { position:absolute; right:7%; top:50%; width:34%; height:430px; transform:translateY(-50%); }
.title-card { position:absolute; width:65%; aspect-ratio:3/4; top:10%; left:18%; overflow:hidden; border:2px solid #998051; border-radius:12px; box-shadow:0 20px 60px #0009; background:#111723; }
.title-card img { width:100%; height:100%; object-fit:cover; }
.title-card span { position:absolute; inset:auto 0 0; padding:35px 14px 16px; font-family:Cinzel,Georgia,serif; font-size:1rem; background:linear-gradient(transparent,#07090ff5); text-align:center; }
.title-card:first-child { transform:translateX(-35%) rotate(-14deg); }
.title-card:nth-child(2) { transform:translateY(-9%); z-index:1; }
.title-card:nth-child(3) { transform:translateX(35%) rotate(14deg); }
@media(max-width:800px) {
 #title { display:block; padding:28px 24px 36px; }
 #title .inner { max-width:100%; }
 #title .sub { font-size:1.125rem; margin:16px 0 22px; }
 .title-hand { position:relative; right:auto; top:auto; width:220px; height:220px; transform:none; margin:0 auto 24px; }
 .title-card { top:6%; }
 .title-card span { font-size:.75rem; padding:25px 8px 10px; }
 #title h1 { font-size:3rem; }
}
@media(prefers-reduced-motion:reduce) { .card { transition:none; } }
/* A scrolling tabletop keeps cards readable on phones and smaller tablets. */
@media(max-width:1100px) {
 #match { overflow:auto; }
 #stage, #stage.compact { position:relative; width:100%; height:auto; min-height:100%; display:flex; flex-direction:column; gap:16px; padding:0 14px 24px; overflow:visible; }
 #stage #hud, #stage.compact #hud { position:relative; inset:auto; height:auto; min-height:72px; flex-wrap:wrap; gap:8px; padding:14px; margin:0 -14px; }
 .hud-destiny { max-width:100%; text-align:left; font-size:.875rem; }
 #stage #prompt, #stage.compact #prompt, #stage #coach { position:relative; inset:auto; text-align:left; }
 #stage #ai-row, #stage #you-row, #stage.compact #ai-row, #stage.compact #you-row { position:relative; inset:auto; flex-wrap:wrap; gap:12px; }
 .meters, .meters-block { align-items:flex-start; justify-content:flex-start; }
 .meter-row { flex-wrap:wrap; gap:12px; }
 #stage #sites, #stage.compact #sites { position:relative; inset:auto; display:grid; grid-template-columns:repeat(3,minmax(260px,1fr)); gap:14px; overflow-x:auto; padding:3px 3px 12px; scroll-snap-type:x proximity; }
 #stage .site, #stage.compact .site { position:relative; inset:auto; transform:none; width:auto; height:240px; scroll-snap-align:start; }
 .site .s-head { padding-top:24px; }
 .site .claims { left:10px; right:auto; font-size:.875rem; }
 .site .s-text { font-size:.875rem; }
 #stage #hand { position:relative; inset:auto; height:auto; min-height:194px; padding:20px 4px 6px; justify-content:flex-start; overflow-x:auto; }
 #stage .card, #stage.compact .card { width:124px; height:172px; }
 .card .cname { font-size:.875rem; bottom:25px; }
 .card .ctype { font-size:.75rem; }
 #stage #side { position:relative; inset:auto; width:100%; border:1px solid #2f2a20; }
 #pin.pin { display:grid; grid-template-columns:96px 1fr; gap:12px; min-height:144px; }
 #pin.empty { display:block; min-height:0; padding:14px; }
 .pin-art { height:128px; }
 #side .actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
 #side .actions .btn { font-size:.8rem; padding:12px 6px; }
 #log { max-height:160px; flex:auto; }
 #stage #clashBar { position:sticky !important; inset:auto !important; bottom:8px !important; transform:none !important; justify-content:center; background:#101525; padding:12px; }
 .modal { position:fixed; overflow:auto; padding:16px 0; }
 .modal .box { max-height:90vh; overflow:auto; padding:20px; }
}
.card .cname { font-size:.875rem; text-shadow:0 1px 5px #000; }
.card .ctype { font-size:.75rem; letter-spacing:.03em; }
.card .cost, .card .willstat { font-size:.8125rem; }
.kind { font-size:.75rem; }
.pin-art .card-art, .inspect-art { object-fit:contain; background:#090c12; }
.inspect-art { height:260px; }
@media(hover:none) { .inspect { display:none; } }
.card .cname { overflow-wrap:anywhere; }
#stage:has(#coach:not(.hidden)) #prompt { visibility:hidden; }
@media(min-width:1101px) {
 #stage #sites, #stage.compact #sites { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; left:20px; right:280px; top:166px; bottom:238px; }
 #stage .site, #stage.compact .site { position:relative; inset:auto; transform:none; width:auto; height:100%; }
 .site .s-head { top:34px; }
 .site .claims { left:10px; right:auto; font-size:.875rem; }
 .site .s-text { font-size:.875rem; line-height:1.4; }
 #stage #coach { top:112px; }
}
.site-art { opacity:.8; }
.s-wash::after { content:""; position:absolute; inset:0; background:linear-gradient(180deg,rgba(5,6,11,.8),rgba(5,6,11,.25) 55%,rgba(5,6,11,.6)); }
.site .s-head, .site .claims { text-shadow:0 1px 5px #000; }
