@font-face{ font-family:'Press Start 2P'; src:url(assets/fonts/PressStart2P.ttf); font-display:swap; }

:root{
  --purple:#9945ff;
  --green:#14f195;
  --ink:#0a1326;
  --panel:rgba(13,20,38,.82);
  --line:rgba(255,255,255,.12);
  --muted:#9fb0cc;
}
*{ padding:0; margin:0; box-sizing:border-box; user-select:none; }
*:focus{ outline:none; }
html,body{ height:100%; }
body{
  margin:0; overflow:hidden;
  font-family:'Pixelify Sans',-apple-system,BlinkMacSystemFont,sans-serif;
  /* warm Fable 5 sky behind the transparent 3D canvas (deeper for contrast) */
  background:linear-gradient(180deg,#ece1c6 0%, #ddceac 58%, #d0bf9b 100%);
}
canvas{ height:100%; width:100%; display:block; }
.pixel{ font-family:'Pixelify Sans',sans-serif; }

/* ===================== HUD ===================== */
#hud{
  position:fixed; inset:0; z-index:20; pointer-events:none;
  display:flex; align-items:flex-start; justify-content:space-between;
  padding:18px; opacity:0; transition:opacity .4s ease;
}
#hud.show{ opacity:1; }
#hud .home-pill, #hud .score-card, #hud .bounty-card, #hud .wallet-btn{ pointer-events:auto; }

.hud-left{ display:flex; flex-direction:column; gap:10px; }
.home-pill{
  display:inline-flex; align-items:center; gap:6px; width:max-content;
  font-family:'Pixelify Sans',sans-serif; font-size:10px; color:#fff; text-decoration:none;
  background:rgba(10,19,38,.78); border:1px solid var(--line); border-radius:9px; padding:8px 11px;
}
.home-pill span{ color:var(--green); }
.home-pill:hover{ background:rgba(10,19,38,.95); }

