:root{
  --bg:#070b14;
  --panel:#0d1426;
  --panel2:#0b1020;
  --text:#e8eefc;
  --muted:#9fb0d0;
  --accent:#7c5cff;
  --accent2:#00d4ff;
  --danger:#ff4d6d;
  --ok:#39d98a;
  --border:rgba(255,255,255,0.08);
  --shadow:0 12px 30px rgba(0,0,0,0.45);
  --radius:14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";

  /* Log colors (player/enemy/system). */
  --log-player: rgba(142,240,194,0.95);
  --log-enemy: rgba(255,154,162,0.95);
  --log-system: rgba(199,179,255,0.95);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:var(--sans);
  background: radial-gradient(1200px 700px at 20% 0%, rgba(124,92,255,0.20), transparent 60%),
              radial-gradient(900px 500px at 80% 20%, rgba(0,212,255,0.16), transparent 60%),
              linear-gradient(180deg, #070b14 0%, #050812 100%),
              url('bg/rift_bg.jpg') center/cover fixed no-repeat;
  color:var(--text);
}

a{ color:inherit; text-decoration:none; }
a:hover{ text-decoration:underline; }

/* ------------------------------------------------------------------------- */
/* Game logs + tiny card thumbs */
/* ------------------------------------------------------------------------- */

.log .log-line{ margin:0 0 4px; }
.log .log-player{ color: var(--log-player); }
.log .log-enemy{ color: var(--log-enemy); }
.log .log-system{ color: var(--log-system); }

.miniThumb{
  width:46px;
  aspect-ratio: 63 / 88;
  border-radius:10px;
  overflow:hidden;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.05);
  flex:0 0 auto;
}
.miniThumb img{ width:100%; height:100%; object-fit:cover; display:block; }

.topbar{
  position:sticky;
  top:0;
  z-index:10;
  display:flex;
  gap:16px;
  align-items:center;
  justify-content:space-between;
  padding:14px 18px;
  background:rgba(7,11,20,0.65);
  backdrop-filter: blur(12px);
  border-bottom:1px solid var(--border);
}

.brand a{
  font-weight:800;
  letter-spacing:0.5px;
  font-size:18px;
}
.brand .tag{
  margin-left:12px;
  color:var(--muted);
  font-size:12px;
}

.nav a{
  margin-left:12px;
  color:var(--muted);
}
.nav a:hover{ color:var(--text); }
.nav a.donate{
  color:var(--text);
  padding:8px 12px;
  border:1px solid rgba(124,92,255,0.5);
  border-radius:999px;
  background:rgba(124,92,255,0.12);
}
.nav a.donate:hover{
  background:rgba(124,92,255,0.22);
  text-decoration:none;
}

.nav{ display:flex; align-items:center; flex-wrap:wrap; justify-content:flex-end; }

.navToggle{
  display:none;
  align-items:center;
  justify-content:center;
  width:44px;
  height:44px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.06);
  color:var(--text);
  cursor:pointer;
  font-size:18px;
  line-height:1;
}
.navToggle:hover{ background:rgba(255,255,255,0.10); }

@media (max-width: 860px){
  .topbar{ flex-wrap:wrap; gap:10px; }
  .brand .tag{ display:none; }
  .navToggle{ display:inline-flex; }
  .nav{ width:100%; display:none; margin-top:6px; padding-top:6px; border-top:1px solid var(--border); flex-direction:column; align-items:flex-start; }
  .nav.open{ display:flex; }
  .nav a{ margin:0; padding:10px 8px; width:100%; }
  .nav a.donate{ width:100%; text-align:left; }
}


.container{
  max-width:1100px;
  margin:0 auto;
  padding:24px 16px 70px;
}

.daily{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  padding:14px 16px;
  background:linear-gradient(90deg, rgba(124,92,255,0.18), rgba(0,212,255,0.12));
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow: var(--shadow);
  margin-bottom:18px;
}
.daily-label{
  color:var(--muted);
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:0.12em;
}
.daily-theme{
  font-weight:800;
  font-size:16px;
}

.panel{
  background:rgba(13,20,38,0.85);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:18px;
  margin-bottom:16px;
}

.hero{
  display:grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap:16px;
  align-items:start;
}
@media (max-width:900px){
  .hero{ grid-template-columns: 1fr; }
}

