/* ==========================================================================
   KEYBOARD MASTER - PERFECT TYPING STYLES & FLOATING CARET (ELEVENTOR BRAND)
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

.game-page-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    padding-top: 90px;
    padding-bottom: 30px;
    background: #090c15;
}

.game-wrapper-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 24px;
    max-width: 860px;
    margin: 0 auto;
}

/* Glassmorphism Main Workbench Card */
.km-game-workbench {
    width: 100%;
    background: rgba(15, 19, 32, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 156, 245, 0.2);
    border-radius: 24px;
    box-shadow: 0 0 50px rgba(255, 156, 245, 0.12), 0 30px 80px rgba(0, 0, 0, 0.85);
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    box-sizing: border-box;
}

/* Header Config Bar */
.km-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.km-brand-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.km-logo-small {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid rgba(255, 156, 245, 0.3);
}

.km-title-h1 {
    font-family: "Outfit", sans-serif;
    font-size: 20px;
    font-weight: 800;
    color: #ffffff;
    margin: 0;
}

.km-header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.km-pill-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--ink-dim, #8b949e);
    padding: 6px 14px;
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.km-pill-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.km-pill-btn.active {
    background: rgba(255, 156, 245, 0.16);
    color: #FF9CF5;
    border-color: rgba(255, 156, 245, 0.4);
    font-weight: 700;
}

/* TOP HORIZONTAL HUD STATS BAR */
.km-top-hud-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: rgba(8, 11, 20, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 14px 20px;
    align-items: center;
}

.km-hud-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
}

