:root {
    --bg: #0b1220;
    --panel: #16233a;
    --panel-2: #1e3050;
    --line: #2a3f60;
    --text: #e8eefb;
    --dim: #7f93b3;
    --accent: #38bdf8;
    --ok: #4ade80;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
}

body {
    background: radial-gradient(120% 90% at 50% 0%, #16233a 0%, var(--bg) 60%);
    color: var(--text);
    font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Geeza Pro", Arial, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.game {
    position: relative;
    width: 100%;
    max-width: 760px;
}

.game__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

h1 {
    font-size: 1.3rem;
    margin: 0;
}

h1::after {
    content: "";
    display: block;
    width: 42px;
    height: 3px;
    margin-top: 6px;
    border-radius: 2px;
    background: var(--accent);
}

.btn {
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 16px;
    font: inherit;
    font-size: .85rem;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.btn:hover {
    background: #27405f;
    border-color: var(--accent);
}

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #06121f;
    font-weight: 700;
}

.btn--primary:hover {
    background: #7dd3fc;
}

.stats {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 0 0 16px;
    padding: 0;
}

.stats li {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 8px;
    text-align: center;
}

.stats b {
    display: block;
    font-size: 1.3rem;
    line-height: 1.1;
}

.stats span {
    display: block;
    font-size: .62rem;
    color: var(--dim);
    margin-top: 4px;
}

.track {
    margin-bottom: 20px;
}

.lane {
    position: relative;
    height: 46px;
    border-radius: 12px;
    background:
        repeating-linear-gradient(90deg, rgba(255, 255, 255, .04) 0 2px, transparent 2px 46px),
        var(--panel);
    border: 1px solid var(--line);
    overflow: hidden;
}

.finish {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 12px;
    background:
        repeating-conic-gradient(#e8eefb 0 25%, #334b6d 0 50%) 0 0 / 8px 8px;
    opacity: .85;
}

.marker {
    position: absolute;
    top: 50%;
    transform: translate(50%, -50%);
    font-size: .66rem;
    font-weight: 700;
    white-space: nowrap;
    border-radius: 999px;
    padding: 5px 9px;
    transition: right .25s linear;
}

.marker--you {
    background: var(--accent);
    color: #06121f;
    z-index: 2;
    box-shadow: 0 0 14px rgba(56, 189, 248, .45);
}

.marker--pace {
    background: transparent;
    border: 1px dashed var(--dim);
    color: var(--dim);
    z-index: 1;
}

.words {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 6px 10px;
    min-height: 132px;
    max-height: 132px;
    overflow: hidden;
    padding: 16px;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    font-size: 1.2rem;
    line-height: 1.9;
}

.words--over {
    opacity: .35;
}

.w {
    color: var(--dim);
    border-radius: 4px;
    padding: 0 2px;
}

.w--done {
    color: #45597a;
}

.w--current {
    position: relative;
    display: inline-block;
    background: rgba(56, 189, 248, .12);
    box-shadow: inset 0 -2px 0 var(--accent);
}

.ghost {
    color: var(--text);
}

.typed {
    position: absolute;
    top: 0;
    right: 0;
    color: var(--ok);
    white-space: pre;
}

.hint {
    margin: 12px 2px 0;
    font-size: .8rem;
    color: var(--dim);
    line-height: 1.6;
}

kbd {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 1px 5px;
    font-size: .75rem;
    color: var(--text);
}

/* [hidden] loses to display:flex on the rule below, so restore it */
.over[hidden] {
    display: none;
}

.over {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    background: rgba(11, 18, 32, .88);
    backdrop-filter: blur(3px);
    border-radius: 14px;
    padding: 20px;
}

.over h2 {
    margin: 0;
    font-size: 1.35rem;
}

.over p {
    margin: 0 0 8px;
    color: var(--dim);
    font-size: .9rem;
    max-width: 34em;
    line-height: 1.7;
}

@media (max-width: 520px) {
    .stats b {
        font-size: 1.05rem;
    }

    .words {
        font-size: 1.05rem;
        min-height: 120px;
        max-height: 120px;
    }

    .marker--pace {
        display: none;
    }
}