h1,h2,h3{ margin:0 0 12px; }
h1{ font-size:28px; }
h2{ font-size:20px; }
p{ color:var(--muted); line-height:1.5; }

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.06);
  color:var(--text);
  cursor:pointer;
  font-weight:650;
}
.btn:hover{ background:rgba(255,255,255,0.10); text-decoration:none; }
.btn.primary{
  border-color:rgba(124,92,255,0.7);
  background:rgba(124,92,255,0.20);
}
.btn.primary:hover{ background:rgba(124,92,255,0.28); }
.btn.danger{
  border-color:rgba(255,77,109,0.7);
  background:rgba(255,77,109,0.12);
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.05);
  color:var(--muted);
  font-size:12px;
}
.badge.ok{ color:rgba(57,217,138,0.95); border-color:rgba(57,217,138,0.35); }
.badge.warn{ color:rgba(255,217,61,0.95); border-color:rgba(255,217,61,0.25); }

.form{
  display:grid;
  gap:12px;
}
.input{
  display:grid;
  gap:6px;
}
.input label{ color:var(--muted); font-size:12px; }
.input input, .input textarea, .input select{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(0,0,0,0.20);
  color:var(--text);
  outline:none;
}
.input input:focus, .input textarea:focus, .input select:focus{
  border-color:rgba(124,92,255,0.8);
}

.grid{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:14px;
}
@media (max-width:1000px){ .grid{ grid-template-columns: repeat(3, 1fr);} }
@media (max-width:740px){ .grid{ grid-template-columns: repeat(2, 1fr);} }

.card{
  position:relative;
  background:linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border:1px solid var(--border);
  border-radius:16px;
  overflow:hidden;
  box-shadow: var(--shadow);
}
.card .img{
  /* Portrait trading-card ratio (~63×88mm). */
  aspect-ratio: 63 / 88;
  height: auto;
  padding: 0;

  background: radial-gradient(120px 120px at 20% 20%, rgba(124,92,255,0.35), transparent 60%),
              radial-gradient(120px 120px at 80% 30%, rgba(0,212,255,0.25), transparent 60%),
              linear-gradient(180deg, rgba(0,0,0,0.2), rgba(0,0,0,0.35));

  display:flex;
  align-items:flex-end;
  justify-content:flex-start;
}

.card .img img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

@supports not (aspect-ratio: 1 / 1){
  .card .img{ position:relative; display:block; height:0; padding-top:139.68%; }
  .card .img img{ position:absolute; inset:0; }
  .card .img .badge{ position:absolute; left:10px; bottom:10px; margin:0; }
}

.card .img .badge{ margin:10px; }

.card .meta{
  padding:12px;
}
.card .name{
  font-weight:800;
  margin:0 0 6px;
}
.card .sub{
  display:flex;
  justify-content:space-between;
  gap:8px;
  color:var(--muted);
  font-size:12px;
}
.card .pill{
  font-family:var(--mono);
  padding:2px 8px;
  border-radius:999px;
  border:1px solid var(--border);
  background:rgba(0,0,0,0.20);
}
.card .stats{
  margin-top:10px;
  display:flex;
  justify-content:space-between;
  color:var(--muted);
  font-size:12px;
}
.card .stats b{ color:var(--text); }

/* Ability snippet (shown in Collection + Deck builder) */
.card .ability{
  margin-top:10px;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(0,0,0,0.22);
  color:var(--muted);
  font-size:12px;
  line-height:1.25;

  /* Clamp to keep cards compact */
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}
.card .abilityKey{
  font-family:var(--mono);
  color:var(--text);
  margin-right:6px;
  white-space:nowrap;
}

/* Card detail page layout */
.cardDetailGrid{
  display:grid;
  grid-template-columns: 420px 1fr;
  gap:16px;
  align-items:start;
}
@media (max-width: 860px){
  .cardDetailGrid{ grid-template-columns: 1fr; }
}

/* Speak with the Librarian chat */
.chatWrap{
  display:grid;
  grid-template-columns: 340px 1fr;
  gap:14px;
  align-items:start;
}
@media (max-width: 860px){
  .chatWrap{ grid-template-columns: 1fr; }
}