.km-hud-item:not(:last-child)::after {
    content: "";
    position: absolute;
    right: 0;
    top: 15%;
    height: 70%;
    width: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.km-hud-icon {
    font-size: 18px;
    color: #FF9CF5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.km-hud-content {
    display: flex;
    flex-direction: column;
}

.km-hud-title {
    font-family: "JetBrains Mono", monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #8b949e;
    text-transform: uppercase;
}

.km-hud-value {
    font-family: "JetBrains Mono", monospace;
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.1;
}

.km-hud-value.highlight {
    color: #FF9CF5;
}

/* PARAGRAPH TEXT BOX CONTAINER */
.km-text-box {
    position: relative;
    background: rgba(8, 11, 20, 0.85);
    border: 1px solid rgba(255, 156, 245, 0.25);
    border-radius: 18px;
    padding: 26px 30px;
    min-height: 140px;
    cursor: text;
    transition: all 0.25s ease;
    overflow: hidden;
}

.km-text-box:focus-within, .km-text-box.active {
    border-color: #FF9CF5;
    box-shadow: 0 0 20px rgba(255, 156, 245, 0.15);
}

.km-hidden-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.km-paragraph-stream {
    font-family: "JetBrains Mono", monospace;
    font-size: 21px;
    line-height: 1.85;
    color: rgba(255, 255, 255, 0.35);
    user-select: none;
    white-space: normal;
    word-break: normal;
    overflow-y: hidden;
    position: relative;
}

/* WORD & CHARACTER STYLING */
.km-word {
    display: inline-block;
    white-space: nowrap;
    margin-right: 10px;
    margin-bottom: 6px;
}

.km-word.active-word {
    color: rgba(255, 255, 255, 0.65);
}

.km-char {
    position: relative;
    display: inline;
    transition: color 0.05s ease;
}

.km-char.correct {
    color: #ffffff;
}

.km-char.incorrect {
    color: #ff4b4b;
    background: rgba(255, 75, 75, 0.22);
    border-radius: 2px;
    text-decoration: underline;
}

/* ABSOLUTE FLOATING CURSOR CARET */
.km-cursor {
    position: absolute;
    top: 0;
    left: 0;
    width: 2.5px;
    height: 26px;
    background: #FF9CF5;
    box-shadow: 0 0 10px #FF9CF5, 0 0 18px rgba(255, 156, 245, 0.6);
    border-radius: 2px;
    pointer-events: none;
    z-index: 10;
    transition: transform 0.08s cubic-bezier(0.1, 0.9, 0.2, 1);
    animation: kmCursorBlink 0.8s infinite alternate;
}

@keyframes kmCursorBlink {
    0% { opacity: 1; }
    100% { opacity: 0.3; }
}

/* ON-SCREEN VIRTUAL KEYBOARD */
.km-keyboard-wrapper {
    background: rgba(8, 11, 20, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    user-select: none;
}

.km-kb-row {
    display: flex;
    justify-content: center;
    gap: 7px;
}

.km-key {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    font-family: "JetBrains Mono", monospace;
    font-size: 14px;
    font-weight: 600;
    height: 44px;
    min-width: 44px;
    padding: 0 12px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease;
}

.km-key.space-key {
    flex-grow: 1;
    max-width: 460px;
    font-size: 11px;
    letter-spacing: 0.1em;
    color: #8b949e;
}

.km-key.action-key {
    min-width: 54px;
    font-size: 15px;
    color: #8b949e;
}

.km-key.active-target {
    border-color: #FF9CF5 !important;
    color: #FF9CF5 !important;
    background: rgba(255, 156, 245, 0.25) !important;
    box-shadow: 0 0 16px rgba(255, 156, 245, 0.5) !important;
    font-weight: 700 !important;
}

.km-key.pressed {
    background: linear-gradient(135deg, #FF9CF5, #9B51E0) !important;
    color: #ffffff !important;
    border-color: #FF9CF5 !important;
    box-shadow: 0 0 20px rgba(255, 156, 245, 0.7) !important;
    transform: translateY(3px) !important;
}

.km-key.wrong-key {
    background: #ff4b4b !important;
    color: #ffffff !important;
    border-color: #ff0055 !important;
    box-shadow: 0 0 20px rgba(255, 75, 75, 0.8) !important;
    animation: kmShake 0.2s ease !important;
}

@keyframes kmShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

/* RESULTS POPUP MODAL */
.km-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(5, 7, 14, 0.92);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.km-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.km-results-card {
    background: #0f1322;
    border: 1.5px solid rgba(255, 156, 245, 0.3);
    border-radius: 28px;
    max-width: 460px;
    width: 100%;
    padding: 32px 36px;
    box-shadow: 0 0 60px rgba(255, 156, 245, 0.2), 0 30px 80px rgba(0, 0, 0, 0.9);
    transform: scale(0.9);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.km-modal-overlay.active .km-results-card {
    transform: scale(1);
}

.km-modal-top-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.km-icon-nav-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #8b949e;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.km-icon-nav-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.km-modal-header-title {
    font-family: "Outfit", sans-serif;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #ffffff;
    text-transform: uppercase;
}

.km-trophy-wrap {
    margin: 12px 0 16px;
    position: relative;
}

.km-trophy-icon {
    width: 80px;
    height: 80px;
    filter: drop-shadow(0 0 20px rgba(255, 156, 245, 0.5));
}

.km-results-heading {
    font-family: "Outfit", sans-serif;
    font-size: 26px;
    font-weight: 800;
    color: #FF9CF5;
    margin: 0 0 6px 0;
}

.km-results-sub {
    font-family: "JetBrains Mono", monospace;
    font-size: 13px;
    color: #8b949e;
    margin-bottom: 24px;
}

.km-results-metrics-box {
    width: 100%;
    background: rgba(8, 11, 20, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 16px 12px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 28px;
    box-sizing: border-box;
}

.km-metric-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.km-metric-cell:not(:last-child)::after {
    content: "";
    position: absolute;
    right: 0;
    top: 15%;
    height: 70%;
    width: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.km-m-label {
    font-family: "JetBrains Mono", monospace;
    font-size: 10px;
    font-weight: 700;
    color: #8b949e;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.km-m-val {
    font-family: "JetBrains Mono", monospace;
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.1;
}

.km-m-diff {
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    font-weight: 600;
    color: #38ef7d;
    margin-top: 4px;
}

.km-m-diff.yellow {
    color: #ffb800;
}

.km-modal-action-row {
    width: 100%;
    display: flex;
    gap: 12px;
}

.km-btn-modal-stats {
    flex: 1;
    padding: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-family: "Outfit", sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.05em;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.km-btn-modal-stats:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.km-btn-modal-again {
    flex: 1;
    padding: 14px;
    background: linear-gradient(135deg, #FF9CF5, #9B51E0);
    color: #ffffff;
    font-family: "Outfit", sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.05em;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(255, 156, 245, 0.4);
    transition: all 0.2s ease;
}

.km-btn-modal-again:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(255, 156, 245, 0.6);
}

@media (max-width: 768px) {
    .km-top-hud-bar {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .km-hud-item:not(:last-child)::after {
        display: none;
    }
    .km-results-metrics-box {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .km-metric-cell:not(:last-child)::after {
        display: none;
    }
    .km-keyboard-wrapper {
        display: none;
    }
}

/* Slide-in Info Drawer Styles */
.game-drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(5, 7, 14, 0.7);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.game-drawer-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.game-drawer-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 480px;
    background: #0f1322;
    border-left: 1px solid rgba(255, 156, 245, 0.25);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

.game-drawer-overlay.active .game-drawer-panel {
    transform: translateX(0);
}

.game-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.game-drawer-title {
    font-family: var(--font-heading, 'IBM Plex Serif', serif);
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
}

.game-drawer-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #8b949e;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.game-drawer-close-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
}

.game-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    color: var(--ink-dim, #a8a39a);
    font-family: var(--font-body, 'IBM Plex Sans', sans-serif);
    font-size: 14px;
    line-height: 1.8;
}
