:root {
    --primary-gold: #D4AF37;
    --primary-gold-light: #FFD700;
    --primary-gold-dark: #B8941F;
    --bg-dark: #0a0a0a;
    --bg-card: #141414;
    --bg-secondary: #1a1a1a;
    --text-white: #ffffff;
    --text-gray: #b0b0b0;
    --text-muted: #4a4a4a;
    --correct-color: #4ade80;
    --error-color: #ef4444;
    --cursor-color: #FFD700;
    --transition: all 0.3s ease;
    --border-gold: rgba(212, 175, 55, 0.15);
    --glow-gold: rgba(212, 175, 55, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-white);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========== SVG ICONS ========== */
.icon-svg {
    vertical-align: middle;
    stroke: currentColor;
    display: inline-block;
    flex-shrink: 0;
}

.logo-img {
    height: 32px;
    width: auto;
    margin-right: 10px;
    vertical-align: middle;
    filter: drop-shadow(0 0 5px rgba(212, 175, 55, 0.3));
}

.mode-btn .icon-svg {
    margin-right: 8px;
}

.btn-icon {
    margin-right: 6px;
}

.trophy-icon {
    color: var(--primary-gold);
    filter: drop-shadow(0 0 8px rgba(212, 175, 55, 0.3));
    margin-right: 12px;
    animation: pulseGlow 2s infinite ease-in-out;
}

.history-title-icon {
    color: var(--primary-gold);
    margin-right: 10px;
}

@keyframes pulseGlow {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(212, 175, 55, 0.3)); }
    50% { filter: drop-shadow(0 0 12px rgba(212, 175, 55, 0.6)); }
}

/* ========== HEADER ========== */
.header {
    padding: 20px 0;
    border-bottom: 1px solid var(--border-gold);
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
}

.logo-text {
    color: var(--text-white);
}

