@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Inter:wght@400;500;600;700&display=swap');

:root[data-theme="dark"]{
  --bg:#1a1a1a;
  --sub:#5a5a5a;
  --sub-alt:#252525;
  --text:#e8e8e8;
  --main:#e63946;
  --error:#ca4754;
  --error-extra:#7e2a33;
  --line:#2a2a2a;
}
:root[data-theme="light"]{
  --bg:#f5f5f5;
  --sub:#a0a0a0;
  --sub-alt:#e8e8e8;
  --text:#1a1a1a;
  --main:#d62828;
  --error:#b22234;
  --error-extra:#6b1018;
  --line:#dcdcdc;
}
:root[data-theme="blood"]{
  --bg:#0d0000;
  --sub:#5a2828;
  --sub-alt:#1a0808;
  --text:#f0d0d0;
  --main:#ff2d3a;
  --error:#ff6b6b;
  --error-extra:#8a0010;
  --line:#2a1010;
}
:root[data-theme="matrix"]{
  --bg:#000000;
  --sub:#1a4a1a;
  --sub-alt:#0a1a0a;
  --text:#a0ffa0;
  --main:#00ff41;
  --error:#ff5555;
  --error-extra:#7a0000;
  --line:#0f1f0f;
}
:root[data-theme="paper"]{
  --bg:#fafafa;
  --sub:#aaaaaa;
  --sub-alt:#eeeeee;
  --text:#000000;
  --main:#000000;
  --error:#cc0000;
  --error-extra:#770000;
  --line:#dddddd;
}
:root[data-theme="serika"]{
  --bg:#323437;
  --sub:#646669;
  --sub-alt:#2c2e31;
  --text:#d1d0c5;
  --main:#e2b714;
  --error:#ca4754;
  --error-extra:#7e2a33;
  --line:#3a3c3f;
}

*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html,body{
  background:var(--bg);color:var(--sub);
  font-family:'JetBrains Mono', ui-monospace, Menlo, monospace;
  -webkit-font-smoothing:antialiased;min-height:100%;
  transition:background-color .25s ease, color .25s ease;
}
body{display:flex;flex-direction:column;min-height:100vh}
a{color:inherit;text-decoration:none;transition:color .15s}
a:hover{color:var(--text)}
button{font:inherit;color:inherit;cursor:pointer;background:transparent;border:0;transition:color .15s, background .15s, transform .12s;-webkit-tap-highlight-color:transparent;user-select:none;-webkit-user-select:none;outline:none}
button:active{transform:scale(.97)}
button:focus{outline:none}
button:focus-visible{outline:2px solid var(--main);outline-offset:2px;border-radius:6px}
.settings-row, .theme-card, .pill, .toggle{user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}
input{-webkit-tap-highlight-color:transparent}

.top{
  display:flex;align-items:center;justify-content:space-between;
  padding:18px 24px;max-width:1400px;width:100%;margin:0 auto;
}
.brand{display:flex;align-items:center;gap:8px;color:var(--text);font-weight:700;transition:opacity .15s}
.brand:hover{opacity:.85}
.brand-mark{font-size:32px;line-height:1;color:var(--main);font-weight:400}
.brand-name{font-size:18px;letter-spacing:.5px}
.topnav{display:flex;align-items:center;gap:6px}
.nav-btn, .theme-toggle{
  width:36px;height:36px;display:grid;place-items:center;border-radius:8px;
  color:var(--sub);transition:color .15s, background .15s, transform .12s;
}
.nav-btn:hover, .theme-toggle:hover{color:var(--text);background:var(--sub-alt)}
.nav-btn.active{color:var(--main)}
.nav-btn svg, .theme-toggle svg{width:18px;height:18px;transition:transform .25s ease}
.nav-btn:hover svg, .theme-toggle:hover svg{transform:scale(1.1)}

main{flex:1;display:flex;flex-direction:column;max-width:1400px;width:100%;margin:0 auto;padding:0 24px;animation:fadeIn .3s ease both}
@keyframes fadeIn{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:translateY(0)}}

.foot{
  display:flex;justify-content:space-between;align-items:center;
  padding:18px 24px;max-width:1400px;width:100%;margin:0 auto;color:var(--sub);font-size:12px;
}
.foot .left{display:flex;gap:18px}
.foot .right{font-feature-settings:'tnum'}

