/* =========================================================
  MAGICAL QUIZ THEME + Q1 SHELF + QUESTION IMAGES + MUSIC DOCK
  + LOADING SCREEN + SWORD LOADER (masked liquid fill)
========================================================= */

:root{
  --font-body: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  --font-magic: ui-serif, "Georgia", "Garamond", "Times New Roman", serif;

  --bg0:#070816;
  --bg1:#0a0c22;
  --ink: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.70);

  --glass: rgba(255,255,255,.07);
  --edge: rgba(255,255,255,.12);

  --a1:#a78bfa;
  --a2:#60a5fa;
  --a3:#22d3ee;
  --ring: rgba(167,139,250,.42);

  --radius: 18px;
  --radius2: 22px;
  --shadow: 0 22px 55px rgba(0,0,0,.45);
  --shadow2: 0 14px 35px rgba(0,0,0,.35);
  --gap: 14px;

  --shelf-img: none;
  --shelf-wood: rgba(255,255,255,.06);
  --shelf-edge: rgba(255,255,255,.16);

  --item-size: 84px;
  --item-radius: 16px;
  --item-bg: rgba(255,255,255,.06);
  --item-border: rgba(255,255,255,.12);
  --item-glow: rgba(167,139,250,.30);

  --maxw: 920px;

  --sword-mask: url("image/sword-mask.png");
}

:root{
  --sword-fill-left: 15%;   /* adjust until the fill starts at sword’s left edge */
  --sword-fill-right: 15%;  /* adjust until 100% reaches sword’s right edge */
}


*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(900px 520px at 20% 10%, rgba(167,139,250,.23), transparent 60%),
    radial-gradient(860px 520px at 78% 22%, rgba(96,165,250,.18), transparent 55%),
    radial-gradient(900px 520px at 45% 96%, rgba(34,211,238,.12), transparent 60%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  line-height: 1.35;
  overflow-x: hidden;
}

body::before{
  content:"";
  position:fixed;
  inset:-30%;
  pointer-events:none;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.08), transparent 35%),
    radial-gradient(circle at 70% 20%, rgba(255,255,255,.06), transparent 40%),
    radial-gradient(circle at 45% 70%, rgba(255,255,255,.05), transparent 42%);
  filter: blur(1px);
  opacity:.55;
  mix-blend-mode: screen;
  transform: rotate(6deg);
  animation: drift 12s ease-in-out infinite alternate;
}

@keyframes drift{
  from{ transform: translate3d(-10px,-6px,0) rotate(5deg); opacity:.50; }
  to  { transform: translate3d(12px,10px,0) rotate(7deg); opacity:.62; }
}

.wrap{
  min-height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 28px 14px 74px;
}

.card{
  width:min(var(--maxw), 100%);
  background: linear-gradient(180deg, var(--glass), rgba(255,255,255,.03));
  border: 1px solid var(--edge);
  border-radius: var(--radius2);
  box-shadow: var(--shadow);
  overflow:hidden;
  position: relative;
}

.card::after{
  content:"";
  position:absolute;
  inset:0;
  border-radius: inherit;
  pointer-events:none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), inset 0 0 40px rgba(167,139,250,.10);
}

header{
  padding: 18px 20px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.10);
  background: linear-gradient(180deg, rgba(255,255,255,.07), transparent);
}

.brand{ display:flex; flex-direction:column; gap:4px; }
.brand h1{
  font-family: var(--font-magic);
  font-size: 18px;
  margin:0;
  letter-spacing:.4px;
}
.brand p{
  margin:0;
  color: var(--muted);
  font-size: 13px;
}

.progress{
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:6px;
  min-width: 180px;
}
.bar{
  width: 180px;
  height: 9px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  overflow:hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.bar > i{
  display:block;
  height:100%;
  width:0%;
  background: linear-gradient(90deg, rgba(167,139,250,.95), rgba(96,165,250,.85), rgba(34,211,238,.75));
  filter: drop-shadow(0 0 10px rgba(167,139,250,.35));
}
.progress small{ color: var(--muted); }

main{ padding: 18px 20px 20px; }

.page{ display:none; }
.page.active{ display:block; }

.title{
  margin: 0 0 10px;
  font-family: var(--font-magic);
  font-size: 26px;
  letter-spacing:.35px;
}

.subtitle{
  margin: 0 0 18px;
  color: var(--muted);
  max-width: 62ch;
}

.qhead{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.qnum{
  font-weight: 700;
  color: rgba(255,255,255,.88);
  font-size: 12px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.11);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05);
  white-space: nowrap;
}
.qtext{
  margin:0;
  font-size: 19px;
  font-weight: 750;
  letter-spacing:.2px;
}

