
:root{
  --text:#e5e7eb;
  --muted:#9ca3af;
  --card:#111827;
  --accent:#f97316;
  --ok:#22c55e;
  --bad:#f97316;
}
*{box-sizing:border-box;margin:0;padding:0}
body{
  font:16px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,Arial;
  color:var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(0,0,0,0.45), transparent 55%),
    radial-gradient(circle at 85% 0%, rgba(15,23,42,0.55), transparent 55%),
    radial-gradient(circle at 50% 100%, rgba(15,23,42,0.85), transparent 60%),
    linear-gradient(180deg, #020617 0%, #020617 40%, #020617 70%, #000000 100%);
  background-attachment:fixed;
  animation: fire-flicker 4.7s ease-in-out infinite;
}

@keyframes fire-flicker{
  0%{ filter:brightness(1) saturate(1.1); }
  25%{ filter:brightness(1.12) saturate(1.3); }
  50%{ filter:brightness(1.03) saturate(1.15); }
  75%{ filter:brightness(1.16) saturate(1.35); }
  100%{ filter:brightness(1) saturate(1.1); }
}
.top-made{
  text-align:center;
  padding:8px 0;
  font-size:14px;
  letter-spacing:0.12em;
  text-transform:uppercase;
  color:#fecaca;
  background:linear-gradient(90deg, rgba(248,113,113,.12), rgba(252,211,77,.25), rgba(248,113,113,.12));
  border-bottom:1px solid rgba(248,113,113,.3);
}
.wrap{max-width:980px;margin:0 auto;padding:24px}
h1{font-size:clamp(24px,3.3vw,38px);margin-bottom:6px;text-shadow:0 2px 12px rgba(0,0,0,.5);}
.sub{color:var(--muted);margin-bottom:18px}
.card{
  background:rgba(15,23,42,0.96);
  border-radius:16px;
  border:1px solid rgba(248,250,252,0.08);
  box-shadow:0 14px 45px rgba(0,0,0,.55), 0 0 20px rgba(248,113,113,.25);
  padding:18px;
  margin:18px 0;
  backdrop-filter: blur(20px);
}
.controls .row{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(210px,1fr));
  gap:12px;
  margin-bottom:12px;
}
label{display:flex;flex-direction:column;gap:6px;color:var(--muted);font-size:14px}
select,input{
  padding:10px;
  border-radius:10px;
  border:1px solid rgba(148,163,184,.6);
  background:rgba(15,23,42,.9);
  color:var(--text);
}
button{
  padding:10px 14px;
  border-radius:10px;
  border:1px solid rgba(248,250,252,0.2);
  background:transparent;
  color:var(--text);
  cursor:pointer;
  font-weight:500;
}
button.primary{
  background:linear-gradient(135deg,#f97316,#fb923c);
  border:none;
  color:#111827;
  font-weight:700;
  box-shadow:0 0 18px rgba(248,113,113,.6);
}
button.primary:hover{transform:translateY(-1px);}
button.ghost{opacity:.85}
.hidden{display:none}
.q{margin:12px 0;padding:14px;border-radius:12px;border:1px solid rgba(148,163,184,.45);background:rgba(15,23,42,0.92);transition:transform .1s ease;}
.q h3{margin-bottom:10px;font-size:17px}
.opts{display:grid;gap:8px}
.opt{
  display:flex;gap:10px;align-items:center;
  padding:10px 11px;
  border-radius:10px;
  background:rgba(15,23,42,0.9);
  border:1px solid rgba(30,64,175,0.4);
  transition:transform .08s ease, box-shadow .2s ease, border-color .2s ease;
}
.opt:hover{
  transform:translateY(-2px);
  box-shadow:0 6px 18px rgba(0,0,0,.45);
  border-color:rgba(251,146,60,0.9);
}
.opt input{margin:0}
.feedback{margin-top:6px;font-size:14px}
.feedback.ok{color:var(--ok)}
.feedback.bad{color:var(--bad)}
.score{font-size:20px}
.foot{text-align:center;opacity:.8}

/* Confetti */
#confetti-root{position:fixed;inset:0;pointer-events:none;overflow:hidden}
.confetti-piece{
  position:absolute;width:8px;height:12px;opacity:.95;
  will-change: transform, opacity;
  animation: confetti-pop .9s ease-out forwards;
}
@keyframes confetti-pop{
  0%{transform:translate(var(--x),var(--y)) rotate(0deg) scale(0.6);opacity:0}
  30%{opacity:1}
  100%{transform:translate(calc(var(--x) + var(--dx)), calc(var(--y) + var(--dy))) rotate(340deg) scale(1);opacity:0}
}

/* Macro wrong-answer animation */
#flash-root{position:fixed;inset:0;pointer-events:none}
.flashburst{
  position:absolute;inset:0;
  background:radial-gradient(circle at 50% 50%, rgba(248,113,113,.35), rgba(127,29,29,.6), rgba(0,0,0,0) 60%);
  animation: flash-fade 420ms ease-out forwards;
}
@keyframes flash-fade{
  from{opacity:1} to{opacity:0}
}
.shake-strong{
  animation: shake-kaboom 650ms cubic-bezier(.36,.07,.19,.97) both;
}
@keyframes shake-kaboom{
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-8px, 0, 0); }
  40%, 60% { transform: translate3d(8px, 0, 0); }
}