.config-bar{
  display:flex;align-items:center;justify-content:center;gap:6px;
  background:var(--sub-alt);padding:10px 14px;border-radius:10px;
  font-size:13px;color:var(--sub);
  margin:32px auto 0;width:fit-content;flex-wrap:wrap;max-width:100%;
  animation:slideDown .3s ease both;
}
@keyframes slideDown{from{opacity:0;transform:translateY(-6px)}to{opacity:1;transform:translateY(0)}}
.config-group{display:flex;align-items:center;gap:4px}
.config-bar .sep{width:1px;height:18px;background:var(--bg);margin:0 6px}
.config-bar button{
  padding:4px 10px;border-radius:6px;color:var(--sub);
  font-size:13px;display:flex;align-items:center;gap:6px;
}
.config-bar button:hover{color:var(--text)}
.config-bar button.on{color:var(--main)}
.config-bar svg{width:14px;height:14px}

.live-stats{
  display:flex;justify-content:center;align-items:baseline;gap:16px;
  margin:60px 0 14px;font-size:32px;color:var(--main);font-weight:600;
  min-height:48px;font-feature-settings:'tnum';
}
.live-stats .small{color:var(--sub);font-size:18px}

.test-area{
  position:relative;font-size:30px;line-height:1.6;
  font-family:'JetBrains Mono', ui-monospace, monospace;
  letter-spacing:.5px;color:var(--sub);
  max-width:1100px;width:100%;margin:0 auto;
  padding:6px 4px;outline:none;
  user-select:none;-webkit-user-select:none;
  height:calc(1.6em * 3);overflow:hidden;
}
.test-area:focus{outline:none}
.test-area .blur-overlay{
  position:absolute;inset:0;display:none;align-items:center;justify-content:center;
  backdrop-filter:blur(4px);background:transparent;cursor:pointer;
  font-size:14px;color:var(--text);z-index:5;font-family:'Inter',sans-serif;
}
.test-area.unfocused .blur-overlay{display:flex}
.test-area.unfocused .words{filter:blur(4px);opacity:.85}

.words{display:flex;flex-wrap:wrap;gap:0 12px;line-height:1.6;transition:transform .25s ease}
.word{display:inline-flex;border-bottom:2px solid transparent;transition:border-color .2s}
.word.has-error{border-bottom-color:var(--error)}
.letter{position:relative;color:var(--sub);transition:color .08s, transform .12s}
.letter.correct{color:var(--text)}
.letter.incorrect{color:var(--error);animation:shake .2s ease}
@keyframes shake{0%,100%{transform:translateX(0)}25%{transform:translateX(-2px)}75%{transform:translateX(2px)}}
.letter.extra{color:var(--error-extra)}

.cursor{
  position:absolute;width:2px;height:1.4em;background:var(--main);
  margin-top:-2px;transition:left .1s cubic-bezier(.4,0,.2,1), top .1s ease;
  animation:blink 1s steps(2) infinite;border-radius:1px;
  box-shadow:0 0 8px var(--main);
}
@keyframes blink{50%{opacity:0}}

.test-actions{display:flex;justify-content:center;gap:18px;margin-top:30px;color:var(--sub);font-size:13px}
.test-actions button{padding:6px 12px;border-radius:8px;color:var(--sub);display:flex;align-items:center;gap:8px}
.test-actions button:hover{color:var(--text);background:var(--sub-alt)}
.test-actions svg{width:14px;height:14px}
.test-actions kbd{display:inline-block;padding:2px 6px;font-size:11px;border-radius:4px;background:var(--sub-alt);color:var(--sub);margin-left:2px}

/* Result */
.result-wrap{animation:fadeUp .4s cubic-bezier(.22,1,.36,1) both;margin-top:40px}
@keyframes fadeUp{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}

