:root{
  --bg:#070a12;
  --card:#0d1222;
  --text:#e9f0ff;
  --muted:#9bb0d6;
  --line:rgba(255,255,255,.12);
  --shadow:0 20px 60px rgba(0,0,0,.55);
  --radius:22px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  background:
    radial-gradient(1200px 600px at 10% 10%, rgba(122,51,255,.22), transparent 60%),
    radial-gradient(900px 500px at 90% 30%, rgba(0,255,200,.16), transparent 55%),
    radial-gradient(1000px 700px at 50% 110%, rgba(255,153,0,.10), transparent 60%),
    var(--bg);
  color:var(--text);
}

.app{max-width:1150px;margin:0 auto;padding:18px 14px 38px}

.top{
  display:flex;
  gap:14px;
  align-items:flex-start;
  justify-content:space-between;
  flex-wrap:wrap;
}

.brand{min-width:260px}
.brandTitle{font-weight:900;letter-spacing:.5px;font-size:28px}
.brandSub{color:var(--muted);font-size:13px;margin-top:4px;max-width:520px;line-height:1.35}

.controls{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.ctl{
  display:flex;
  flex-direction:column;
  gap:6px;
  font-size:12px;
  color:var(--muted);
}

select,input,textarea{
  background:rgba(255,255,255,.06);
  border:1px solid var(--line);
  color:var(--text);
  border-radius:14px;
  padding:10px 12px;
  outline:none;
}
select{padding-right:34px}

input[type="range"]{height:40px;padding:0 10px}

.btnRow{display:flex;gap:10px;align-items:flex-end}

.glowBtn, .ghostBtn {
    border-radius: 16px;
    padding: 10px 12px;
    font-weight: 800;
    border: 1px solid rgba(255, 255, 255, .14);
    cursor: pointer;
    user-select: none;
    color: white;
}
.ghostBtn{background:transparent;color:var(--text)}

.glowBtn {
    background: linear-gradient(135deg, rgba(255, 0, 200, .22), rgba(0, 255, 210, .18));
    position: relative;
    box-shadow: 0 0 0 1px rgb(255 255 255 / 52%) inset, 0 0 18px rgb(255 0 200 / 93%), 0 0 26px rgb(0 255 210);
    transition: transform .12s ease, filter .12s ease;
    filter: saturate(1.2);
}

.glowBtn:hover{transform:translateY(-1px);filter:saturate(1.6) brightness(1.08)}
.glowBtn:active{transform:translateY(0px) scale(.99)}

.stage{margin-top:14px}

.card{
  background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border:1px solid var(--line);
  box-shadow:var(--shadow);
  border-radius:var(--radius);
  padding:14px;
  position:relative;
}

.progress{display:flex;align-items:center;gap:10px;margin-bottom:10px}
.meter{flex:1;height:10px;border-radius:999px;background:rgba(255,255,255,.06);overflow:hidden;border:1px solid var(--line)}
.meterFill{height:100%;width:0%;background:linear-gradient(90deg, rgba(0,255,210,.8), rgba(255,0,200,.8));}
.progressText{font-size:12px;color:var(--muted);min-width:70px;text-align:right}

.viewer{
  border-radius:20px;
  overflow:hidden;
  border:1px solid var(--line);
  background:rgba(0,0,0,.25);
  position:relative;
}

.viewer img{
  display:block;
  width:100%;
  max-height:520px;
  object-fit:contain;
  background:rgba(0,0,0,.35);
  transition:opacity .45s ease;
}

.viewer.fadeOut img{opacity:0}

.hint{
  position:absolute;
  left:14px;
  bottom:14px;
  padding:8px 10px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(0,0,0,.35);
  backdrop-filter: blur(10px);
  font-weight:900;
  letter-spacing:.2px;
  line-height:1.2;
  max-width:calc(100% - 28px);
}

.typeArea{margin-top:12px}
.promptRow{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.promptLabel{color:var(--muted);font-size:12px}
.targetWord{font-weight:950;font-size:16px;opacity:.08;transition:opacity .15s ease}

.answerInput{
  width:100%;
  margin-top:10px;
  font-size:18px;
  padding:14px 14px;
  border-radius:18px;
}

.feedback{margin-top:10px;color:var(--muted);min-height:22px;font-size:13px}

.pickArea{margin-top:12px}
.pickTitle{color:var(--muted);font-size:12px;margin:6px 0 10px}
.pickGrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}

.pickBtn{
  border-radius:18px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.04);
  cursor:pointer;
  box-shadow:0 0 20px rgba(0,255,210,.08);
  transition:transform .12s ease, filter .12s ease;
}
.pickBtn:hover{transform:translateY(-1px);filter:brightness(1.08)}
.pickBtn:active{transform:translateY(0px) scale(.99)}
.pickBtn img{width:100%;height:200px;object-fit:cover;display:block}