.score-card{
  background:rgba(246,241,228,.92); border:1px solid rgba(35,32,26,.14); border-radius:12px;
  padding:11px 14px; color:#23201a; min-width:132px;
  box-shadow:0 10px 26px rgba(35,32,26,.12);
}
.score-row{ display:flex; align-items:center; justify-content:space-between; gap:14px; }
.score-row .lbl{ font-family:'Pixelify Sans',sans-serif; font-size:9px; letter-spacing:.3px; color:#b5624a; }
.score-row .val{ font-family:'Pixelify Sans',sans-serif; font-size:20px; color:#23201a; }
.score-row.sub{ margin-top:7px; }
.score-row.sub .lbl{ color:#8a8073; }
.score-row.sub .val{ font-size:12px; color:#23201a; }

.bounty-card{
  background:rgba(246,241,228,.92); border:1px solid rgba(35,32,26,.14); border-radius:12px;
  padding:15px 16px; color:#23201a; width:240px;
  box-shadow:0 10px 26px rgba(35,32,26,.12);
}
.sol-inline{ width:1.1em; height:.86em; vertical-align:-.05em; }
.bc-row{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.bc-k{ font-family:'Pixelify Sans',sans-serif; font-size:10px; letter-spacing:.3px; color:#6b6355;
  display:inline-flex; align-items:center; gap:6px; }
.bc-k.aqua{ color:#b5624a; }
.bc-k.gold{ color:#cc785c; }
.bc-v{ font-family:'Pixelify Sans',sans-serif; font-size:15px; color:#23201a; font-variant-numeric:tabular-nums; }
.bc-v.timer{ color:#cc785c; }
.bc-v.cleared{ color:#7d9160; }
.bc-divider{ height:1px; background:rgba(35,32,26,.14); margin:13px 0; }
.b-progress{ height:9px; background:rgba(35,32,26,.1); border:1px solid rgba(35,32,26,.14); border-radius:99px; overflow:hidden; margin:12px 0 15px; }
#lvlBar{ height:100%; width:0%; transition:width .25s ease;
  background:linear-gradient(90deg,#cc785c,#d9b25a); }
.wallet-btn{
  width:100%; cursor:pointer; border:none; border-radius:10px; padding:12px;
  font-family:'Pixelify Sans',sans-serif; font-size:12px; letter-spacing:.3px; color:#f6f1e4;
  background:linear-gradient(180deg,#d98a6e,#cc785c);
  box-shadow:0 6px 16px rgba(204,120,92,.35);
  transition:transform .08s ease, filter .12s ease;
}
.wallet-btn:hover{ filter:brightness(1.05); }
.wallet-btn:active{ transform:translateY(2px); }
.wallet-btn.connected{ background:#23201a; color:#f6f1e4; }

#hint{
  position:fixed; left:50%; bottom:20px; transform:translateX(-50%);
  z-index:20; pointer-events:none; opacity:0; transition:opacity .4s ease;
  background:rgba(246,241,228,.9); border:1px solid rgba(35,32,26,.14); color:#5b544a;
  padding:9px 16px; border-radius:99px; font-size:12px; backdrop-filter:blur(6px);
}
#hint.show{ opacity:1; }
#hint b{ color:#cc785c; }

@media(max-width:560px){
  .bounty-card{ width:218px; padding:13px; }
  .score-card{ min-width:120px; }
}

/* ===================== LOADER / SPLASH ===================== */
#splash{
  position:fixed; inset:0; z-index:40;
  display:grid; place-items:center;
  background:
    radial-gradient(900px 500px at 50% 0%, rgba(153,69,255,.35), transparent 60%),
    linear-gradient(180deg,#0a1020 0%, #0a1326 50%, #0a1a14 100%);
  transition:opacity .5s ease, visibility .5s ease;
}
#splash.hidden{ opacity:0; visibility:hidden; pointer-events:none; }
.splash-inner{ text-align:center; padding:24px; }
.splash-logo{ font-size:62px; line-height:1; filter:drop-shadow(0 8px 20px rgba(0,0,0,.4)); animation:bob 1.6s ease-in-out infinite; }
@keyframes bob{ 0%,100%{ transform:translateY(0); } 50%{ transform:translateY(-10px); } }
.splash-title{ font-family:'Pixelify Sans',sans-serif; font-weight:700; font-size:clamp(42px,8.6vw,76px); color:#fff; margin-top:6px; letter-spacing:-.5px; text-shadow:0 4px 28px rgba(0,0,0,.55); }
.splash-title span{ color:var(--green); }
.splash-sub{ font-size:15px; color:#cdd8ef; letter-spacing:.2px; margin-top:12px; }
#loadingbar{ width:240px; max-width:70vw; height:9px; margin:30px auto 22px; border-radius:99px;
  background:rgba(255,255,255,.12); overflow:hidden; transition:opacity .4s ease; }
#loadingfill{ height:100%; width:40%; border-radius:99px;
  background:linear-gradient(90deg,var(--purple),var(--green));
  animation:load 1.1s ease-in-out infinite; }
@keyframes load{ 0%{ margin-left:-40%; } 100%{ margin-left:100%; } }
.play-btn{
  font-family:'Pixelify Sans',sans-serif; font-weight:700;
  cursor:pointer; border:none; border-radius:14px; padding:16px 48px;
  font-size:18px; color:#062417;
  background:linear-gradient(135deg,var(--green),#0bc77a);
  box-shadow:0 10px 26px rgba(20,241,149,.35); transition:transform .12s ease, filter .12s ease;
}
.play-btn:hover{ transform:translateY(-2px); }
.play-btn:disabled{ filter:grayscale(.6) brightness(.8); cursor:default; transform:none; box-shadow:none; }
.splash-hint{ margin-top:22px; color:var(--muted); font-size:12px; }

/* ===================== GAME OVER ===================== */
#gameover{
  position:fixed; inset:0; z-index:45; display:grid; place-items:center;
  background:rgba(6,10,20,.66); backdrop-filter:blur(4px);
  opacity:0; visibility:hidden; transition:opacity .35s ease, visibility .35s ease;
}
#gameover.show{ opacity:1; visibility:visible; }
.go-panel{
  width:min(380px,90vw); text-align:center; padding:34px 28px;
  background:#f6f1e4; border:1px solid rgba(35,32,26,.14);
  border-radius:20px; box-shadow:0 24px 60px rgba(35,32,26,.28);
}
.go-title{ font-family:'Pixelify Sans',sans-serif; font-weight:700; font-size:28px; letter-spacing:-.3px; color:#23201a; margin-bottom:22px; }
.go-stats{ display:flex; gap:14px; margin-bottom:18px; }
.go-stats > div{ flex:1; background:rgba(35,32,26,.04); border:1px solid rgba(35,32,26,.14); border-radius:12px; padding:14px; }
.go-stats span{ display:block; font-family:'Pixelify Sans',sans-serif; font-size:8px; color:#8a8073; margin-bottom:8px; }
.go-stats b{ font-family:'Pixelify Sans',sans-serif; font-size:20px; color:#cc785c; }
.go-reward{ font-size:12px; color:#6b6355; line-height:1.6; margin-bottom:22px; }
.go-panel .play-btn{ width:100%; padding:16px; }
.go-home{ display:inline-block; margin-top:16px; color:#8a8073; font-size:12px; text-decoration:none; }
.go-home:hover{ color:#23201a; }

/* ===================== TOAST ===================== */
#toast{
  position:fixed; left:50%; bottom:70px; transform:translate(-50%,20px);
  z-index:50; pointer-events:none; opacity:0; transition:opacity .3s ease, transform .3s ease;
  background:#23201a; border:1px solid rgba(204,120,92,.5);
  color:#f6f1e4; padding:13px 20px; border-radius:12px; font-size:14px; font-weight:700;
  box-shadow:0 14px 34px rgba(35,32,26,.3);
}
#toast.show{ opacity:1; transform:translate(-50%,0); }

/* ===================== CHARACTER SELECT ===================== */
#charselect{
  position:fixed; inset:0; z-index:60;
  display:none; align-items:center; justify-content:center;
  background:
    radial-gradient(120% 90% at 50% 0%, #f8f3e6 0%, #f0e8d5 55%, #e6dbc2 100%);
}
#charselect.show{ display:flex; }
.cs-inner{ width:100%; max-width:1200px; padding:28px 20px; text-align:center; }
.cs-title{
  font-family:'Pixelify Sans',sans-serif; color:#23201a; font-weight:700;
  font-size:clamp(26px,4.6vw,48px); letter-spacing:1px;
}
.cs-sub{
  color:#6b6355; font-size:clamp(13px,1.8vw,17px); margin-top:6px;
}
.cs-cards{ margin:26px auto 24px; display:flex; flex-wrap:wrap; gap:16px; justify-content:center; }
.char-card{
  width:210px; cursor:pointer;
  background:rgba(246,241,228,.75);
  border:2px solid rgba(35,32,26,.14);
  border-radius:18px; padding:10px 10px 16px;
  backdrop-filter:blur(7px); -webkit-backdrop-filter:blur(7px);
  transition:transform .15s ease, border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.char-card:hover{ transform:translateY(-5px); background:rgba(246,241,228,.92); }
.char-card.selected{
  border-color:#cc785c;
  box-shadow:0 0 0 2px rgba(204,120,92,.4), 0 12px 34px rgba(204,120,92,.24);
  background:#f6f1e4;
}
.char-canvas{ width:190px; height:224px; display:block; margin:0 auto; }
.char-info{ margin-top:4px; }
.char-name{ font-family:'Pixelify Sans',sans-serif; color:#23201a; font-weight:700; font-size:23px; }
.char-tag{ color:#6b6355; font-size:13px; margin-top:2px; }
.cs-play{
  font-family:'Pixelify Sans',sans-serif; cursor:pointer;
  font-size:21px; font-weight:700; color:#f6f1e4;
  padding:14px 50px; border:none; border-radius:14px;
  background:linear-gradient(180deg,#d98a6e,#cc785c);
  box-shadow:0 10px 26px rgba(204,120,92,.4);
  transition:transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.cs-play:hover{ transform:translateY(-3px); filter:brightness(1.05); box-shadow:0 14px 32px rgba(204,120,92,.5); }
.cs-play:active{ transform:translateY(0); }
@media (max-width:560px){
  .char-card{ width:45%; padding:8px 8px 12px; }
  .char-canvas{ width:100%; height:180px; }
  .char-name{ font-size:19px; }
}