.result{display:grid;grid-template-columns:auto 1fr;gap:32px;align-items:center}
.result-stats{display:flex;flex-direction:column;gap:16px}
.result-stats .big{font-size:80px;color:var(--main);line-height:1;font-weight:700;font-feature-settings:'tnum';animation:countUp .5s ease both}
@keyframes countUp{from{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}
.result-stats .label{color:var(--sub);font-size:16px;text-transform:lowercase;letter-spacing:.5px}
.result-stats .row{display:flex;flex-direction:column;gap:0}
.result-meta{display:grid;grid-template-columns:repeat(3, 1fr);gap:16px 24px;color:var(--sub);font-size:14px;margin-top:18px}
.result-meta .v{color:var(--text);font-size:18px;font-feature-settings:'tnum'}
.result-meta .l{color:var(--sub);font-size:12px;text-transform:lowercase}

.result-charts{display:grid;grid-template-columns:2fr 1fr;gap:18px;margin-top:24px}
.chart-card{background:var(--sub-alt);border-radius:12px;padding:14px;animation:fadeUp .5s cubic-bezier(.22,1,.36,1) both}
.chart-card h4{color:var(--sub);font-size:11px;text-transform:uppercase;letter-spacing:.5px;margin-bottom:10px;font-family:'Inter',sans-serif;font-weight:600}
.chart-card svg{width:100%;height:auto;display:block}

.fun-stats{display:flex;flex-direction:column;gap:4px;margin-top:18px;font-family:'Inter',sans-serif;font-size:13px;color:var(--sub);text-align:center}
.fun-stat{padding:4px 8px;animation:fadeUp .5s cubic-bezier(.22,1,.36,1) both;line-height:1.5}
.fun-stat:nth-child(1){animation-delay:.05s}
.fun-stat:nth-child(2){animation-delay:.1s}
.fun-stat:nth-child(3){animation-delay:.15s}
.fun-stat:nth-child(4){animation-delay:.2s}
.fun-stat strong{color:var(--text);font-weight:600}

.result-actions{display:flex;justify-content:center;gap:14px;margin-top:30px}
.result-actions .btn{
  width:48px;height:48px;display:grid;place-items:center;border-radius:50%;
  background:var(--sub-alt);color:var(--sub);
  transition:color .15s, background .15s, transform .15s;
}
.result-actions .btn:hover{color:var(--main);background:var(--bg);transform:scale(1.08)}
.result-actions svg{width:20px;height:20px}

/* Confetti */
.confetti-piece{
  position:fixed;width:8px;height:14px;top:-20px;
  pointer-events:none;z-index:200;
  animation:confettiFall 2.5s cubic-bezier(.4,.4,.6,1) forwards;
}
@keyframes confettiFall{
  to{transform:translate3d(var(--dx,0), 110vh, 0) rotate(var(--rot,720deg));opacity:0}
}

/* User pill */
.user-pill{display:inline-flex;align-items:center;gap:6px;padding:4px;border-radius:99px;background:var(--sub-alt);cursor:pointer;color:var(--sub);transition:background .15s, color .15s, transform .12s}
.user-pill:hover{color:var(--text);transform:translateY(-1px)}
.user-pill .avatar{width:28px;height:28px;border-radius:50%;display:grid;place-items:center;background:var(--main);color:var(--bg);font-weight:700;font-size:12px;font-family:'Inter',sans-serif;overflow:hidden}
.user-pill .avatar.img{padding:0;object-fit:cover;display:block}

/* Modal */
.modal-wrap{position:fixed;inset:0;background:rgba(0,0,0,.65);backdrop-filter:blur(8px);display:grid;place-items:center;z-index:60;padding:20px;animation:fade .15s ease}
:root[data-theme="light"] .modal-wrap, :root[data-theme="paper"] .modal-wrap{background:rgba(0,0,0,.4)}
@keyframes fade{from{opacity:0}to{opacity:1}}
.modal{
  width:100%;max-width:420px;background:var(--bg);border:1px solid var(--line);
  border-radius:14px;padding:24px;position:relative;font-family:'Inter',sans-serif;
  animation:up .25s cubic-bezier(.22,1,.36,1) both;
}
@keyframes up{from{transform:translateY(8px) scale(.98);opacity:0}to{transform:translateY(0) scale(1);opacity:1}}
.modal h2{color:var(--text);font-size:22px;margin-bottom:8px;letter-spacing:-.3px}
.modal p{color:var(--sub);font-size:14px;margin-bottom:14px}
.modal-close{position:absolute;top:14px;right:14px;width:30px;height:30px;border-radius:8px;background:var(--sub-alt);color:var(--sub);display:grid;place-items:center}
.modal-close:hover{color:var(--text)}
.modal-close svg{width:14px;height:14px}
.modal-tabs{display:flex;gap:4px;margin-bottom:16px;background:var(--sub-alt);padding:4px;border-radius:10px}
.modal-tabs .tab{flex:1;padding:8px;border-radius:7px;color:var(--sub);font-weight:600;font-size:13px}
.modal-tabs .tab.active{background:var(--bg);color:var(--text)}
.auth-form{display:flex;flex-direction:column;gap:10px}
.auth-form label{display:flex;flex-direction:column;gap:5px;font-size:13px;color:var(--sub)}
.auth-form input{
  background:var(--sub-alt);border:1px solid transparent;color:var(--text);
  padding:11px 12px;border-radius:8px;font:inherit;outline:none;transition:border-color .15s;
  font-family:'Inter',sans-serif;font-size:14px;
}
.auth-form input:focus{border-color:var(--main)}
.btn-primary{
  background:var(--main);color:var(--bg);font-weight:700;
  padding:11px;border-radius:8px;font-size:14px;font-family:'Inter',sans-serif;
}
.btn-primary:hover{filter:brightness(1.1)}
.btn-ghost{
  background:var(--sub-alt);color:var(--text);font-weight:600;
  padding:11px;border-radius:8px;font-size:14px;font-family:'Inter',sans-serif;
}
.btn-ghost:hover{background:var(--line)}
.divider{display:flex;align-items:center;gap:10px;color:var(--sub);font-size:12px;margin:14px 0;font-family:'Inter',sans-serif}
.divider::before,.divider::after{content:'';flex:1;height:1px;background:var(--line)}
.oauth-row{display:flex;flex-direction:column;gap:8px;align-items:stretch}
.oauth-btn{
  display:flex;align-items:center;justify-content:center;gap:10px;width:100%;
  padding:11px;border-radius:8px;color:var(--text);background:var(--sub-alt);
  font-family:'Inter',sans-serif;font-weight:600;font-size:14px;
}
.oauth-btn:hover{background:var(--line)}
.oauth-btn svg{width:18px;height:18px}
.form-error{color:var(--error);font-size:13px;min-height:16px;font-family:'Inter',sans-serif}

/* User menu */
.user-menu{
  position:fixed;z-index:70;width:280px;
  background:var(--bg);border:1px solid var(--line);border-radius:12px;
  padding:8px;box-shadow:0 20px 50px rgba(0,0,0,.5);
  animation:up .18s cubic-bezier(.22,1,.36,1) both;font-family:'Inter',sans-serif;
}
.um-head{display:flex;gap:10px;align-items:center;padding:8px 8px 12px;border-bottom:1px solid var(--line)}
.um-head .avatar{width:36px;height:36px;border-radius:50%;display:grid;place-items:center;background:var(--main);color:var(--bg);font-weight:800;font-size:14px;overflow:hidden}
.um-head .avatar.img{padding:0;object-fit:cover;display:block}
.um-nick{color:var(--text);font-weight:700;font-size:14px}
.um-sub{color:var(--sub);font-size:12px}
.um-divider{height:1px;background:var(--line);margin:6px 0}
.um-link{display:block;padding:8px 10px;border-radius:8px;color:var(--text);font-size:14px;font-weight:500}
.um-link:hover{background:var(--sub-alt)}
.um-btn{
  width:100%;text-align:left;padding:8px 10px;border-radius:8px;color:var(--text);font-size:14px;
  font-family:inherit;font-weight:500;
}
.um-btn:hover{background:var(--sub-alt)}
.um-btn.danger{color:var(--sub)}
.um-btn.danger:hover{color:var(--error);background:var(--sub-alt)}

/* Generic empty */
.empty{text-align:center;padding:60px 20px;color:var(--sub);font-family:'Inter',sans-serif;display:flex;flex-direction:column;align-items:center;gap:10px}
.empty h2{color:var(--text);font-size:24px;margin:6px 0 0;font-weight:700;letter-spacing:-.3px}
.empty p{font-size:14px;margin:0}
.state-gif{
  width:140px;height:auto;object-fit:contain;
  filter:grayscale(1) contrast(1.05);mix-blend-mode:screen;
}
:root[data-theme="light"] .state-gif, :root[data-theme="paper"] .state-gif{mix-blend-mode:multiply}
.state-gif.small{width:96px}

/* Leaderboard */
.lb-table{width:100%;max-width:760px;margin:30px auto;border-collapse:collapse;font-family:'JetBrains Mono', monospace;font-size:14px}
.lb-table th{text-align:left;padding:12px 14px;color:var(--sub);font-weight:500;border-bottom:1px solid var(--line);font-size:12px;text-transform:uppercase;letter-spacing:.5px}
.lb-table td{padding:12px 14px;color:var(--text);border-bottom:1px solid var(--sub-alt)}
.lb-table tr:hover td{background:var(--sub-alt)}
.lb-table .wpm{color:var(--main);font-weight:700}
.lb-table .rank{color:var(--sub);width:40px}

/* Settings */
.settings{max-width:760px;margin:30px auto;font-family:'Inter',sans-serif}
.settings-group{background:var(--sub-alt);border-radius:12px;padding:18px 20px;margin-bottom:14px;animation:fadeUp .35s ease both}
.settings-group h3{color:var(--text);font-size:13px;margin-bottom:12px;text-transform:uppercase;letter-spacing:.5px;font-weight:700}
.settings-row{display:flex;justify-content:space-between;align-items:center;padding:10px 0;color:var(--sub);font-size:14px;gap:16px;border-bottom:1px solid var(--line)}
.settings-row:last-child{border-bottom:0}
.settings-row .v{color:var(--text)}
.settings-row .desc{color:var(--sub);font-size:12px;margin-top:2px}
.settings-row .left{flex:1}
.settings-row .right{display:flex;gap:6px;flex-wrap:wrap}
.settings-row .pill{
  padding:6px 12px;border-radius:8px;background:var(--bg);color:var(--sub);font-size:13px;
  cursor:pointer;
}
.settings-row .pill:hover{color:var(--text)}
.settings-row .pill.on{background:var(--main);color:var(--bg);font-weight:600}
.theme-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:8px}
.theme-card{
  background:var(--bg);border:2px solid var(--line);border-radius:8px;padding:10px;cursor:pointer;
  display:flex;flex-direction:column;gap:6px;
}
.theme-card.active{border-color:var(--main)}
.theme-card .swatch{height:30px;border-radius:5px;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:11px;letter-spacing:.5px}
.theme-card .name{font-size:11px;color:var(--text);text-align:center}