.q-media{
  margin: 10px 0 16px;
  border-radius: 18px;
  overflow:hidden;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.10);
  box-shadow: var(--shadow2);
  position: relative;
}
.q-media::after{
  content:"";
  position:absolute;
  inset:0;
  background: radial-gradient(600px 240px at 50% 0%, rgba(167,139,250,.20), transparent 60%);
  pointer-events:none;
}
.q-media img{
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}
.q-media figcaption{
  padding: 10px 12px;
  color: rgba(255,255,255,.72);
  font-size: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.28));
}

.hero-img{ width:100%; height:auto; display:block; }

.answers{
  display:grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  margin: 14px 0 18px;
}
.ans{
  position:relative;
  padding: 14px 14px 14px 46px;
  border-radius: 16px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  cursor:pointer;
  transition: transform .08s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
  user-select:none;
}
.ans:hover{
  background: rgba(255,255,255,.085);
  border-color: rgba(255,255,255,.16);
  box-shadow: 0 10px 22px rgba(0,0,0,.22);
}
.ans:active{ transform: translateY(1px); }
.ans input{
  position:absolute;
  inset:0;
  opacity:0;
  pointer-events:none;
}
.ans .dot{
  position:absolute;
  left: 14px;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  transform: translateY(-50%);
  border: 2px solid rgba(255,255,255,.28);
  background: rgba(0,0,0,.18);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.ans.selected{
  background: rgba(167,139,250,.10);
  outline: 2px solid rgba(167,139,250,.45);
  outline-offset: 0;
  box-shadow: 0 0 0 1px rgba(167,139,250,.12);
}
.ans.selected .dot{
  border-color: rgba(255,255,255,.85);
  background:
    radial-gradient(circle at 50% 50%,
      rgba(255,255,255,.98) 0 35%,
      rgba(167,139,250,1) 36% 100%);
  box-shadow: 0 0 0 5px rgba(167,139,250,.18);
}

.nav{
  display:flex;
  justify-content:space-between;
  gap: 12px;
  margin-top: 8px;
}
.btn{
  appearance:none;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.08);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 16px;
  cursor:pointer;
  font-weight: 750;
  letter-spacing:.25px;
  transition: background .18s ease, border-color .18s ease, transform .08s ease, box-shadow .18s ease;
  display:inline-flex;
  align-items:center;
  gap:10px;
}
.btn:hover{
  background: rgba(255,255,255,.11);
  border-color: rgba(255,255,255,.20);
  box-shadow: 0 10px 22px rgba(0,0,0,.22);
}
.btn:active{ transform: translateY(1px); }
.btn.primary{
  background: linear-gradient(90deg, rgba(167,139,250,.92), rgba(96,165,250,.78), rgba(34,211,238,.68));
  border-color: rgba(255,255,255,.18);
  box-shadow: 0 0 0 1px rgba(167,139,250,.18), 0 16px 30px rgba(0,0,0,.22);
}
.btn.primary:hover{ filter: brightness(1.06); }
.btn:disabled{ opacity:.45; cursor:not-allowed; transform:none; box-shadow:none; }

.shelfWrap{ margin: 14px 0 18px; }
.shelfHint{ margin:10px 4px 0; color: var(--muted); font-size: 13px; }

