/* ============================================================
   Shared chrome for the cognitive ability games.
   Dark-first, built on NIAT's own crest:
   crimson #941A1B · cream #F5EFBB, both sampled from the logo
   ============================================================ */
:root{
  /* surfaces */
  --bg:#190508; --bg-2:#2A0B10; --navy:#3A1014; --navy-2:#2A0B10;
  --glass:rgba(245,239,187,.06); --glass-2:rgba(245,239,187,.11);
  --stroke:rgba(245,239,187,.16); --stroke-2:rgba(245,239,187,.28);

  /* brand */
  --brand:#941A1B; --brand-lite:#C62B2C; --brand-deep:#5E0F10;
  --amber:#F5EFBB; --amber-deep:#DCCB74;          /* the crest's cream */
  --coral:#FF7A63; --green:#2E9E63; --green-lite:#5BD69A;
  --violet:#D9A441;

  /* text */
  --ink:#FBF5E2; --ink-2:#D9C7A8; --muted:#A98D74; --line:#F5EFBB;

  /* gradients + glows */
  --grad-brand:linear-gradient(135deg,#C62B2C 0%,#941A1B 100%);
  --grad-amber:linear-gradient(135deg,#F7F2C6 0%,#DCC471 100%);
  --glow-brand:0 8px 30px rgba(198,43,44,.45);
  --glow-amber:0 8px 26px rgba(245,239,187,.28);

  --r:18px; --r-sm:12px;
  --ff:'Poppins',system-ui,-apple-system,'Segoe UI',sans-serif;
}
*{box-sizing:border-box}
html,body{height:100%; margin:0}
body{
  background:var(--bg); color:var(--ink); font-family:var(--ff); overflow:hidden;
  background-image:
    radial-gradient(760px 420px at 12% -8%, rgba(148,26,27,.55), transparent 62%),
    radial-gradient(620px 380px at 92% 4%, rgba(245,239,187,.1), transparent 60%),
    radial-gradient(700px 500px at 60% 108%, rgba(198,43,44,.28), transparent 62%);
  -webkit-font-smoothing:antialiased;
}
button{font-family:inherit; cursor:pointer}

.stage{height:100%; display:flex; flex-direction:column;
  padding-top:env(safe-area-inset-top,0px); padding-bottom:env(safe-area-inset-bottom,0px)}

/* ---------------- top bar ---------------- */
.bar{
  display:flex; align-items:center; gap:9px; flex:none;
  padding:10px 14px; margin:10px 12px 0; border-radius:var(--r);
  background:rgba(42,11,16,.8); border:1px solid var(--stroke);
  backdrop-filter:blur(14px); -webkit-backdrop-filter:blur(14px);
}
.bar .ic{
  width:42px; height:38px; border:1px solid var(--stroke); border-radius:12px;
  background:var(--glass); color:var(--ink); font-size:14px; display:grid; place-items:center;
  transition:transform .12s ease, background .15s ease;
}
.bar .ic:hover{background:var(--glass-2)}
.bar .ic:active{transform:scale(.92)}
.bar .lvl{
  background:var(--glass); border:1px solid var(--stroke); color:var(--ink);
  font-weight:700; font-size:14px; padding:8px 15px; border-radius:12px; white-space:nowrap;
}
.scorebar{
  flex:1 1 auto; min-width:60px; height:38px; border-radius:99px; position:relative;
  overflow:hidden; display:grid; place-items:center;
  background:rgba(255,255,255,.07); border:1px solid var(--stroke);
}
.scorebar .fill{position:absolute; inset:0; width:0; background:var(--grad-amber);
  transition:width .45s cubic-bezier(.2,.9,.25,1)}
.scorebar .v{position:relative; font-weight:800; font-size:17px; color:var(--ink);
  font-variant-numeric:tabular-nums; text-shadow:0 1px 6px rgba(0,0,0,.45)}
.scorebar .v.neg{color:var(--coral)}
.clock{
  background:var(--glass); border:1px solid var(--stroke); color:var(--ink);
  font-weight:800; font-size:15px; padding:8px 14px; border-radius:12px;
  font-variant-numeric:tabular-nums; min-width:80px; text-align:center;
}
.clock.low{color:var(--coral); border-color:rgba(243,112,90,.5); animation:pulse 1s ease-in-out infinite}
@keyframes pulse{50%{opacity:.5}}
.bar .name{color:var(--ink-2); font-weight:700; font-size:15px; white-space:nowrap}
.streak{
  display:none; align-items:center; gap:5px; white-space:nowrap;
  font-weight:800; font-size:13px; color:#3A1006; padding:7px 13px; border-radius:99px;
  background:var(--grad-amber); box-shadow:var(--glow-amber);
}
.streak.on{display:inline-flex; animation:popin .32s cubic-bezier(.2,1.4,.4,1)}
@keyframes popin{from{transform:scale(.6); opacity:0}to{transform:scale(1); opacity:1}}
@media (max-width:820px){ .bar .name{display:none} }
@media (max-width:560px){
  .bar{gap:7px; padding:8px 10px; margin:8px 8px 0}
  .bar .lvl{padding:7px 10px; font-size:12.5px}
  .clock{min-width:66px; padding:7px 10px; font-size:13.5px}
  .streak{padding:6px 10px; font-size:12px}
  .bar .ic{width:38px; height:34px}
}

/* session strip */
.session{flex:none; height:4px; margin:9px 14px 0; border-radius:99px;
  background:rgba(255,255,255,.08); overflow:hidden}
.session i{display:block; height:100%; width:100%; background:var(--grad-brand);
  transform-origin:left center}

.prompt{flex:none; text-align:center; font-weight:800; letter-spacing:-.01em;
  font-size:clamp(17px,2.6vw,27px); padding:14px 16px 4px; text-wrap:balance}
.board{flex:1 1 auto; margin:8px 14px 16px; position:relative; min-height:0;
  display:flex; align-items:center; justify-content:center; overflow:auto}

/* ---------------- shared pieces ---------------- */
.tile{background:var(--glass); border:1px solid var(--stroke); border-radius:var(--r-sm);
  display:grid; place-items:center}

.flash{
  position:absolute; left:50%; top:16%; transform:translate(-50%,-50%);
  font-size:clamp(28px,5.4vw,52px); font-weight:800; pointer-events:none; opacity:0; z-index:6;
  letter-spacing:-.02em;
}
.flash.on{opacity:1; animation:floatUp .85s cubic-bezier(.2,.9,.25,1)}
@keyframes floatUp{
  0%{transform:translate(-50%,-30%) scale(.6); opacity:0}
  32%{transform:translate(-50%,-50%) scale(1.14); opacity:1}
  100%{transform:translate(-50%,-95%) scale(1); opacity:0}
}
.flash.good{color:var(--green-lite); text-shadow:0 6px 26px rgba(61,214,140,.45)}
.flash.bad{color:var(--coral); text-shadow:0 6px 26px rgba(243,112,90,.4)}

/* confetti burst */
.conf{position:fixed; inset:0; pointer-events:none; z-index:40; overflow:hidden}
.conf i{position:absolute; width:9px; height:14px; border-radius:2px; will-change:transform,opacity;
  animation:fall var(--dur,1.1s) cubic-bezier(.15,.7,.4,1) forwards}
@keyframes fall{
  0%{transform:translate(0,0) rotate(0deg); opacity:1}
  100%{transform:translate(var(--dx),var(--dy)) rotate(var(--rot)); opacity:0}
}

/* ---------------- overlays ---------------- */
.overlay{
  position:fixed; inset:0; z-index:20; display:grid; place-items:center; padding:18px;
  background:rgba(14,4,7,.82); overflow:auto;
  backdrop-filter:blur(10px); -webkit-backdrop-filter:blur(10px);
}
.overlay[hidden]{display:none}
.sheet{
  width:min(760px,100%); border-radius:26px; padding:28px; position:relative;
  display:flex; flex-direction:column; gap:14px;
  background:linear-gradient(165deg,#3A1014 0%,#1E070B 100%);
  border:1px solid var(--stroke-2);
  box-shadow:0 30px 80px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.14);
  animation:sheetIn .34s cubic-bezier(.2,1.1,.35,1);
}
@keyframes sheetIn{from{transform:translateY(16px) scale(.97); opacity:0}to{transform:none; opacity:1}}
.sheet h1{
  margin:0; text-align:center; font-size:clamp(30px,6vw,52px); font-weight:800;
  letter-spacing:-.03em; line-height:1.02;
  background:var(--grad-amber); -webkit-background-clip:text; background-clip:text; color:transparent;
}
.sheet .sub{
  align-self:center; font-weight:700; font-size:clamp(12px,1.9vw,14.5px); letter-spacing:.06em;
  text-transform:uppercase; padding:6px 16px; border-radius:99px; text-align:center;
  background:var(--glass); border:1px solid var(--stroke); color:var(--amber);
}
.sheet p{margin:0; font-size:clamp(14px,1.85vw,16.5px); line-height:1.6; color:var(--ink-2)}
.sheet h2{margin:8px 0 0; text-align:center; color:var(--amber); font-size:clamp(18px,3vw,24px);
  font-weight:800; letter-spacing:-.01em}
.sheet ul{margin:0; padding:0; list-style:none; display:flex; flex-direction:column; gap:8px}
.sheet ul li{
  display:flex; gap:10px; align-items:flex-start; font-size:clamp(13.5px,1.8vw,15.5px);
  color:var(--ink-2); background:var(--glass); border:1px solid var(--stroke);
  border-radius:var(--r-sm); padding:10px 13px;
}
.sheet ul li::before{content:'▸'; color:var(--amber); font-weight:800; line-height:1.4}

.play{
  align-self:center; border:0; border-radius:99px; color:#fff; margin-top:8px;
  font-size:clamp(16px,2.4vw,20px); font-weight:800; letter-spacing:.02em;
  padding:15px 54px; background:var(--grad-brand); box-shadow:var(--glow-brand);
  transition:transform .14s cubic-bezier(.2,1.4,.4,1), filter .15s ease;
}
.play:hover{filter:brightness(1.08)}
.play:active{transform:scale(.94)}
.ghost{
  align-self:center; background:var(--glass); border:1px solid var(--stroke); color:var(--ink-2);
  border-radius:99px; padding:11px 26px; font-size:14px; font-weight:700;
  transition:transform .14s ease, color .15s ease, background .15s ease; text-decoration:none;
}
.ghost:hover{background:var(--glass-2); color:var(--ink)}
.ghost:active{transform:scale(.94)}

.results{display:flex; flex-direction:column; gap:8px}
.results div{
  display:flex; justify-content:space-between; align-items:center; gap:12px;
  padding:12px 15px; border-radius:var(--r-sm);
  background:var(--glass); border:1px solid var(--stroke); font-size:15px; color:var(--ink-2);
}
.results b{font-weight:800; color:var(--ink); font-variant-numeric:tabular-nums; font-size:17px}
.share{
  display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap;
  padding:13px 15px; border-radius:var(--r-sm); font-size:13.5px; color:var(--ink-2);
  background:rgba(148,26,27,.28); border:1px dashed rgba(198,43,44,.6);
}
.share b{color:var(--ink); font-weight:700}
.share button{
  border:0; border-radius:99px; padding:8px 18px; font-weight:700; font-size:13px; color:#fff;
  background:var(--grad-brand); transition:transform .14s ease;
}
.share button:active{transform:scale(.93)}

.backlink{
  position:fixed; left:14px; bottom:14px; z-index:9; text-decoration:none;
  background:rgba(42,11,16,.85); border:1px solid var(--stroke); color:var(--ink-2);
  font-size:12.5px; font-weight:700; padding:9px 15px; border-radius:99px;
  backdrop-filter:blur(10px); -webkit-backdrop-filter:blur(10px);
  transition:transform .14s ease, color .15s ease;
}
.backlink:hover{color:var(--ink)}
.backlink:active{transform:scale(.94)}


.crest{
  width:34px; height:34px; border-radius:9px; flex:none; display:block;
  box-shadow:0 3px 0 rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.25);
}
.sheet .crest{
  width:64px; height:64px; border-radius:14px; align-self:center; margin-bottom:2px;
  box-shadow:0 6px 0 rgba(0,0,0,.45), 0 14px 30px rgba(0,0,0,.5);
}
@media (max-width:560px){ .crest{width:30px; height:30px} }

/* ---------------- depth pass ----------------
   Objects are lit from above: a bright inner top edge, a darker inner bottom,
   and a hard coloured edge underneath so buttons look like they stick out and
   physically depress when pressed. */
:root{
  --lift-1:inset 0 1px 0 rgba(255,255,255,.28), inset 0 -2px 0 rgba(0,0,0,.28),
           0 6px 14px rgba(0,0,0,.35);
  --lift-2:inset 0 2px 0 rgba(255,255,255,.34), inset 0 -3px 0 rgba(0,0,0,.32),
           0 12px 26px rgba(0,0,0,.45);
}

.play{
  box-shadow:0 7px 0 #5E0F10, 0 16px 30px rgba(148,26,27,.5),
             inset 0 2px 0 rgba(255,255,255,.32), inset 0 -3px 0 rgba(0,0,0,.24);
  transform:translateY(0);
}
.play:active{transform:translateY(5px); box-shadow:0 2px 0 #5E0F10, 0 6px 14px rgba(148,26,27,.45),
  inset 0 2px 0 rgba(255,255,255,.3)}
.ghost{box-shadow:0 4px 0 rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.2)}
.ghost:active{transform:translateY(3px); box-shadow:0 1px 0 rgba(0,0,0,.35)}