.toggle{
  display:inline-flex;align-items:center;gap:8px;cursor:pointer;
  padding:6px 10px;border-radius:8px;background:var(--bg);
}
.toggle .knob{
  width:32px;height:18px;background:var(--line);border-radius:99px;position:relative;
  transition:background .2s;
}
.toggle .knob::after{
  content:'';position:absolute;top:2px;left:2px;width:14px;height:14px;border-radius:50%;
  background:var(--sub);transition:transform .2s, background .2s;
}
.toggle.on .knob{background:var(--main)}
.toggle.on .knob::after{transform:translateX(14px);background:var(--bg)}

/* Legal */
.legal{max-width:720px;margin:30px auto;font-family:'Inter',sans-serif;color:var(--text);line-height:1.6}
.legal h1{font-size:26px;margin-bottom:10px}
.legal h2{font-size:17px;margin:22px 0 6px}
.legal p, .legal ul{color:var(--sub);font-size:14px;margin-bottom:8px}
.legal ul{padding-left:20px}

/* Toast */
.toast{
  position:fixed;bottom:30px;left:50%;transform:translateX(-50%);
  background:var(--sub-alt);color:var(--text);padding:12px 20px;border-radius:10px;
  font-family:'Inter',sans-serif;font-size:14px;z-index:100;
  box-shadow:0 10px 30px rgba(0,0,0,.3);
  animation:toastIn .25s ease both;
  border:1px solid var(--line);
}
@keyframes toastIn{from{opacity:0;transform:translate(-50%,8px)}to{opacity:1;transform:translate(-50%,0)}}
.toast.out{animation:toastOut .2s ease both}
@keyframes toastOut{to{opacity:0;transform:translate(-50%,-8px)}}