.npcCard{ display:flex; gap:12px; align-items:center; }
.npcMedia{
  width:84px;
  height:84px;
  border-radius:18px;
  overflow:hidden;
  border:1px solid var(--border);
  background:rgba(0,0,0,0.25);
  flex:0 0 auto;
}
.npcMedia img,
.npcMedia video{ width:100%; height:100%; object-fit:cover; display:block; }
.npcName{ font-weight:900; }
.npcTag{ color:var(--muted); font-size:12px; margin-top:4px; }
.npcTheme{ color:var(--muted); font-size:12px; margin-top:6px; }

.chatHeader{ display:flex; justify-content:space-between; gap:12px; align-items:center; margin-bottom:12px; }
.chatTitle{ font-weight:900; }
.chatSubtitle{ color:var(--muted); font-size:12px; margin-top:4px; }

.chatMessages{
  height: 420px;
  overflow:auto;
  border:1px solid var(--border);
  border-radius:16px;
  background:rgba(0,0,0,0.18);
  padding:12px;
}
@media (max-width: 860px){
  .chatMessages{ height: 52vh; }
}

.msg{ display:flex; margin:10px 0; }
.msg.user{ justify-content:flex-end; }
.msg.npc{ justify-content:flex-start; }
.bubble{
  max-width: 86%;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.06);
  color:var(--text);
  line-height:1.35;
  white-space:pre-wrap;
}
.msg.user .bubble{ background:rgba(124,92,255,0.14); }
.msg.npc .bubble{ background:rgba(255,77,109,0.10); }

.chatForm{ display:flex; gap:10px; margin-top:12px; }
.chatForm .input{ flex:1 1 auto; }
.card .qty{
  position:absolute;
  top:10px;
  right:10px;
  font-family:var(--mono);
  background:rgba(0,0,0,0.55);
  border:1px solid rgba(255,255,255,0.14);
  padding:4px 8px;
  border-radius:999px;
}

.notice{
  padding:12px 14px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.05);
  color:var(--muted);
}
.notice.ok{ border-color:rgba(57,217,138,0.35); color:rgba(57,217,138,0.95); }
.notice.err{ border-color:rgba(255,77,109,0.35); color:rgba(255,77,109,0.95); }

.footer{
  border-top:1px solid var(--border);
  padding:18px 16px;
  color:var(--muted);
  font-size:12px;
  text-align:center;
}
.footer .tiny{ margin-top:8px; opacity:0.8; }

/* --- Feed / Social --- */
.hero{ position:relative; overflow:hidden; }
.hero:before{
  content:"";
  position:absolute;
  inset:-120px;
  background:radial-gradient(circle at 20% 10%, rgba(122,162,247,0.25), transparent 55%),
             radial-gradient(circle at 80% 20%, rgba(255,77,109,0.18), transparent 60%),
             radial-gradient(circle at 50% 80%, rgba(57,217,138,0.15), transparent 55%);
  filter: blur(12px);
  pointer-events:none;
}
.hero > *{ position:relative; }

.feedGrid{ display:grid; grid-template-columns: repeat(3, 1fr); gap:14px; }
@media (max-width: 980px){ .feedGrid{ grid-template-columns: repeat(2, 1fr);} }
@media (max-width: 680px){ .feedGrid{ grid-template-columns: 1fr;} }

.feedPost{ display:flex; flex-direction:column; gap:10px; }
.feedPost .caption{ margin-top:10px; color:var(--muted); font-size:12px; }
.postActions{ display:flex; gap:10px; flex-wrap:wrap; }

.tinyLine{ display:flex; justify-content:space-between; gap:10px; margin-top:10px; color:var(--muted); font-size:11px; }
.smallTitle{ color:var(--muted); font-size:12px; font-weight:700; }

/* --- Cosmetics --- */
.card.frame-none{ }
.card.frame-bronze{ border-color: rgba(205,127,50,0.55); box-shadow: 0 0 0 1px rgba(205,127,50,0.35), 0 12px 28px rgba(0,0,0,0.35); }
.card.frame-silver{ border-color: rgba(192,192,192,0.55); box-shadow: 0 0 0 1px rgba(192,192,192,0.30), 0 12px 28px rgba(0,0,0,0.35); }
.card.frame-gold{ border-color: rgba(255,215,0,0.55); box-shadow: 0 0 0 1px rgba(255,215,0,0.25), 0 12px 28px rgba(0,0,0,0.35); }
.card.frame-prism{ border-color: rgba(122,162,247,0.55); box-shadow: 0 0 0 1px rgba(122,162,247,0.25), 0 12px 28px rgba(0,0,0,0.35); }
.card.frame-godfire{ border-color: rgba(255,77,109,0.65); box-shadow: 0 0 0 1px rgba(255,77,109,0.30), 0 14px 34px rgba(0,0,0,0.45); }