/* Rain man background */
body{
  background:
    linear-gradient(to top, rgba(3,7,18,0.92), rgba(15,23,42,0.45)),
    url("assets/img/rain-man.png") center bottom / cover no-repeat fixed;
  background-attachment: fixed;
}

/* Loading overlay */
#loader{
  position:fixed;inset:0;
  display:flex;align-items:center;justify-content:center;
  background:radial-gradient(circle at 50% 10%, rgba(56,189,248,.15), rgba(15,23,42,.95));
  z-index:40;
}
#loader.hidden{opacity:0;pointer-events:none;transition:opacity .4s ease;}
.loader-inner{text-align:center;gap:16px;display:flex;flex-direction:column;align-items:center;}
.loader-ring{
  width:72px;height:72px;border-radius:999px;
  border:3px solid rgba(59,130,246,.35);
  border-top-color:#22d3ee;
  animation:spin 1s linear infinite, glow 1.8s ease-in-out infinite alternate;
  box-shadow:0 0 18px rgba(56,189,248,.6);
}
.loader-text{color:#e5e7eb;font-size:15px;letter-spacing:.08em;text-transform:uppercase;}
@keyframes spin{to{transform:rotate(360deg);}}
@keyframes glow{
  0%{box-shadow:0 0 12px rgba(56,189,248,.4);}
  100%{box-shadow:0 0 28px rgba(94,234,212,.9);}
}

/* header flex + theme toggle */
.header-flex{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
}
.theme-toggle{
  align-self:flex-start;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid rgba(148,163,184,.7);
  background:rgba(15,23,42,.9);
  color:#e5e7eb;
  font-size:13px;
  cursor:pointer;
  box-shadow:0 0 12px rgba(59,130,246,.5);
}

/* Neon card glow */
.card{
  box-shadow:
    0 16px 40px rgba(0,0,0,.7),
    0 0 24px rgba(56,189,248,.25),
    0 0 48px rgba(168,85,247,.18);
  border-image:linear-gradient(135deg,#22d3ee,#a855f7,#f97316) 1;
}

/* Matrix canvas */
#matrixCanvas{
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index:0;
  opacity:0.22;
  mix-blend-mode:screen;
}

/* Ensure main content above matrix */
body > .wrap,
header.wrap,
footer.wrap,
#loader{position:relative;z-index:1;}

/* Light mode */
body.light-mode{
  background:#f9fafb;
  color:#111827;
}
body.light-mode .card{
  background:#ffffffee;
  border-color:rgba(148,163,184,.7);
  box-shadow:0 10px 25px rgba(15,23,42,.12);
}
body.light-mode select,
body.light-mode input{
  background:#f1f5f9;
  color:#0f172a;
}
body.light-mode .theme-toggle{
  background:#e5e7eb;
  color:#111827;
}
body.light-mode #matrixCanvas{
  opacity:0.08;
}

/* Responsive tweaks */
@media (max-width:768px){
  .wrap{padding:16px;}
  h1{font-size:22px;}
  .controls .row{
    grid-template-columns:1fr;
  }
  .card{padding:14px;}
  .header-flex{flex-direction:column;}
}

/* Keep existing flash & shake if defined */

/* Combo popup */
.combo-pop{
  position:fixed;
  transform:translate(-50%,-100%);
  padding:6px 14px;
  border-radius:999px;
  background:rgba(34,197,94,0.16);
  border:1px solid rgba(34,197,94,0.75);
  color:#bbf7d0;
  font-size:13px;
  font-weight:600;
  text-shadow:0 0 10px rgba(22,163,74,.8);
  animation:combo-pop 0.85s ease-out forwards;
  pointer-events:none;
  z-index:30;
}
@keyframes combo-pop{
  0%{opacity:0;transform:translate(-50%,-120%) scale(0.8);}
  20%{opacity:1;transform:translate(-50%,-140%) scale(1.05);}
  100%{opacity:0;transform:translate(-50%,-200%) scale(0.9);}
}