/* Responsive */
@media (max-width:700px){
  .top{padding:14px 16px}
  main{padding:0 16px}
  .foot{padding:14px 16px;flex-direction:column;gap:10px}
  .test-area{font-size:20px;height:calc(1.6em * 3);letter-spacing:0}
  .live-stats{font-size:24px;margin:24px 0 8px}
  .result{grid-template-columns:1fr;gap:16px}
  .result-stats .big{font-size:54px}
  .result-meta{grid-template-columns:repeat(2,1fr);gap:12px 16px;font-size:13px}
  .result-charts{grid-template-columns:1fr;gap:12px}
  .config-bar{font-size:12px;gap:4px;padding:8px 10px;border-radius:8px}
  .config-bar button{padding:4px 8px;font-size:12px}
  .config-bar .sep{margin:0 3px;height:14px}
  .brand-name{display:none}
  .fun-stat{font-size:13px;padding:10px 12px}
  .theme-grid{grid-template-columns:repeat(2,1fr)}
  .modal{padding:18px;border-radius:12px}
  .modal h2{font-size:20px}
  .nav-btn, .theme-toggle{width:32px;height:32px}
  .lb-table th, .lb-table td{padding:8px 10px;font-size:12px}
  .settings-row{flex-direction:column;align-items:flex-start;gap:8px}
  .settings-row .right{width:100%}
}

.hp{position:absolute !important;left:-9999px !important;width:0 !important;height:0 !important;opacity:0 !important}
