:root{
  --bg:#0b1220;
  --panel:#101a33;
  --text:#e8efff;
  --muted:#9bb0d6;
  --good:#22c55e;
  --bad:#ef4444;
  --accent:#60a5fa;
  --border:rgba(255,255,255,.08);
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family:
    "Faruma",
    "MV Boli",
    "Noto Sans Thaana",
    system-ui,
    -apple-system,
    "Segoe UI",
    Arial,
    sans-serif;
  background: radial-gradient(1200px 600px at 20% 0%, #14224a, var(--bg));
  color:var(--text);
}

.topbar{
  padding:16px 18px;
  border-bottom:1px solid var(--border);
  background:rgba(0,0,0,.2);
  backdrop-filter: blur(10px);
}
/* ONE-ROW HEADER */
.topbar-row{
  display:flex;
  align-items:center;
  justify-content:center;   /* center the whole row */
  gap:24px;
  flex-wrap:wrap;           /* wraps nicely on small screens */
}

/* Each block */
.header-block{
  display:flex;
  align-items:center;
}

/* Lesson block */
.header-lesson{
  flex-direction:column;
  min-width:240px;
}

.lesson-row{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap:10px;
  font-size:13px;
  color:var(--muted);
}

.lesson-name{
  font-weight:600;
  color:var(--text);
}

.lesson-meta{
  display:flex;
  gap:8px;
  white-space:nowrap;
}

.lesson-meta .dot{ opacity:.6; }

/* Stats block */
.header-stats{
  gap:14px;
}

.stat{
  display:flex;
  flex-direction:column;
  gap:2px;
  padding:6px 10px;
  border-radius:10px;
  background:rgba(255,255,255,.05);
  text-align:center;
}

.stat-value{
  font-size:15px;
  font-weight:700;
  color:var(--text);
}

.stat-label{
  font-size:11px;
  opacity:.75;
}

.stat-streak{
  justify-content:center;
  font-weight:700;
}

/* Title block */
.header-title{
  white-space:nowrap;
}

.app-title{
  margin:0;
  font-size:18px;
  letter-spacing:.3px;
}

/* Mobile: stack cleanly */
@media (max-width: 900px){
  .topbar-row{
    gap:14px;
  }
}
.app-title{
  margin:0 0 10px;
  font-size:18px;
  letter-spacing:.3px;
}

/* Lesson block */
.lesson-header{
  margin-bottom:12px;
}

.lesson-row{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap:12px;
  font-size:13px;
  color:var(--muted);
}

.lesson-name{
  font-weight:600;
  color:var(--text);
}

.lesson-meta{
  display:flex;
  gap:8px;
  white-space:nowrap;
}

.lesson-meta .dot{
  opacity:.6;
}

/* Stats */
.stats{
  display:flex;
  gap:14px;
  flex-wrap:wrap;
  font-size:13px;
  color:var(--muted);
}

.stat{
  display:flex;
  flex-direction:column;
  gap:2px;
  padding:6px 10px;
  border-radius:10px;
  background:rgba(255,255,255,.05);
}

.stat-value{
  font-size:15px;
  font-weight:700;
  color:var(--text);
}

.stat-label{
  font-size:11px;
  opacity:.75;
}

.stat-streak{
  justify-content:center;
  font-weight:700;
  color:var(--text);
}
.topbar h1{margin:0 0 6px 0; font-size:18px; letter-spacing:.3px}
.stats{
  display:flex; gap:16px; flex-wrap:wrap;
  color:var(--muted);
  font-size:13px;
}

.container{
  max-width:980px;
  margin:0 auto;
  padding:18px;
  display:grid;
  grid-template-columns: 1fr;
  gap:16px;
}

.lesson, .keyboard{
  background:rgba(16,26,51,.75);
  border:1px solid var(--border);
  border-radius:14px;
  padding:14px;
}

.controls{
  display:flex;
  gap:8px;
  justify-content:flex-start;
}
button{
  background:rgba(255,255,255,.06);
  border:1px solid var(--border);
  color:var(--text);
  padding:8px 10px;
  border-radius:10px;
  cursor:pointer;
}
button:hover{border-color:rgba(96,165,250,.5)}

.prompt-wrap{
  margin-top:12px;
  padding:12px;
  border-radius:12px;
  background:rgba(0,0,0,.18);
  border:1px dashed rgba(255,255,255,.12);
}
.prompt{
  font-size:24px;
  line-height:1.6;
  letter-spacing:.5px;
  unicode-bidi: plaintext;
}

.input{
  margin-top:10px;
  width:100%;
  border-radius:12px;
  border:1px solid var(--border);
  padding:12px;
  background:rgba(0,0,0,.22);
  color:var(--text);
  font-size:22px;
  outline:none;
  unicode-bidi: plaintext;
  direction: rtl;
}

.prompt,
.input{
  font-family:
    "Faruma",
    "MV Boli",
    "Noto Sans Thaana",
    sans-serif;
}
.input:focus{border-color:rgba(96,165,250,.7)}

.hint{
  margin-top:10px;
  color:var(--muted);
  font-size:13px;
}

.kb-row{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:10px;
}
#kb{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.kb-key{
  min-width:44px;
  padding:10px 12px;
  border-radius:12px;
  font-size:18px;
}
.kb-key.wide{min-width:140px}
.kb-row.small .kb-key{font-size:14px}

.good{color:var(--good)}
.bad{color:var(--bad)}
.cursor{
  display:inline-block;
  width:2px;
  height:1.2em;
  background:var(--accent);
  vertical-align:-2px;
  margin:0 3px;
  animation: blink 1s infinite;
}
@keyframes blink{0%,49%{opacity:1}50%,100%{opacity:.15}}