.card.foil-matte .img img{ filter: contrast(1.03) saturate(0.95); }
.card.foil-holo .img{ position:relative; }
.card.foil-holo .img:after{
  content:"";
  position:absolute;
  inset:0;
  background: linear-gradient(120deg, rgba(122,162,247,0.00), rgba(122,162,247,0.28), rgba(255,77,109,0.20), rgba(57,217,138,0.18), rgba(122,162,247,0.00));
  mix-blend-mode: screen;
  opacity:0.55;
  pointer-events:none;
}

.card.foil-nebula .img{ position:relative; }
.card.foil-nebula .img:after{
  content:"";
  position:absolute;
  inset:0;
  background: radial-gradient(circle at 20% 20%, rgba(122,162,247,0.35), transparent 55%),
              radial-gradient(circle at 70% 30%, rgba(255,77,109,0.25), transparent 60%),
              radial-gradient(circle at 55% 75%, rgba(57,217,138,0.22), transparent 60%);
  mix-blend-mode: screen;
  opacity:0.55;
  pointer-events:none;
}

/* ------------------------------------------------------------------------- */
/* Deck builder: sticky HUD + sorting/filter tools */
/* ------------------------------------------------------------------------- */

.deckTools{
  margin-top: 12px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.16);
}

.deckToolsRow{
  display:grid;
  grid-template-columns: repeat(6, 1fr);
  gap:12px;
  align-items:end;
}

@media (max-width: 1000px){
  .deckToolsRow{ grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 740px){
  .deckToolsRow{ grid-template-columns: repeat(2, 1fr); }
}

.deckTools .input{ margin:0; }

.deckToolsMeta{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top: 10px;
}

.card.selected{
  outline: 2px solid rgba(124,92,255,0.55);
  box-shadow: 0 0 0 4px rgba(124,92,255,0.12), var(--shadow);
}

.deckHud{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;

  padding: 12px 14px 10px;
  background: rgba(7,11,20,0.80);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}

.deckHudRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}

.deckHudCounts{
  display:flex;
  align-items:baseline;
  gap:10px;
  flex-wrap:wrap;
}

.deckHudLabel{ font-weight: 900; letter-spacing:0.02em; }
.deckHudNums{ font-family: var(--mono); }
.deckHudHint{ color: var(--muted); font-size: 12px; }

.deckHudActions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.deckHudBar{
  margin-top:10px;
  height: 9px;
  border-radius: 999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,0.06);
  overflow:hidden;
}

.deckHudFill{
  height:100%;
  width:0;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(124,92,255,0.85), rgba(0,212,255,0.80));
}

.deckHudTiny{
  margin-top:8px;
  font-size:11px;
  color: var(--muted);
}

@media (max-width: 740px){
  .deckHud{ padding: 10px 12px 8px; }
  .deckHudActions .btn{ padding: 9px 12px; }
}

/* ------------------------------------------------------------------------- */
/* Deck builder: mobile +/- stepper controls (number input stays for desktop) */
/* ------------------------------------------------------------------------- */

