/* ============ MultiPLAD — DDR-inspired (original, unbranded) ============ */

/* IMPORTANT: .screen below sets `display: flex`, which overrides the
   UA stylesheet's [hidden]{display:none} (author styles win at equal
   specificity). This guard makes our `hidden` attribute actually work. */
[hidden] { display: none !important; }

:root {
  --bg1: #0d0b1e;
  --bg2: #1a1033;
  --bg3: #241452;
  --ink: #fff;
  --dim: #b9b3d9;
  --card: rgba(255, 255, 255, 0.06);
  --card-line: rgba(255, 255, 255, 0.14);
  --up: #37c6ff;
  --down: #ffd53d;
  --left: #ff5ea8;
  --right: #5cff8f;
  --ok: #5cff8f;
  --bad: #ff5370;
  --btn: #4438b5;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  font-family: "Baloo 2", "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 20% -10%, #4b2a9e55, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #1652b355, transparent 60%),
    linear-gradient(160deg, var(--bg1), var(--bg2) 55%, var(--bg3));
  background-attachment: fixed;
}

/* subtle grid floor */
body::before {
  content: "";
  position: fixed;
  inset: auto 0 0 0;
  height: 45vh;
  background:
    linear-gradient(transparent, transparent 82%, #ffffff08),
    repeating-linear-gradient(90deg, #ffffff0a 0 1px, transparent 1px 64px),
    repeating-linear-gradient(0deg, #ffffff0a 0 1px, transparent 1px 44px);
  mask-image: linear-gradient(transparent, black);
  pointer-events: none;
  z-index: 0;
}

#fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px 16px 48px;
  animation: screenin .25s ease both;
}
@keyframes screenin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- header ---------- */
.logo {
  margin: 0;
  font-size: clamp(44px, 9vw, 88px);
  font-weight: 800;
  letter-spacing: 2px;
  text-shadow: 0 0 18px #7f5bffcc, 0 4px 0 #0007;
}
.logo span {
  background: linear-gradient(180deg, var(--up), var(--right));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline { margin: -6px 0 6px; color: var(--dim); font-size: 18px; }

/* ---------- card & buttons ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 22px;
  padding: 22px 24px;
  width: min(560px, 94vw);
  backdrop-filter: blur(6px);
  box-shadow: 0 18px 60px #0007;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card h2 { margin: 0 0 4px; }

.btn {
  font: inherit;
  font-weight: 700;
  color: white;
  background: linear-gradient(180deg, #5b4fd6, var(--btn));
  border: 1px solid #8a7dff55;
  border-radius: 14px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease, box-shadow .15s ease;
  box-shadow: 0 6px 0 #221b5e, 0 10px 22px #0006;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #221b5e; }
.btn-big { font-size: 22px; padding: 16px 22px; }
.btn-primary {
  background: linear-gradient(180deg, var(--right), #2fbf66);
  border-color: #b8ffce66;
  box-shadow: 0 6px 0 #1d7a45, 0 10px 22px #0006;
  color: #05270f;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .btn { flex: 1; }
.row.inline { flex-wrap: wrap; }
.row.inline label {
  color: var(--dim);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}
.row.inline select {
  font: inherit;
  color: var(--ink);
  background: #ffffff14;
  border: 1px solid var(--card-line);
  border-radius: 10px;
  padding: 7px 10px;
}
.chk input { accent-color: var(--right); width: 18px; height: 18px; }

.hint { color: var(--dim); font-size: 14px; text-align: center; margin: 0; }
.small { color: var(--dim); font-size: 13px; }

/* ---------- HUD ---------- */
.hud {
  position: relative;
  z-index: 2;
  width: min(620px, 94vw);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.hud-box {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 14px;
  padding: 8px 10px;
  text-align: center;
}
.hud-box small { display: block; color: var(--dim); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
.hud-box b { font-size: 22px; }
#hud-combo-box.hot { border-color: var(--right); box-shadow: 0 0 18px #5cff8f44; }

/* ---------- stage ---------- */
.stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(620px, 94vw);
}

.equation {
  font-size: clamp(40px, 8vw, 72px);
  font-weight: 800;
  text-shadow: 0 0 24px #ffffff22;
  letter-spacing: 2px;
  line-height: 1;
}
.equation.pop { animation: pop .3s ease; }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
.eq-q { color: var(--dim); font-size: .7em; }

.status {
  height: 34px;
  font-weight: 800;
  font-size: 22px;
  transition: opacity .2s;
}
.status.good { color: var(--ok); text-shadow: 0 0 14px #5cff8f66; }
.status.bad { color: var(--bad); text-shadow: 0 0 14px #ff537066; }
.status.timeout { color: var(--down); }

.timerwrap {
  width: 70%;
  max-width: 420px;
  height: 12px;
  border-radius: 99px;
  background: #ffffff14;
  border: 1px solid var(--card-line);
  overflow: hidden;
}
.timerbar {
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--up), var(--right));
  transition: none;
}

/* ---------- pad ---------- */
.pad {
  position: relative;
  width: min(420px, 88vw);
  aspect-ratio: 1;
  background: radial-gradient(circle at 30% 25%, #3a2a7a, #17103a 70%);
  border: 3px solid #ffffff26;
  border-radius: 28px;
  box-shadow: inset 0 0 60px #000a, 0 22px 60px #0009;
  display: grid;
  grid-template-areas:
    ".  up   ."
    "left mid right"
    ".  down .";
  grid-template-columns: 1fr 1.1fr 1fr;
  grid-template-rows: 1fr 1.1fr 1fr;
  gap: 10px;
  padding: 14px;
  user-select: none;
}
.pad::after {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  border: 2px dashed #ffffff14;
  pointer-events: none;
}
.receptor {
  position: relative;
  border-radius: 18px;
  background: linear-gradient(180deg, #241c52, #140f33);
  border: 2px solid #ffffff1f;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform .06s ease, box-shadow .12s ease, border-color .12s ease;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.r-up { grid-area: up; }
.r-left { grid-area: left; }
.r-right { grid-area: right; }
.r-down { grid-area: down; }

.receptor .arrow {
  font-size: clamp(34px, 7vw, 56px);
  line-height: 1;
  color: #ffffff55;
  transition: color .1s, filter .1s;
}
.receptor .chip {
  min-height: 1.4em;
  font-size: clamp(20px, 4.5vw, 32px);
  font-weight: 800;
  color: #ffffffc9;
}

.receptor.hit {
  transform: scale(1.05);
  border-color: white;
}
.r-up.hit     { background: linear-gradient(180deg, #0d3d5a, #0a2233); border-color: var(--up); box-shadow: 0 0 34px #37c6ff88, inset 0 0 24px #37c6ff55; }
.r-left.hit    { background: linear-gradient(180deg, #571f3f, #320f21); border-color: var(--left); box-shadow: 0 0 34px #ff5ea888, inset 0 0 24px #ff5ea855; }
.r-right.hit   { background: linear-gradient(180deg, #14522c, #0b301a); border-color: var(--right); box-shadow: 0 0 34px #5cff8f88, inset 0 0 24px #5cff8f55; }
.r-down.hit    { background: linear-gradient(180deg, #5c4a10, #332a08); border-color: var(--down); box-shadow: 0 0 34px #ffd53d88, inset 0 0 24px #ffd53d55; }
.r-up.hit .arrow     { color: var(--up); filter: drop-shadow(0 0 10px var(--up)); }
.r-left.hit .arrow    { color: var(--left); filter: drop-shadow(0 0 10px var(--left)); }
.r-right.hit .arrow   { color: var(--right); filter: drop-shadow(0 0 10px var(--right)); }
.r-down.hit .arrow    { color: var(--down); filter: drop-shadow(0 0 10px var(--down)); }

.receptor.shake { animation: shake .35s ease; }
@keyframes shake {
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}
.receptor.faded { opacity: .35; }
.receptor.faded .chip { visibility: hidden; }
.receptor.answer .chip { color: #fff; background: #00000033; padding: 0 8px; border-radius: 8px; }

.pad-preview { pointer-events: none; margin: 6px auto 0; width: min(300px, 70vw); }

/* ---------- calibration ---------- */
.pad-status { font-size: 16px; }
.pad-status .ok { color: var(--ok); }
.calib-step { font-size: 20px; font-weight: 700; }
#calibration { display: flex; flex-direction: column; gap: 4px; align-items: center; }

/* ---------- summary / stats ---------- */
.sum-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sum-item {
  background: #ffffff0a;
  border: 1px solid var(--card-line);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}
.sum-item b { display: block; font-size: 30px; }
.sum-item small { color: var(--dim); }

.misslist { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.misspill {
  background: #ff537022;
  border: 1px solid #ff537066;
  border-radius: 99px;
  padding: 6px 14px;
  font-weight: 700;
}
.misspill small { color: var(--dim); font-weight: 500; }

@media (max-width: 480px) {
  .hud { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