.logo-highlight {
    background: linear-gradient(135deg, var(--primary-gold), var(--primary-gold-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ========== NAV & LANGUAGE ========== */
.nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.info-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 6px 16px;
    border-radius: 20px;
    color: var(--text-gray);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.info-btn:hover {
    background: rgba(212, 175, 55, 0.08);
    border-color: var(--primary-gold);
    color: var(--primary-gold);
}

.lang-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 6px 16px;
    border-radius: 20px;
    color: var(--text-white);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.lang-toggle-btn:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: var(--primary-gold);
    color: var(--primary-gold);
}

.lang-icon {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    object-fit: cover;
}

/* ========== HERO ========== */
.hero {
    padding: 60px 0 25px;
    text-align: center;
}

h1 {
    font-size: 3rem;
    margin-bottom: 12px;
    font-weight: 800;
}

.highlight {
    background: linear-gradient(135deg, var(--primary-gold), var(--primary-gold-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    color: var(--text-gray);
    font-size: 1.15rem;
}

/* ========== GAME CONTAINER ========== */
.game-container {
    max-width: 900px;
    margin: 30px auto 0;
    padding: 0 20px;
}

/* ========== MODE SELECTOR ========== */
.mode-selector {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: 14px;
    border: 1px solid var(--border-gold);
}

.mode-btn {
    background: transparent;
    border: none;
    color: var(--text-gray);
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
}

.mode-btn:hover {
    color: var(--primary-gold-light);
    background: rgba(212, 175, 55, 0.08);
}

.mode-btn.active {
    background: rgba(212, 175, 55, 0.15);
    color: var(--primary-gold-light);
    box-shadow: inset 0 0 20px rgba(212, 175, 55, 0.05);
}

/* ========== SETTINGS BAR ========== */
.settings-bar {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    min-height: 42px;
    align-items: center;
}

.settings-group {
    display: flex;
    gap: 3px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.setting-btn {
    background: transparent;
    border: none;
    color: var(--text-gray);
    padding: 7px 18px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
}

.setting-btn:hover {
    color: var(--text-white);
}

.setting-btn.active {
    background: var(--primary-gold);
    color: #000;
    box-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
}

/* ========== TYPING AREA ========== */
.typing-area {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 30px 35px;
    border: 1px solid var(--border-gold);
    margin-bottom: 16px;
    position: relative;
    cursor: text;
    min-height: 170px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.typing-area:focus-within {
    border-color: rgba(212, 175, 55, 0.35);
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.04);
}

.typing-area.game-over {
    pointer-events: none;
    opacity: 0.5;
}

.text-display {
    font-family: 'JetBrains Mono', 'Source Code Pro', 'Courier New', monospace;
    font-size: 1.35rem;
    line-height: 2.1;
    letter-spacing: 0.3px;
    max-height: 145px;
    overflow: hidden;
    position: relative;
    user-select: none;
    word-break: break-word;
}

.text-display .char {
    color: var(--text-muted);
    transition: color 0.05s ease;
    position: relative;
}

.text-display .char.correct {
    color: var(--correct-color);
}

.text-display .char.incorrect {
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
    border-radius: 2px;
}

.text-display .char.current {
    color: var(--text-white);
    border-left: 2.5px solid var(--cursor-color);
    margin-left: -1px;
    padding-left: 2px;
    animation: cursorBlink 1s ease infinite;
}

@keyframes cursorBlink {
    0%, 100% { border-color: var(--cursor-color); }
    50% { border-color: transparent; }
}

.typing-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: text;
    z-index: 10;
    font-size: 16px;
    border: none;
    outline: none;
    background: transparent;
}

.start-prompt {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-gray);
    font-size: 0.85rem;
    font-weight: 500;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    white-space: nowrap;
    background: rgba(10, 10, 10, 0.75);
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid rgba(212, 175, 55, 0.15);
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    z-index: 5;
}

.start-prompt.fade {
    opacity: 0;
    transform: translate(-50%, 10px);
}

/* ========== GAME CONTROLS ========== */
.game-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    min-height: 30px;
}

.hint-text {
    color: var(--text-muted);
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

.hint-text kbd {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2px 7px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    margin: 0 2px;
}

/* ========== LIVE STATS ========== */
.live-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 20px;
    padding: 14px 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.stat-item {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--primary-gold);
    display: block;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 3px;
}

/* ========== VIRTUAL KEYBOARD ========== */
.keyboard-section {
    margin-bottom: 30px;
}

.keyboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 18px;
    background: var(--bg-card);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.keyboard-row {
    display: flex;
    gap: 5px;
}

.key {
    min-width: 44px;
    height: 44px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 3px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    color: var(--text-gray);
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.08s ease;
    font-family: 'JetBrains Mono', monospace;
    user-select: none;
}

.key.active {
    background: var(--primary-gold);
    color: #000;
    border-color: var(--primary-gold);
    border-bottom-color: var(--primary-gold-dark);
    transform: translateY(2px);
    border-bottom-width: 1px;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.35);
}

.key.space {
    min-width: 300px;
}

/* ========== RESULTS SCREEN ========== */
.results-screen {
    text-align: center;
    animation: slideUp 0.5s ease;
    padding: 20px 0;
}

.results-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.results-title-text {
    background: linear-gradient(135deg, var(--primary-gold), var(--primary-gold-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.results-main {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 22px 30px;
    min-width: 130px;
    transition: var(--transition);
}

.result-card.primary {
    border-color: var(--primary-gold);
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.1);
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.08), rgba(255, 215, 0, 0.03));
}

.result-card .result-value {
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--primary-gold);
    display: block;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.2;
}

.result-card .result-label {
    font-size: 0.75rem;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 6px;
    display: block;
}

.results-details {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px 25px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    text-align: left;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.9rem;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--text-gray);
}