.bar{box-shadow:0 10px 26px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.12)}
.bar .ic, .bar .lvl, .clock{box-shadow:var(--lift-1)}
.bar .ic:active{transform:translateY(2px); box-shadow:inset 0 2px 5px rgba(0,0,0,.4)}
.scorebar{box-shadow:inset 0 3px 7px rgba(0,0,0,.45), inset 0 -1px 0 rgba(255,255,255,.1)}
.scorebar .fill{box-shadow:inset 0 2px 0 rgba(255,255,255,.55), 0 0 18px rgba(245,239,187,.5)}
.streak.on{box-shadow:0 5px 0 #9A8A3F, 0 12px 22px rgba(245,239,187,.35),
  inset 0 2px 0 rgba(255,255,255,.55)}
.session i{box-shadow:0 0 14px rgba(198,43,44,.8)}

.sheet .sub{box-shadow:var(--lift-1)}
.sheet ul li{box-shadow:inset 0 1px 0 rgba(255,255,255,.14), 0 4px 10px rgba(0,0,0,.25)}
.results div{box-shadow:inset 0 1px 0 rgba(255,255,255,.14), 0 4px 10px rgba(0,0,0,.25)}
.share button{box-shadow:0 4px 0 #5E0F10, inset 0 1px 0 rgba(255,255,255,.3)}
.share button:active{transform:translateY(3px); box-shadow:0 1px 0 #5E0F10}
.backlink{box-shadow:var(--lift-1)}

/* shapes stop looking like flat stickers */
.board svg{filter:drop-shadow(0 3px 5px rgba(0,0,0,.45))}

.namebox{
  font:inherit; font-size:14px; font-weight:700; color:var(--ink); text-align:center;
  background:rgba(0,0,0,.28); border:1px solid var(--stroke); border-radius:99px;
  padding:9px 14px; width:min(170px,42vw);
}
.namebox:focus{outline:2px solid var(--amber); outline-offset:1px}
.rankline{
  text-align:center; font-size:14px; font-weight:700; color:var(--ink-2); min-height:20px;
}
.rankline b{color:var(--amber); font-size:16px}
.rankline.good{color:var(--ink)}
.rankline.bad{color:var(--coral)}

/* ---------------- motion preferences ---------------- */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation:none !important; transition:none !important}
  .flash.on{opacity:1}
}