/* Boss fight flash */
.boss-flash{
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index:35;
  background:radial-gradient(circle at 50% 50%, rgba(251,113,133,.4), rgba(15,23,42,.98));
  animation:boss-flash-anim .65s ease-out forwards;
}
.boss-flash.success{
  background:radial-gradient(circle at 50% 50%, rgba(74,222,128,.45), rgba(8,47,73,.98));
}
@keyframes boss-flash-anim{
  0%{opacity:0;}
  20%{opacity:1;}
  100%{opacity:0;}
}

/* Top-right made by serdar */
.top-made{
  position:fixed;
  top:8px;
  right:10px;
  font-size:9px;
  letter-spacing:0.12em;
  text-transform:uppercase;
  padding:4px 10px;
  border-radius:999px;
  color:#fecaca;
  background:rgba(15,23,42,0.85);
  border:1px solid rgba(248,113,113,.4);
  z-index:50;
}
body.light-mode .top-made{
  background:rgba(248,250,252,0.95);
  color:#b91c1c;
  border-color:rgba(248,113,113,.7);
}

/* Highscore small text */
.score.small{font-size:13px;opacity:.85;margin-top:4px;}

.hs-table{
  width:100%;
  border-collapse:collapse;
  margin-top:8px;
  font-size:13px;
}
.hs-table th,
.hs-table td{
  border:1px solid rgba(148,163,184,.4);
  padding:4px 6px;
  text-align:left;
}
.hs-table th{
  background:rgba(15,23,42,.85);
}
body.light-mode .hs-table th{
  background:#e5e7eb;
}

/* Forklift background (layered) */
body{
  background:
    radial-gradient(circle at 20% 0%, rgba(56,189,248,0.18), transparent 55%),
    radial-gradient(circle at 80% 0%, rgba(244,114,182,0.22), transparent 55%),
    url("assets/img/forklifts-wall.png") center center / cover no-repeat fixed;
}

/* High score floating panel */
.hs-float{
  position:fixed;
  top:40px;
  right:12px;
  z-index:40;
  max-width:260px;
  font-size:12px;
}
.hs-float-inner{
  background:rgba(15,23,42,0.94);
  border-radius:14px;
  border:1px solid rgba(56,189,248,0.6);
  box-shadow:0 12px 30px rgba(0,0,0,.6);
  padding:8px;
}
.hs-float-title{
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.08em;
  margin-bottom:4px;
  color:#a5b4fc;
}

/* Exam side card */
.exam-side{
  margin-top:8px;
  font-size:14px;
}
.exam-side .hs-note{
  font-size:12px;
  color:#9ca3af;
}

/* Buttons layout */
.row.row-buttons{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
}
.btn-group{
  display:flex;
  gap:8px;
}
.mini-btn{
  font-size:13px;
}

/* Mini-game overlay */
.mini-overlay{
  position:fixed;
  inset:0;
  background:radial-gradient(circle at 50% 0%, rgba(56,189,248,0.25), rgba(15,23,42,0.96));
  z-index:60;
  display:flex;
  align-items:center;
  justify-content:center;
}
.mini-overlay.hidden{display:none;}
.mini-inner{
  width:min(600px,90vw);
  background:rgba(15,23,42,0.96);
  border-radius:18px;
  border:1px solid rgba(56,189,248,0.8);
  box-shadow:0 18px 45px rgba(0,0,0,.8);
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.mini-top{
  display:flex;
  justify-content:space-between;
  align-items:center;
}
.mini-close{
  padding:4px 10px;
  font-size:12px;
}
.mini-text{
  font-size:14px;
  color:#e5e7eb;
}
.mini-stats{
  display:flex;
  justify-content:space-between;
  font-size:14px;
  margin-bottom:6px;
}
.mini-field{
  position:relative;
  height:260px;
  border-radius:14px;
  background:radial-gradient(circle at 50% 0%, rgba(15,23,42,0.9), rgba(15,23,42,0.98));
  overflow:hidden;
}
.mini-target{
  position:absolute;
  width:54px;
  height:54px;
  background:url("assets/img/forklift-icon.png") center center / contain no-repeat;
  cursor:pointer;
}

/* hs-table tweaks for float */
.hs-table{
  width:100%;
  border-collapse:collapse;
  margin-top:4px;
  font-size:9px;
}
.hs-table th,
.hs-table td{
  border:1px solid rgba(148,163,184,.4);
  padding:3px 4px;
  text-align:left;
}
.hs-table th{
  background:rgba(15,23,42,.85);
}
body.light-mode .hs-table th{
  background:#e5e7eb;
}

/* Responsive */
@media (max-width:768px){
  .hs-float{display:none;}
  .row.row-buttons{flex-direction:column;align-items:stretch;}
  .mini-inner{padding:12px;}
}