.shelf{
  position:relative;
  border-radius: 18px;
  padding: 18px 16px 14px;
  background:
    radial-gradient(700px 260px at 50% 10%, rgba(167,139,250,.18), transparent 60%),
    rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.10);
  box-shadow: var(--shadow2);
  overflow:hidden;
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.shelf::before{
  content:"";
  position:absolute;
  inset:0;
  background-image: var(--shelf-img);
  background-size: cover;
  background-position: center;
  opacity: .28;
  filter: contrast(1.05) saturate(1.1);
  pointer-events:none;
}
.shelf::after{
  content:"";
  position:absolute;
  left:0; right:0; bottom:0;
  height: 64px;
  background:
    linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.25)),
    linear-gradient(90deg, rgba(255,255,255,.06), rgba(255,255,255,.02)),
    var(--shelf-wood);
  border-top: 1px solid var(--shelf-edge);
  pointer-events:none;
}

.shelfItem{
  position:relative;
  z-index:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 8px;
  padding: 12px 10px;
  border-radius: var(--item-radius);
  background: var(--item-bg);
  border: 1px solid var(--item-border);
  cursor:pointer;
  transition: transform .10s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
  user-select:none;
  text-align:center;
}
.shelfItem input{
  position:absolute;
  inset:0;
  opacity:0;
  pointer-events:none;
}
.shelfItem img{
  width: var(--item-size);
  height: var(--item-size);
  object-fit: contain;
  filter: drop-shadow(0 12px 18px rgba(0,0,0,.35));
  transition: transform .18s ease, filter .18s ease;
}
.shelfItem span{
  font-size: 12px;
  color: rgba(255,255,255,.80);
  line-height: 1.2;
}
.shelfItem:hover{
  background: rgba(255,255,255,.085);
  border-color: rgba(255,255,255,.18);
  box-shadow: 0 14px 28px rgba(0,0,0,.25);
  transform: translateY(-1px);
}
.shelfItem:hover img{
  transform: translateY(-2px);
  filter: drop-shadow(0 16px 22px rgba(0,0,0,.40));
}
.shelfItem.selected{
  background: rgba(167,139,250,.12);
  outline: 2px solid rgba(167,139,250,.55);
  outline-offset: 0;
  box-shadow: 0 0 0 1px rgba(167,139,250,.12);
}

/* Make tie-break shelf items darker than Q1 shelf items */
#tieShelf .shelfItem{
  background: rgba(0,0,0,.28);
  border-color: rgba(255,255,255,.10);
}

#tieShelf .shelfItem:hover{
  background: rgba(0,0,0,.36);
  border-color: rgba(255,255,255,.16);
}

#tieShelf .shelfItem.selected{
  background: rgba(0,0,0,.42);
  outline-color: rgba(167,139,250,.55);
}

.shelfItem.selected img{ transform: translateY(-3px) scale(1.03); }

.resultGrid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 12px;
}
.resultGrid > div{
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 18px;
  padding: 14px;
}
.resultImageBox{
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.10);
  box-shadow: var(--shadow2);
  margin: 0 0 12px;
  display: none; /* JS will show it only if an icon exists */
}

.resultImageBox img{
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}


.pillRow{ display:flex; flex-wrap:wrap; gap:10px; margin: 10px 0 0; }
.pill{
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--muted);
  font-size: 12px;
}

/* Audio Dock */
.audioDock{
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 14px;
  max-width: 920px;
  margin: 0 auto;
  display:flex;
  align-items:center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(10,12,34,.72);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 18px 45px rgba(0,0,0,.35);
  backdrop-filter: blur(10px);
  z-index: 999;
}
.audioDock::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius: inherit;
  pointer-events:none;
  background: radial-gradient(520px 140px at 20% 0%, rgba(167,139,250,.22), transparent 55%);
  opacity:.9;
}
.audioMeta{
  position:relative;
  z-index:1;
  display:flex;
  flex-direction:column;
  gap:2px;
  min-width: 160px;
}
.audioTitle{ font-weight: 800; letter-spacing:.2px; font-size: 13px; }
.audioSub{ color: var(--muted); font-size: 12px; }
.audioVol{
  position:relative;
  z-index:1;
  width: 100%;
  max-width: 240px;
  accent-color: rgba(167,139,250,.95);
  height: 4px;
}

