/* NvimQuest — neon terminal theme */
:root {
  --bg: #0a0e14;
  --panel: #10161f;
  --panel2: #151d29;
  --line: #1e2a3a;
  --ink: #c7d5e0;
  --dim: #5c6f80;
  --acc: #5ef2b8;      /* neon mint */
  --acc2: #7aa2ff;     /* neon blue */
  --gold: #ffd166;
  --warn: #ff6b81;
  --target: #ff9e64;
  --sel: rgba(122,162,255,.28);
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, #14202e 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: var(--mono);
  overflow: hidden;
}
#app { height: 100vh; }
.screen { height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* subtle CRT overlay */
#crt {
  pointer-events: none; position: fixed; inset: 0; z-index: 99;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.022) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}
#crt::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.45) 100%);
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--mono); font-size: 15px; cursor: pointer;
  color: var(--ink); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 18px;
  transition: transform .06s, border-color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--acc); box-shadow: 0 0 14px rgba(94,242,184,.25); }
.btn:active { transform: scale(.96); }
.btn.big { font-size: 18px; padding: 14px 30px; color: #06251a; background: var(--acc); border-color: var(--acc); font-weight: 700; }
.btn.big:hover { box-shadow: 0 0 26px rgba(94,242,184,.5); }
.btn.gold { color: #2a1e04; background: var(--gold); border-color: var(--gold); font-weight: 700; }
.btn.gold:hover { box-shadow: 0 0 26px rgba(255,209,102,.5); }
.btn.ghost { background: transparent; }
.btn.small { font-size: 13px; padding: 6px 12px; }
.chip {
  font-family: var(--mono); font-size: 12px; cursor: pointer;
  background: transparent; color: var(--dim);
  border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px;
}
.chip:hover { color: var(--ink); border-color: var(--acc2); }
.chip.danger:hover { color: var(--warn); border-color: var(--warn); }

/* ---------- title ---------- */
#screen-title { align-items: center; justify-content: center; }
.title-card { text-align: center; }
.logo-art { color: var(--acc); font-size: 8px; line-height: 1.15; text-shadow: 0 0 8px rgba(94,242,184,.35); }
.logo { font-size: 44px; letter-spacing: 4px; margin-top: 4px; }
.logo span { color: var(--acc); text-shadow: 0 0 18px rgba(94,242,184,.6); }
.tagline { color: var(--dim); margin: 10px 0 30px; font-size: 15px; }
.title-btns { display: flex; gap: 14px; justify-content: center; }
.title-foot {
  margin-top: 40px; display: flex; gap: 14px; align-items: center; justify-content: center;
  color: var(--dim); font-size: 12px;
}
.title-foot code { color: var(--acc2); }

/* ---------- level select ---------- */
#screen-levels { padding: 24px 4vw; overflow-y: auto; }
.levels-head { display: flex; align-items: center; gap: 20px; margin-bottom: 22px; }
.levels-head h2 { flex: 1; font-size: 22px; letter-spacing: 1px; }
.total-stars { color: var(--gold); font-size: 16px; }
#level-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px; padding-bottom: 40px;
}
.level-card {
  position: relative; cursor: pointer; border-radius: 12px; padding: 16px;
  background: linear-gradient(160deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); transition: transform .1s, border-color .15s, box-shadow .15s;
}
.level-card:hover { transform: translateY(-3px); border-color: var(--acc); box-shadow: 0 6px 24px rgba(0,0,0,.4), 0 0 14px rgba(94,242,184,.18); }
.level-card.locked { opacity: .38; cursor: not-allowed; filter: grayscale(.6); }
.level-card .num { font-size: 12px; color: var(--dim); }
.level-card .name { font-size: 17px; margin: 4px 0 2px; color: var(--ink); }
.level-card .blurb { font-size: 12px; color: var(--dim); min-height: 30px; }
.level-card .stars { margin-top: 8px; font-size: 16px; letter-spacing: 3px; color: var(--gold); }
.level-card .stars .off { color: #2c3948; }
.level-card .icon { position: absolute; top: 12px; right: 14px; font-size: 22px; }
.level-card .lock { position: absolute; top: 12px; right: 14px; font-size: 18px; }

/* ---------- game HUD ---------- */
#screen-game { padding: 10px 3vw 14px; gap: 8px; }
#hud { display: flex; align-items: center; gap: 14px; }
.hud-level { font-size: 15px; color: var(--acc); letter-spacing: 1px; white-space: nowrap; }
.hud-dots { flex: 1; display: flex; gap: 5px; flex-wrap: wrap; }
.hud-dots .dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: #22304200; border: 1px solid var(--line);
}
.hud-dots .dot.cur { border-color: var(--acc2); box-shadow: 0 0 8px rgba(122,162,255,.7); }
.hud-dots .dot.done { background: var(--acc); border-color: var(--acc); }
.hud-dots .dot.fail { background: var(--warn); border-color: var(--warn); opacity: .6; }
.hud-right { display: flex; align-items: center; gap: 16px; }
.hearts { font-size: 15px; letter-spacing: 2px; }
.hearts .off { opacity: .22; filter: grayscale(1); }
.combo { color: var(--gold); font-size: 14px; min-width: 90px; text-align: right; }
.hud-timer { color: var(--dim); font-size: 13px; min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }
.combo.hot { animation: pulse .5s infinite alternate; }
@keyframes pulse { from { text-shadow: 0 0 4px rgba(255,209,102,.4); } to { text-shadow: 0 0 16px rgba(255,209,102,.95); } }
.zen-toggle { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--dim); cursor: pointer; }