.kbdToggle{
  position:fixed;
  right:14px;
  bottom:14px;
  z-index:20;
  border-radius:999px;
  padding:12px 14px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(0,0,0,.35);
  color:var(--text);
  font-weight:900;
  cursor:pointer;
  box-shadow:0 14px 38px rgba(0,0,0,.55);
}

.kbd{
  position:fixed;
  left:50%;
  transform:translateX(-50%);
  bottom:72px;
  width:min(980px, calc(100% - 20px));
  border-radius:22px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(10,14,26,.84);
  box-shadow:var(--shadow);
  z-index:30;
  backdrop-filter: blur(14px);
}

.kbdTop{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border-bottom:1px solid rgba(255,255,255,.10)}
.kbdTitle{font-weight:950}
.kbdClose{border:none;background:transparent;color:var(--text);font-size:18px;cursor:pointer}
.kbdBody{padding:10px 10px 14px;display:flex;flex-direction:column;gap:8px}

.kbdRow{display:flex;gap:8px;flex-wrap:wrap}
.key{
  min-width:42px;
  padding:10px 10px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.06);
  color:var(--text);
  cursor:pointer;
  font-weight:850;
}
.key.wide{min-width:90px}
.key.xwide{min-width:140px}
.key:hover{filter:brightness(1.1)}

.modal{position:fixed;inset:0;z-index:60}
.modalBackdrop{position:absolute;inset:0;background:rgba(0,0,0,.62)}
.modalCard{
  position:relative;
  width:min(720px, calc(100% - 20px));
  margin:6vh auto 0;
  border-radius:22px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(10,14,26,.92);
  box-shadow:var(--shadow);
}

.modalHeader{display:flex;align-items:center;justify-content:space-between;padding:12px 14px;border-bottom:1px solid rgba(255,255,255,.10)}
.modalTitle{font-weight:950;font-size:16px}
.modalX{border:none;background:transparent;color:var(--text);font-size:18px;cursor:pointer}
.modalBody{padding:14px}
.modalFooter{display:flex;gap:10px;justify-content:flex-end;padding:12px 14px;border-top:1px solid rgba(255,255,255,.10)}
.field{display:flex;flex-direction:column;gap:8px;margin-bottom:12px;color:var(--muted);font-size:12px}
.miniHelp{color:rgba(255,255,255,.55);font-size:12px;line-height:1.35;margin-top:6px}

@media (max-width:720px){
  .pickGrid{grid-template-columns:repeat(1,minmax(0,1fr))}
  .pickBtn img{height:220px}
}

/* Blackout training (hide the big prompt picture so you must rely on audio) */
.is-blackout{
  filter: brightness(0) contrast(1) !important;
}
.pill.glow{
  box-shadow: 0 0 18px rgba(160, 90, 255, .55), 0 0 28px rgba(0, 220, 255, .25);
}
.pill.glow:active{
  transform: translateY(1px);
}
/* Dropdown readable (select + options) */
select {
  background: #111 !important;
  color: #fff !important;
  border: 1px solid #333 !important;
}