.deckPickRow{
  margin-top:10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.qtyStepper{
  display:none;
  align-items:center;
  gap:8px;
  padding:6px 8px;
  border:1px solid var(--border);
  border-radius: 999px;
  background: rgba(0,0,0,0.18);
}

.qtyStepper .stepBtn{
  width:36px;
  height:36px;
  border-radius: 999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-weight: 900;
  cursor:pointer;
}

.qtyStepper .stepBtn:active{ transform: scale(0.98); }

.qtyStepper .stepCount{
  min-width: 26px;
  text-align:center;
  font-family: var(--mono);
  font-weight: 900;
  color: var(--text);
}

@media (max-width: 900px){
  /* On mobile, hide the numeric input and use tap-friendly +/- controls. */
  .deckQtyInput{ display:none !important; }
  .qtyStepper{ display:flex; }
}

/* ------------------------------------------------------------------------- */
/* Speak with the Librarian (sticky avatar + scrolling dialogue) */
/* ------------------------------------------------------------------------- */

.librarianShell{
  padding:0;
  overflow:hidden;

  /* Fill most of the viewport so the avatar stays visible while dialogue scrolls. */
  min-height: 560px;
  height: min(820px, calc(100dvh - 230px));
}

.librarianGrid{
  display:grid;
  grid-template-columns: 360px 1fr;
  height:100%;
}

@media (max-width: 900px){
  /* Mobile: top is the Librarian media, bottom ~1/3 is the chat. */
  .librarianShell{
    height: calc(100dvh - 120px);
    min-height: calc(100dvh - 120px);
  }

  .librarianGrid{
    grid-template-columns: 1fr;
    grid-template-rows: 1fr minmax(240px, 34dvh);
  }
}

.librarianAvatarPanel{
  padding:16px;
  border-right:1px solid var(--border);
  background: rgba(0,0,0,0.12);
  display:flex;
  flex-direction:column;
  gap:12px;
}

@media (max-width: 900px){
  .librarianAvatarPanel{ border-right:none; border-bottom:1px solid var(--border); }
}

@media (max-width: 900px){
  /* Keep the portrait clean on mobile; put rules/prompts in an overlay instead. */
  .librarianAvatarPanel{
    padding: 10px;
    gap: 10px;
  }
  .librarianAvatarPanel > :not(.librarianAvatarMedia){
    display:none !important;
  }
  .librarianAvatarMedia{
    aspect-ratio: auto;
    max-height: none;
    height: 100%;
    border-radius: 14px;
  }
  .librarianChatPanel{
    padding: 12px;
    background: rgba(7,11,20,0.82);
    backdrop-filter: blur(12px);
  }
}

@media (max-width: 420px){
  .librarianForm{
    flex-direction: column;
  }
  .librarianForm .btn{
    width: 100%;
  }
}

.librarianAvatarMedia{
  width:100%;
  border-radius:18px;
  overflow:hidden;
  border:1px solid var(--border);
  background: rgba(0,0,0,0.25);

  aspect-ratio: 1 / 1;
  max-height: 280px;
}

@media (max-width: 900px){
  /* Mobile override: let the portrait fill the top area. */
  .librarianAvatarMedia{ aspect-ratio: auto; max-height: none; height: 100%; }
}

.librarianAvatarMedia img,
.librarianAvatarMedia video{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

.librarianQuick summary{
  cursor:pointer;
  color: var(--text);
  font-weight: 800;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
}

.librarianQuick[open] summary{ margin-bottom: 10px; }

.librarianQuickBtns{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.librarianChatPanel{
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:12px;
  height:100%;
}

.librarianMessages{
  flex: 1 1 auto;
  overflow:auto;
  border:1px solid var(--border);
  border-radius:16px;
  background:rgba(0,0,0,0.18);
  padding:12px;
}

.librarianForm{
  display:flex;
  gap:10px;
}

.librarianForm .input{ flex:1 1 auto; }

/* One-time mobile-friendly overlay for rules + quick prompts. */
.librarianOverlay{
  position:fixed;
  inset:0;
  z-index: 999;
  display:none;
  align-items:center;
  justify-content:center;
  padding: 16px;
  background: rgba(0,0,0,0.76);
  backdrop-filter: blur(10px);
}
.librarianOverlay.show{ display:flex; }

.librarianOverlayCard{
  width: min(560px, 100%);
  max-height: min(78dvh, 740px);
  overflow:auto;
  border-radius: 16px;
  border:1px solid var(--border);
  background: rgba(11,16,32,0.94);
  box-shadow: var(--shadow);
  padding: 16px;
}

.librarianOverlayCard h3{ margin: 0 0 10px; }

.librarianOverlayBtns{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top: 12px;
}

.librarianOverlayPrompts{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin-top: 12px;
}



/* Form controls that use class="input" directly (legacy templates). */
input.input, textarea.input, select.input{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(0,0,0,0.20);
  color:var(--text);
  outline:none;
}
input.input:focus, textarea.input:focus, select.input:focus{
  border-color:rgba(124,92,255,0.8);
}