/* ---------- challenge panel ---------- */
#challenge-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
#prompt-num { font-size: 11px; color: var(--dim); letter-spacing: 1px; }
#prompt { font-size: 24px; color: var(--ink); }
#prompt .key-token {
  display: inline-block; padding: 1px 8px; margin: 0 2px; border-radius: 5px;
  background: #1b2635; border: 1px solid #2c3d54; border-bottom-width: 3px;
  color: var(--acc); font-size: 20px;
}
#tip { font-size: 12.5px; color: var(--dim); margin-top: 5px; }

/* ---------- buffer ---------- */
#buffer-wrap { position: relative; flex: 1; min-height: 120px; }
#buffer {
  height: 100%; overflow: auto; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font-size: 19px; line-height: 1.75;
  outline: none;
}
#buffer .row { display: flex; white-space: pre; }
#buffer .ln {
  width: 76px; min-width: 76px; text-align: right; padding-right: 18px;
  color: #33465c; user-select: none;
}
#buffer .ln.rel { color: var(--acc2); font-weight: 600; }
#buffer .ln.abs { color: #2c3d50; font-size: 11px; align-self: flex-end; padding-bottom: 3px; }
#buffer .ch.target {
  color: var(--target); background: rgba(255,158,100,.16);
  border-radius: 3px; animation: targetpulse 1.1s infinite;
}
@keyframes targetpulse { 0%,100% { box-shadow: 0 0 0 rgba(255,158,100,0); } 50% { box-shadow: 0 0 12px rgba(255,158,100,.8); } }
#buffer .ch.cursor {
  background: var(--acc); color: #06251a; border-radius: 2px;
  animation: blink 1.06s step-end infinite; text-shadow: none;
}
#buffer .ch.cursor.insert { animation: none; }
@keyframes blink { 50% { background: rgba(94,242,184,.35); color: var(--ink); } }
#buffer .ch.sel { background: var(--sel); color: var(--ink); }
#buffer.flash-win { animation: flashwin .7s; }
@keyframes flashwin { 0% { box-shadow: 0 0 0 rgba(94,242,184,0); } 30% { box-shadow: 0 0 40px rgba(94,242,184,.55); border-color: var(--acc); } 100% { box-shadow: 0 0 0 rgba(94,242,184,0); } }
#buffer-wrap.shake #buffer { animation: shake .3s; border-color: var(--warn); }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }

#mode-badge {
  position: absolute; top: -1px; right: 14px; z-index: 2;
  font-size: 11px; letter-spacing: 2px; padding: 3px 12px;
  border-radius: 0 0 8px 8px; background: var(--acc); color: #06251a; font-weight: 700;
}
#mode-badge[data-mode="insert"] { background: var(--gold); }
#mode-badge[data-mode="visual"] { background: var(--acc2); color: #0a1428; }
#mode-badge[data-mode="cmdline"] { background: #c792ea; color: #241030; }

