/* ============================================
   PROGRAMMER TYPING TEST — Stylesheet v3
   Bigger editor + grid stats + history
   ============================================ */

.ct-game {
    background: #0b1322;
    padding: 28px 20px 56px;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #cbd5e1;
}

.ct-inner { max-width: 1080px; margin: 0 auto; }

/* --- Header --- */
.ct-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.ct-title {
    color: #f8fafc;
    font-size: 30px;
    font-weight: 800;
    margin: 0 0 4px;
    letter-spacing: -0.6px;
}
.ct-sub { color: #8fa3bd; font-size: 14.5px; margin: 0; }

.ct-best-badge {
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.35);
    color: #fbbf24;
    padding: 9px 18px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
}

/* --- Stats: GRID = perfect alignment --- */
.ct-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.ct-stat {
    background: #111a2c;
    border: 1px solid #1e2a44;
    border-radius: 10px;
    padding: 12px 16px;
}
.ct-stat-l {
    display: block;
    font-size: 10.5px;
    color: #5c7089;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 3px;
}
.ct-stat-v {
    display: block;
    font-size: 25px;
    font-weight: 800;
    color: #38bdf8;
    font-variant-numeric: tabular-nums;   /* numbers jitter nahi karenge */
    line-height: 1.1;
}
.ct-stat-time .ct-stat-v { color: #fbbf24; }

/* --- Config --- */
.ct-config {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}
.ct-config-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}
.ct-config-label {
    width: 86px;              /* fixed width = dono rows ki chips align */
    flex-shrink: 0;
    color: #5c7089;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}
.ct-chip {
    background: #111a2c;
    border: 1px solid #1e2a44;
    color: #8fa3bd;
    border-radius: 7px;
    padding: 7px 15px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.ct-chip:hover { border-color: #38bdf8; color: #e2e8f0; }
.ct-chip.active {
    background: rgba(56, 189, 248, 0.12);
    border-color: #38bdf8;
    color: #38bdf8;
}

/* --- Holder --- */
.ct-holder { position: relative; }

/* --- Overlays --- */
.ct-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    background: rgba(7, 11, 21, 0.93);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}
.ct-overlay.hidden { display: none; }

.ct-card {
    background: #111a2c;
    border: 1px solid #1e2a44;
    border-radius: 14px;
    padding: 32px 40px;
    text-align: center;
    width: 92%;
    max-width: 560px;
    max-height: 94%;
    overflow-y: auto;
}
.ct-card-title {
    color: #f8fafc;
    font-size: 25px;
    margin: 0 0 16px;
    font-weight: 800;
}
.ct-card-title.ct-over { color: #38bdf8; }

.ct-inst { text-align: left; margin: 0 auto 18px; max-width: 420px; }
.ct-inst ul { list-style: none; padding: 0; margin: 0; }
.ct-inst li {
    color: #b8c7dc;
    font-size: 13.5px;
    padding: 5px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.45;
}
.ct-b {
    width: 21px; height: 21px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: bold; flex-shrink: 0;
}
.ct-b-g { background: rgba(34,197,94,0.15); color: #22c55e; }
.ct-b-r { background: rgba(239,68,68,0.15); color: #ef4444; }
.ct-b-y { background: rgba(249,115,22,0.15); color: #f97316; }
.ct-b-b { background: rgba(56,189,248,0.15); color: #38bdf8; }

.ct-preview {
    background: #1e1e1e;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 20px;
    text-align: left;
}
.ct-preview-l {
    display: block;
    font-size: 10px;
    color: #5c7089;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 8px;
}
.ct-preview-code {
    margin: 0;
    font-family: 'Cascadia Code', Consolas, 'Courier New', monospace;
    font-size: 13.5px;
    line-height: 1.65;
    color: #d4d4d4;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 150px;
    overflow: hidden;
}

/* --- Buttons --- */
.ct-btn {
    border: none;
    border-radius: 9px;
    font-weight: 700;
    font-size: 14.5px;
    cursor: pointer;
    padding: 13px 32px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    display: inline-block;
    font-family: inherit;
}
.ct-btn-p {
    background: #22c55e;
    color: #052e16;
}
.ct-btn-p:hover { background: #16a34a; transform: translateY(-1px); }
.ct-btn-s {
    background: rgba(56, 189, 248, 0.1);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.35);
    padding: 12px 20px;
}
.ct-btn-s:hover { background: rgba(56, 189, 248, 0.18); }
.ct-btn-s:disabled { opacity: 0.55; cursor: default; transform: none; }

/* --- Countdown --- */
.ct-overlay-count { background: rgba(7, 11, 21, 0.82); flex-direction: column; gap: 12px; }
.ct-count {
    font-size: 104px;
    font-weight: 900;
    color: #f8fafc;
    line-height: 1;
    animation: ct-pop 0.8s ease;
}
.ct-count-sub { color: #8fa3bd; font-size: 14px; }
@keyframes ct-pop {
    0% { transform: scale(0.5); opacity: 0; }
    40% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* --- Results (bigger) --- */
.ct-card-end { padding: 36px 44px; }
.ct-meta {
    color: #5c7089;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin: -8px 0 18px;
}
.ct-results {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}
.ct-res {
    background: #0d1524;
    border: 1px solid #1e2a44;
    border-radius: 10px;
    padding: 16px 10px;
    text-align: center;
}
.ct-res-main { border-color: rgba(56, 189, 248, 0.4); }
.ct-res-v { font-size: 30px; font-weight: 800; color: #e2e8f0; font-variant-numeric: tabular-nums; line-height: 1.15; }
.ct-res-main .ct-res-v { font-size: 38px; color: #22c55e; }
.ct-res-l { font-size: 10px; color: #5c7089; text-transform: uppercase; letter-spacing: 1.2px; margin-top: 5px; }

.ct-best { color: #fbbf24; font-size: 13.5px; font-weight: 600; margin-bottom: 16px; }
.ct-save { display: flex; gap: 8px; justify-content: center; margin-bottom: 16px; }
.ct-input {
    background: #0d1524;
    border: 1px solid #1e2a44;
    border-radius: 8px;
    color: #f8fafc;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    width: 180px;
    font-family: inherit;
}
.ct-input:focus { border-color: #38bdf8; }
.ct-hint { margin-top: 12px; color: #46587a; font-size: 11.5px; }

/* --- Leaderboard --- */
.ct-lb { margin-top: 20px; padding-top: 16px; border-top: 1px solid #1e2a44; }
.ct-lb h3 {
    color: #5c7089;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    margin: 0 0 10px;
}
.ct-lb-list { text-align: left; }
.ct-lb-empty { color: #46587a; font-size: 12px; text-align: center; }
.ct-lb-row {
    display: flex;
    align-items: center;
    padding: 6px 0;
    color: #b8c7dc;
    font-size: 13px;
    border-bottom: 1px solid #16203a;
}
.ct-lb-row:last-child { border-bottom: none; }
.ct-lb-rank { color: #5c7089; width: 32px; }
.ct-lb-name { flex: 1; padding-left: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-lb-lang {
    background: rgba(56, 189, 248, 0.1);
    color: #38bdf8;
    font-size: 10px;
    padding: 2px 9px;
    border-radius: 99px;
    text-transform: capitalize;
    margin-right: 10px;
}
.ct-lb-wpm { color: #22c55e; width: 70px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============================================
   EDITOR — BADA
   ============================================ */
.ct-editor {
    background: #1e1e1e;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #2d2d2d;
    box-shadow: 0 14px 44px rgba(0, 0, 0, 0.4);
}
.ct-editor.flash-good { animation: ct-flash 0.4s ease; }
@keyframes ct-flash {
    0%, 100% { box-shadow: 0 14px 44px rgba(0,0,0,0.4); }
    50% { box-shadow: 0 0 0 3px rgba(34,197,94,0.55), 0 14px 44px rgba(0,0,0,0.4); }
}

.ct-ed-titlebar {
    display: flex;
    align-items: center;
    gap: 7px;
    background: #252526;
    padding: 11px 16px;
    border-bottom: 1px solid #1d1d1d;
}
.ct-dot { width: 12px; height: 12px; border-radius: 50%; }
.ct-dot-r { background: #ff5f56; } .ct-dot-y { background: #ffbd2e; } .ct-dot-g { background: #27c93f; }
.ct-filename { color: #9d9d9d; font-size: 12.5px; margin-left: 10px; font-family: Consolas, monospace; }

.ct-ed-body { display: flex; }

.ct-gutter {
    padding: 20px 10px 20px 18px;
    text-align: right;
    color: #4b5263;
    user-select: none;
    background: #1e1e1e;
    min-width: 52px;
    border-right: 1px solid #252526;
    font-family: 'Cascadia Code', Consolas, 'Courier New', monospace;
    font-size: 19px;
    line-height: 1.8;
}
.ct-gutter .gn { display: block; }
.ct-gutter .gn.active { color: #38bdf8; }

.ct-code-scroll {
    flex: 1;
    overflow-y: auto;
    height: 480px;                /* pehle 350 max tha — ab bada fixed */
    padding: 20px 22px 100px 16px;
    scroll-behavior: smooth;
}
.ct-code {
    font-family: 'Cascadia Code', Consolas, 'Courier New', monospace;
    font-size: 20px;              /* pehle 17.5 */
    line-height: 1.8;
    white-space: pre;
}

.ct-line { min-height: 1.8em; padding: 0 6px; border-radius: 4px; }
.ct-line.active { background: rgba(56, 189, 248, 0.06); }

.ct-char { border-radius: 2px; opacity: 0.4; }
.ct-char.typed { opacity: 1; }
.ct-char.wrong { background: #ef4444; color: #fff !important; opacity: 1; }
.ct-char.current {
    background: rgba(56, 189, 248, 0.35);
    opacity: 1;
    animation: ct-caret 1s step-end infinite;
}
@keyframes ct-caret { 50% { background: rgba(56, 189, 248, 0.08); } }
.ct-char.nl { color: #3f4854; opacity: 1; font-size: 0.72em; }
.ct-char.nl.typed { opacity: 0.25; }
.ct-char.nl.current { opacity: 1; color: #38bdf8; }

/* Syntax tokens */
.tok-kw   { color: #569cd6; }
.tok-str  { color: #ce9178; }
.tok-num  { color: #b5cea8; }
.tok-com  { color: #6a9955; }
.tok-id   { color: #9cdcfe; }
.tok-tag  { color: #4ec9b0; }
.tok-attr { color: #9cdcfe; }
.tok-prop { color: #9cdcfe; }
.tok-sel  { color: #dcdcaa; }
.tok-pun  { color: #d4d4d4; }

.ct-ed-status {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #007acc;
    color: #fff;
    font-size: 11.5px;
    padding: 6px 16px;
    font-family: Consolas, monospace;
}
.ct-ed-sep { width: 1px; height: 12px; background: rgba(255,255,255,0.35); }
.ct-ed-right { margin-left: auto; opacity: 0.9; }

.ct-snippet-prog { height: 4px; background: #252526; }
.ct-snippet-prog-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #22c55e, #38bdf8);
    transition: width 0.1s ease;
}

/* ============================================
   HISTORY
   ============================================ */
.ct-history {
    margin-top: 22px;
    background: #111a2c;
    border: 1px solid #1e2a44;
    border-radius: 12px;
    padding: 20px 22px;
}
.ct-h-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    flex-wrap: wrap;
    gap: 10px;
}
.ct-h-title { font-size: 17px; font-weight: 700; color: #e2e8f0; margin: 0; }
.ct-h-clear {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #f87171;
    border-radius: 7px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease;
}
.ct-h-clear:hover { background: rgba(239, 68, 68, 0.1); }

.ct-h-note { color: #5c7089; font-size: 11.5px; margin: 0 0 14px; }

.ct-h-scroll { overflow-x: auto; }
.ct-h-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ct-h-table th {
    text-align: left;
    color: #5c7089;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    padding: 9px 12px;
    border-bottom: 1px solid #1e2a44;
    white-space: nowrap;
    font-weight: 600;
}
.ct-h-table th.ta-r, .ct-h-table td.ta-r { text-align: right; }
.ct-h-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #16203a;
    color: #b8c7dc;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.ct-h-table tr:last-child td { border-bottom: none; }
.ct-h-table tr.ct-h-bestrow td { background: rgba(34, 197, 94, 0.06); }
.ct-h-table tr.ct-h-bestrow td:first-child { box-shadow: inset 3px 0 0 #22c55e; }
.ct-h-table .ct-h-wpm-best { color: #22c55e; font-weight: 800; }
.ct-h-lang {
    background: rgba(56, 189, 248, 0.1);
    color: #38bdf8;
    font-size: 10.5px;
    padding: 2px 9px;
    border-radius: 99px;
    text-transform: capitalize;
}
.ct-h-empty {
    color: #46587a;
    font-size: 13px;
    text-align: center;
    padding: 26px 0;
    margin: 0;
}

/* Hidden input */
.ct-hidden { position: absolute; left: -9999px; opacity: 0; width: 1px; height: 1px; }

/* --- Responsive --- */
@media (max-width: 860px) {
    .ct-stats { grid-template-columns: repeat(3, 1fr); }
    .ct-results { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .ct-game { padding: 18px 12px 40px; }
    .ct-title { font-size: 23px; }
    .ct-head { flex-direction: column; }
    .ct-code { font-size: 15px; }
    .ct-gutter { font-size: 15px; min-width: 40px; }
    .ct-code-scroll { height: 320px; padding: 16px 12px 80px 10px; }
    .ct-card { padding: 24px 20px; }
    .ct-card-end { padding: 26px 20px; }
    .ct-count { font-size: 70px; }
    .ct-stat { padding: 9px 12px; }
    .ct-stat-v { font-size: 19px; }
    .ct-config-label { width: 100%; margin-bottom: 2px; }
    .ct-history { padding: 16px 14px; }
    .ct-lb-lang { display: none; }
    .ct-res-main .ct-res-v { font-size: 30px; }
    .ct-res-v { font-size: 24px; }
}