/* LOADING SCREEN */
.loading{
  position: fixed;
  inset: 0;
  display:none;
  align-items:center;
  justify-content:center;
  padding: 20px;
  z-index: 2000;
  background:
    radial-gradient(900px 520px at 20% 10%, rgba(167,139,250,.22), transparent 60%),
    radial-gradient(860px 520px at 78% 22%, rgba(96,165,250,.16), transparent 55%),
    linear-gradient(180deg, rgba(7,8,22,.92), rgba(10,12,34,.92));
  backdrop-filter: blur(10px);
  overflow:hidden;
}
.loading.active{ display:flex; }

#loadingScreen{
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.loadingCard{
  width: min(560px, 100%);
  padding: 18px 18px 56px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  box-shadow: 0 22px 55px rgba(0,0,0,.45);
  overflow:hidden;
  position: relative;
}

.loadingTitle{
  font-weight: 850;
  letter-spacing: .2px;
  font-size: 18px;
}

#loadingScreen .loadingSub{
  margin-top: 10px;
  color: rgba(255,255,255,.72);
  font-size: 13px;
  text-align: center;
}

.loadingCard .swordMeter{
  width: 100%;
  max-width: 560px;
  margin-left:auto;
  margin-right:auto;
}

.swordMeter{
  aspect-ratio: 1786 / 660;
  position: relative;
  margin: 14px auto 0;

  -webkit-mask-image: var(--sword-mask);
  mask-image: var(--sword-mask);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;

  overflow: hidden;
}

.swordBase{
  position:absolute;
  inset:0;
  background:#000;
  filter: drop-shadow(0 12px 20px rgba(0,0,0,.45));
}

.swordFillClip{
  position:absolute;
  top:0;
  bottom:0;
  left: var(--sword-fill-left);
  right: var(--sword-fill-right);
  overflow:hidden;
  pointer-events:none;
}

:root{
  --liquid-shift-x: 10%;   /* tweak this: 0% = no shift, higher moves start right */
  --liquid-stretch-x: 120%;/* tweak this: larger = more room so it doesn’t “run out” */
}


/* Liquid base = white */
.swordFill{
  position:absolute;
  inset:0;
  background: #fff;            /* starts white */
 transform-origin: left center;  /* ✅ starts at left edge */
  transform: scaleX(0);
  overflow: hidden;            /* keeps overlay clean */
}

.swordFill::before{
  content:"";
  position:absolute;
  inset:0;
  background: linear-gradient(
    90deg,
    rgba(36, 158, 199, 1) 34%,
    rgba(232, 167, 53, 1) 35%, 
    rgba(212, 145, 30, 1) 65%,
    rgba(35, 148, 86, 1) 66%
  );
  opacity: 0;
  transition: opacity 2s ease, background-position 2s ease;
}

/* When load finishes, reveal gradient and slide it */
.loading.ready .swordFill::before{
  opacity: 1;

}

.swordFillClip::after{
  content:"";
  position:absolute;
  left:-10%;
  right:-10%;
  top:-12px;
width:24px;
  background: #24a9c7;
background: linear-gradient(90deg, rgba(36, 169, 199, 1) 0%, rgba(232, 167, 53, 1) 50%, rgba(176, 176, 176, 1) 100%);
  animation: liquidWave 2s ease-in-out infinite alternate;
  transform: translateZ(0);
}

@keyframes liquidWave{
  from{ transform: translateY(-6px) translateZ(0); }
  to  { transform: translateY(6px) translateZ(0); }
}

/* ENTER BUTTON */
.enterBtn{
  position:absolute;
  right:14px;
  bottom:14px;
  width:44px;
  height:44px;
  padding:0;
  border:none;
  background: transparent;
  cursor:pointer;
  opacity: .95;
}
.enterBtn img{
  width:100%;
  height:100%;
  object-fit: contain;
  display:block;
}
.enterBtn:disabled{
  opacity:.35;
  cursor:not-allowed;
}
.enterBtn:hover:not(:disabled){
  transform: translateY(-1px);
}

.card > main { overflow-anchor: none; }
.answers { overflow-anchor: none; }

@media (min-width: 760px){
  .answers{ grid-template-columns: 1fr 1fr; }
  .resultGrid{ grid-template-columns: 1.2fr .8fr; }
  .shelf{ grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