select option {
  background: #111 !important;
  color: #fff !important;   /* makes the list items readable */
}

/* When highlighted/selected (some browsers) */
select option:checked,
select option:hover {
  background: #333 !important;
  color: #fff !important;
}

/* Particle dust transition canvas (overlays the big image) */
#dustCanvas{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  pointer-events:none;
  opacity:0;
  transition: opacity .15s ease;
}
.viewer.is-dusting #dustCanvas{ opacity:1; }
.viewer.is-dusting img{ opacity:0 !important; }


/* Pick-mode particle dust overlay (over the 4 choice pictures) */
#pickArea{ position: relative; }
#pickDustCanvas{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  pointer-events:none;
  opacity:0;
  transition: opacity .15s ease;
}
#pickArea.is-dusting #pickDustCanvas{ opacity:1; }
#pickArea.is-dusting #pickGrid{ opacity:0; }


/* Prev/Next arrows */
.navBtn{
  min-width:52px;
  padding:10px 0;
  text-align:center;
  font-size:18px;
  line-height:1;
}


/* Score row */
.scoreRow{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  margin:10px 0 8px;
}
.pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:8px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.06);
  font-weight:900;
  color:var(--text);
}
.pill.good{ box-shadow:0 0 18px rgba(0,255,210,.12); }
.pill.bad{ box-shadow:0 0 18px rgba(255,0,200,.12); }
.smallBtn{ padding:8px 10px; border-radius:14px; font-weight:900; }


/* Giant red X + buzzer feedback */
.wrongOverlay{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  pointer-events:none;
  opacity:0;
  z-index:9999;
}
.wrongOverlay.show{
  animation: wrongFlash 650ms ease-out forwards;
}
.wrongX{
  font-size:min(46vw, 360px);
  font-weight:1000;
  line-height:1;
  color:#ff1e2a;
  text-shadow:
    0 0 22px rgba(255,30,42,.75),
    0 0 60px rgba(255,30,42,.55),
    0 0 110px rgba(255,30,42,.35);
  transform: scale(.82) rotate(-6deg);
}
@keyframes wrongFlash{
  0%{opacity:0; transform:scale(1);}
  12%{opacity:1;}
  55%{opacity:1;}
  100%{opacity:0;}
}
/* ===========================
   FIX: button row wrapping
   paste at very bottom
   =========================== */

/* Let the buttons wrap instead of stretching the page */
.btnRow{
  flex-wrap: wrap;
  align-items: center;  /* better than flex-end */
  justify-content: flex-end;
  width: 100%;
}

/* Keep buttons from getting too wide / weird */
.btnRow .glowBtn,
.btnRow .ghostBtn,
.btnRow .navBtn{
  white-space: nowrap;
}

/* Make controls block not overflow */
.controls{
  max-width: 100%;
}

/* On phones: make buttons 2 per row (and arrows smaller) */
@media (max-width: 720px){
  .btnRow{
    justify-content: stretch;
  }
  .btnRow .glowBtn,
  .btnRow .ghostBtn{
    width: calc(50% - 5px);
    min-width: 0;
  }
  .btnRow .navBtn{
    width: calc(25% - 8px);
    min-width: 0;
  }
}

/* On very small phones: 1 button per row */
@media (max-width: 420px){
  .btnRow .glowBtn,
  .btnRow .ghostBtn{
    width: 100%;
  }
  .btnRow .navBtn{
    width: calc(50% - 5px);
  }
}

.rangeBox{
  display:flex;
  align-items:center;
  gap:10px;
  padding:6px 10px;
  border-radius:14px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  backdrop-filter: blur(10px);
}

.rangeLbl{
  font-size: 12px;
  opacity: .85;
  white-space: nowrap;
}

.rangeInp{
  width: 84px;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.25);
  color: #fff;
  outline: none;
}

@media (max-width: 520px){
  .rangeBox{
    flex-wrap: wrap;
    justify-content: center;
    gap:8px;
  }
  .rangeInp{ width: 110px; }
}