.detail-value {
    color: var(--text-white);
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.results-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ========== BUTTONS ========== */
.btn-primary {
    background: var(--primary-gold);
    color: #000;
    border: none;
    padding: 12px 28px;
    border-radius: 10px;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(212, 175, 55, 0.4);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-gold);
    color: var(--primary-gold);
    padding: 10px 26px;
    border-radius: 10px;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-outline:hover {
    background: var(--primary-gold);
    color: #000;
}

.btn-small {
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
}

/* ========== HISTORY SECTION ========== */
.history-section {
    max-width: 900px;
    margin: 10px auto 50px;
    padding: 0 20px;
}

.history-section h2 {
    color: var(--primary-gold);
    margin-bottom: 16px;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
}

.history-grid {
    display: grid;
    gap: 8px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 14px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    gap: 15px;
    flex-wrap: wrap;
}

.history-mode {
    color: var(--primary-gold);
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 80px;
    display: flex;
    align-items: center;
}

.history-mode .icon-svg {
    margin-right: 6px;
}

.history-stats {
    display: flex;
    gap: 18px;
    color: var(--text-gray);
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
}

.history-stats span {
    white-space: nowrap;
}

.history-date {
    color: var(--text-muted);
    font-size: 0.78rem;
    min-width: 90px;
    text-align: right;
}

.clear-history-btn {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: var(--error-color);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 12px;
    font-family: 'Inter', sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.clear-history-btn:hover {
    background: var(--error-color);
    color: white;
    border-color: var(--error-color);
}

/* ========== FOOTER ========== */
.footer {
    padding: 40px 0;
    border-top: 1px solid var(--border-gold);
    text-align: center;
    color: var(--text-gray);
    font-size: 0.9rem;
}

.footer a {
    color: var(--primary-gold);
    text-decoration: none;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary-gold-light);
}

/* ========== UTILITIES ========== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(25px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .info-btn span {
        display: none;
    }

    .info-btn {
        padding: 8px;
        gap: 0;
    }

    .info-btn .btn-icon {
        margin-right: 0;
    }

    h1 {
        font-size: 2rem;
    }

    .hero {
        padding: 40px 0 15px;
    }

    .hero p {
        font-size: 1rem;
    }

    .mode-selector {
        gap: 3px;
        padding: 6px;
    }

    .mode-btn {
        padding: 8px 10px;
        font-size: 0.78rem;
    }

    .mode-btn .icon-svg {
        display: none;
    }

    .settings-group {
        flex-wrap: wrap;
        justify-content: center;
    }

    .setting-btn {
        padding: 6px 14px;
        font-size: 0.8rem;
    }

    .typing-area {
        padding: 20px;
        min-height: 150px;
        border-radius: 15px;
    }

    .text-display {
        font-size: 1.1rem;
        line-height: 1.9;
        max-height: 130px;
    }

    .live-stats {
        gap: 20px;
        padding: 12px 15px;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .keyboard-section {
        display: none !important;
    }

    .results-main {
        gap: 8px;
    }

    .result-card {
        padding: 16px 22px;
        min-width: 95px;
    }

    .result-card .result-value {
        font-size: 1.8rem;
    }

    .results-actions {
        flex-direction: column;
        align-items: center;
    }

    .btn-primary, .btn-outline {
        width: 100%;
        max-width: 250px;
    }

    .history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .history-date {
        text-align: left;
    }

    .game-controls .hint-text {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.6rem;
    }

    .logo {
        font-size: 20px;
    }

    .game-container {
        padding: 0 12px;
    }

    .text-display {
        font-size: 1rem;
        line-height: 1.8;
    }

    .typing-area {
        padding: 15px;
    }

    .live-stats {
        gap: 12px;
    }
}

/* ========== MODAL (Premium Glassmorphism) ========== */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(5, 5, 5, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    border: 1px solid var(--border-gold);
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(212, 175, 55, 0.15);
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-gray);
    cursor: pointer;
    transition: var(--transition);
}

.close-modal:hover {
    color: var(--primary-gold-light);
}

/* ========== CUSTOM SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-card);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.25);
    border-radius: 10px;
    transition: var(--transition);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-gold);
}

/* Firefox Support */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.25) var(--bg-card);
}