.footer{
  text-align:center;
  color:var(--muted);
  padding:18px 0 26px;
}
/* Make the keyboard appear LTR even if the page is RTL */
.real-kb { direction: ltr; user-select: none; }

.kb-row{
  display:flex;
  gap:8px;
  margin-top:10px;
}

.kb-keycap{
  --size: clamp(34px, 4.2vw, 52px);
  --w: 1;

  position:relative;
  flex: var(--w) 0 0;
  min-width: calc(var(--size) * var(--w));
  height: var(--size);

  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.10);
  background:
    linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.04));
  box-shadow:
    0 10px 18px rgba(0,0,0,.35),
    inset 0 1px 0 rgba(255,255,255,.12);
  color: var(--text);
  cursor:pointer;
  overflow:hidden;
  padding:0;
}

.kb-keycap:hover{
  border-color: rgba(96,165,250,.55);
}

.kb-keycap:active,
.kb-keycap.pressed{
  transform: translateY(2px);
  box-shadow:
    0 6px 12px rgba(0,0,0,.35),
    inset 0 1px 0 rgba(255,255,255,.10);
}

.kb-keycap.dim{
  opacity: .45;
}

.legend{
  position:absolute;
  font-size: 12px;
  line-height: 1;
  opacity: .85;
}

.legend.tl{ top:10px; left:10px; font-weight:600; }
.legend.br{
  bottom:10px; right:10px;
  font-size: 18px;
  opacity: .95;
}

.kb-keycap.target{
  outline: 2px solid rgba(34,197,94,.85);
  box-shadow:
    0 0 0 2px rgba(34,197,94,.25),
    0 12px 22px rgba(0,0,0,.40);
}

/* Keyboard section should not follow page RTL layout */
.keyboard {
  direction: ltr;                 /* force LTR inside keyboard area */
}

/* The actual keyboard wrapper centered on the page */
.real-kb {
  direction: ltr;                 /* double guarantee */
  display: inline-block;          /* shrink-wrap width to keys */
  margin: 0 auto;                 /* center the inline-block */
}

/* Make the keyboard section center its content */
.keyboard {
  text-align: center;             /* centers inline-block children */
}

/* Each row should be LTR and centered */
.real-kb .kb-row {
  direction: ltr;
  display: flex;
  justify-content: center;        /* center the row */
  gap: 8px;
  margin-top: 10px;
}
.legend.tr{
  top:10px;
  right:10px;
  font-size: 14px;
  opacity: .85;
}

.kb-keycap.latched{
  outline: 2px solid rgba(96,165,250,.85);
  box-shadow:
    0 0 0 2px rgba(96,165,250,.25),
    0 12px 22px rgba(0,0,0,.40);
}
.kb-keycap.needShift{
  outline: 2px dashed rgba(34,197,94,.8);
}
/* Next key highlight (yellow glow) */
.kb-keycap.target{
  outline: 3px solid #FFD54A;
  box-shadow:
    0 0 0 3px rgba(255, 213, 74, 0.20),
    0 0 18px rgba(255, 213, 74, 0.55),
    0 10px 18px rgba(0,0,0,.35),
    inset 0 1px 0 rgba(255,255,255,.12);
}

/* If Shift is needed for the next char, highlight Shift too */
.kb-keycap.needShift{
  outline: 3px dashed #FFD54A;
  box-shadow:
    0 0 0 3px rgba(255, 213, 74, 0.18),
    0 0 14px rgba(255, 213, 74, 0.45);
}
.progress-wrap{
  margin: 10px 0 14px;
}

.progress-label{
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  opacity: .85;
  margin-bottom: 4px;
}

.progress-bar{
  height: 8px;
  background: rgba(255,255,255,.12);
  border-radius: 999px;
  overflow: hidden;
}

#progressFill{
  height: 100%;
  width: 0%;
  background: linear-gradient(
    90deg,
    #60a5fa,
    #22c55e
  );
  transition: width .35s ease;
}
.lesson-complete {
  animation: pop 0.4s ease;
}

@keyframes pop {
  0%   { transform: scale(0.96); opacity: 0.6; }
  60%  { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); }
}
/* Next character indicator (replaces blinking cursor) */
#prompt .next {
  color: #facc15;          /* yellow */
  font-weight: 600;
  text-shadow: 0 0 6px rgba(250, 204, 21, 0.45);
}
.kb-keycap.finger-L-pinky  { box-shadow: 0 0 0 3px rgba(255, 99, 132, .25); }
.kb-keycap.finger-L-ring   { box-shadow: 0 0 0 3px rgba(255, 159, 64, .25); }
.kb-keycap.finger-L-middle { box-shadow: 0 0 0 3px rgba(255, 205, 86, .22); }
.kb-keycap.finger-L-index  { box-shadow: 0 0 0 3px rgba(75, 192, 192, .22); }

.kb-keycap.finger-R-index  { box-shadow: 0 0 0 3px rgba(54, 162, 235, .22); }
.kb-keycap.finger-R-middle { box-shadow: 0 0 0 3px rgba(153, 102, 255, .22); }
.kb-keycap.finger-R-ring   { box-shadow: 0 0 0 3px rgba(201, 203, 207, .18); }
.kb-keycap.finger-R-pinky  { box-shadow: 0 0 0 3px rgba(255, 99, 255, .18); }

.kb-keycap.finger-thumb    { box-shadow: 0 0 0 3px rgba(250, 204, 21, .20); }
.input.done{
  border-color: rgba(34,197,94,.8);
}
/* Default: hide keyboard */
.keyboard {
  display: none;
}

/* Show only on desktop/larger screens */
@media (min-width: 769px) {
  .keyboard {
    display: block;
  }
}