#msg-line { min-height: 20px; font-size: 13px; color: var(--dim); }
#msg-line.err { color: var(--warn); }
#msg-line.good { color: var(--acc); }

/* ---------- keyboard ---------- */
#keyboard { display: flex; flex-direction: column; gap: 5px; align-items: center; padding: 4px 0; }
.krow { display: flex; gap: 5px; }
.key {
  min-width: 34px; height: 40px; border-radius: 6px; cursor: pointer;
  background: linear-gradient(180deg, #1b2634, #141c28);
  border: 1px solid #26354a; border-bottom-width: 3px;
  color: var(--ink); font-family: var(--mono); font-size: 13px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  user-select: none; transition: transform .05s, background .12s, box-shadow .12s;
}
.key .shift-glyph { font-size: 10px; color: var(--dim); line-height: 1; }
.key.wide { min-width: 56px; font-size: 11px; }
.key.hint {
  background: linear-gradient(180deg, #1d4a3a, #123527);
  border-color: var(--acc); box-shadow: 0 0 12px rgba(94,242,184,.55);
  animation: keypulse 1s infinite alternate;
}
@keyframes keypulse { from { box-shadow: 0 0 6px rgba(94,242,184,.3); } to { box-shadow: 0 0 16px rgba(94,242,184,.8); } }
.key.latched { background: linear-gradient(180deg, #4a3a1d, #352712); border-color: var(--gold); }
.key.mod-active { background: linear-gradient(180deg, #2a2a4d, #1c1c35); border-color: var(--acc2); box-shadow: 0 0 10px rgba(122,162,255,.5); }
.key:active { transform: translateY(2px); border-bottom-width: 1px; }
#keyboard.hintsoff .key.hint { background: linear-gradient(180deg, #1b2634, #141c28); border-color: #26354a; box-shadow: none; animation: none; }

#game-btns { display: flex; gap: 10px; justify-content: center; }

/* ---------- toast / overlay ---------- */
#toast-layer { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 9px 22px; border-radius: 99px; font-size: 15px;
  background: var(--panel2); border: 1px solid var(--acc); color: var(--acc);
  box-shadow: 0 4px 30px rgba(0,0,0,.5), 0 0 18px rgba(94,242,184,.3);
  animation: toastin .25s, toastout .3s 1.15s forwards;
}
.toast.bad { border-color: var(--warn); color: var(--warn); box-shadow: 0 4px 30px rgba(0,0,0,.5), 0 0 18px rgba(255,107,129,.3); }
.toast.gold { border-color: var(--gold); color: var(--gold); }
@keyframes toastin { from { opacity: 0; transform: translateY(-14px); } }
@keyframes toastout { to { opacity: 0; transform: translateY(-10px); } }

#overlay {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(5,8,12,.8); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.overlay-card {
  text-align: center; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 40px 60px; animation: toastin .3s;
}
.ov-stars { font-size: 44px; letter-spacing: 10px; color: var(--gold); margin-bottom: 12px; }
.ov-stars .off { color: #2c3948; }
#ov-title { font-size: 26px; margin-bottom: 6px; }
#ov-sub { color: var(--dim); margin-bottom: 26px; }
.overlay-btns { display: flex; gap: 14px; justify-content: center; }

/* confetti */
.confetti {
  position: fixed; z-index: 190; width: 9px; height: 9px; border-radius: 2px;
  animation: fall linear forwards; pointer-events: none;
}
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .1; } }

@media (max-height: 800px) {
  #buffer { font-size: 16px; line-height: 1.6; }
  .key { height: 34px; min-width: 30px; font-size: 12px; }
}

/* respect reduced-motion: keep feedback, drop the razzle-dazzle */
@media (prefers-reduced-motion: reduce) {
  #crt, .key.hint, .combo.hot { animation: none; }
  .confetti { display: none; }
  #buffer-wrap.shake #buffer { animation: none; border-color: var(--warn); }
  #buffer .ch.target { animation: none; }
  .toast { animation: toastin .25s; }
  .btn, .key, .level-card { transition: none; }
}
