        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #2a2a2a, #1a1a1a);
            color: #f0f0f0;
            padding: 20px;
            min-height: 100vh;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
        }

        .header {
            text-align: center;
            margin-bottom: 40px;
            padding: 20px;
            transition: all 0.3s ease;
            position: relative;
        }

        .settings-button {
            background: rgba(80, 80, 80, 0.3);
            border: 1px solid #5a5a5a;
            border-radius: 8px;
            padding: 8px 12px;
            color: #fff;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s;
            display: flex;
            align-items: center;
            gap: 5px;
        }

        .settings-button:hover {
            background: rgba(100, 100, 100, 0.4);
            border-color: #ff7e5f;
        }

        .settings-icon {
            width: 16px;
            height: 16px;
            fill: #fff;
        }

        body.test-active .header {
            opacity: 0.4;
            filter: brightness(0.5);
        }

        h1 {
            color: #ff7e5f;
            margin-bottom: 10px;
            font-size: 2.8em;
            font-weight: 700;
            text-shadow: 0 0 15px rgba(255, 126, 95, 0.4);
        }

        .subtitle {
            color: #ddd;
            font-size: 18px;
            margin-top: 5px;
        }

        /* Keyboard Section - Minimalist */
        .keyboard-section {
            margin: 40px auto;
            transition: all 0.3s ease;
        }

        body.test-active .keyboard-section {
            opacity: 0.4;
            filter: brightness(0.5);
        }

        .keyboard-info {
            text-align: center;
            margin-bottom: 30px;
        }

        .keyboard-selector {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 15px;
            margin-bottom: 15px;
        }

        .keyboard-selector label {
            color: #ddd;
            font-size: 16px;
        }

        .keyboard-selector select {
            background: rgba(80, 80, 80, 0.3);
            color: #fff;
            border: 1px solid #5a5a5a;
            border-radius: 20px;
            padding: 8px 15px;
            font-size: 16px;
            outline: none;
            transition: all 0.3s;
            cursor: pointer;
        }

        .keyboard-selector select:hover {
            background: rgba(100, 100, 100, 0.4);
            border-color: #ff7e5f;
        }

        .keyboard-selector select:focus {
            box-shadow: 0 0 0 2px rgba(255, 126, 95, 0.5);
        }

        .layout-picker-button {
            background: rgba(80, 80, 80, 0.3);
            color: #fff;
            border: 1px solid #5a5a5a;
            border-radius: 20px;
            padding: 8px 15px;
            font-size: 16px;
            outline: none;
            transition: all 0.3s;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .layout-picker-button:hover {
            background: rgba(100, 100, 100, 0.4);
            border-color: #ff7e5f;
        }

        .layout-picker-chevron {
            width: 16px;
            height: 16px;
            fill: #ccc;
        }

        .layout-option.active {
            background: rgba(255, 126, 95, 0.15);
            border-color: rgba(255, 126, 95, 0.5);
        }

        .control-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 20px;
            margin-top: 40px;
            max-width: 1200px;
            margin-left: auto;
            margin-right: auto;
        }

        .control-group {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 15px;
        }

        .time-selector {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
            margin-top: 20px;
        }

        .time-selector label {
            color: #ddd;
            font-size: 14px;
            font-weight: 500;
        }

        .time-selector input[type="range"] {
            -webkit-appearance: none;
            appearance: none;
            width: 200px;
            height: 6px;
            background: rgba(80, 80, 80, 0.3);
            border-radius: 3px;
            outline: none;
            transition: all 0.3s;
        }

        .time-selector input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 20px;
            height: 20px;
            background: #ff7e5f;
            border-radius: 50%;
            cursor: pointer;
            box-shadow: 0 2px 6px rgba(255, 126, 95, 0.3);
            transition: all 0.3s;
        }

        .time-selector input[type="range"]::-webkit-slider-thumb:hover {
            transform: scale(1.1);
            box-shadow: 0 4px 8px rgba(255, 126, 95, 0.4);
        }

        .time-selector input[type="range"]::-moz-range-thumb {
            width: 20px;
            height: 20px;
            background: #ff7e5f;
            border-radius: 50%;
            cursor: pointer;
            border: none;
            box-shadow: 0 2px 6px rgba(255, 126, 95, 0.3);
            transition: all 0.3s;
        }

        .time-selector input[type="range"]:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .time-selector input[type="range"]:disabled::-webkit-slider-thumb {
            cursor: not-allowed;
        }



        .keyboard-background {
            width: 1200px;
            height: 450px;
            background: #3a3a3a;
            border-radius: 10px;
            margin: 0 auto;
            transform: scale(1.1);
            transform-origin: center;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .keyboard-wrapper {
            position: relative;
            width: 1052.05px;
            height: 373.199px;
            background: transparent;
            border-radius: 0;
            margin: 0;
            transform: none;
            box-shadow: none;
        }

        .keycap-wrapper {
            position: absolute;
            z-index: 1;
        }

        .keycap-key {
            width: 100%;
            height: 100%;
            position: relative;
        }

        .keycap {
            width: 100%;
            height: 100%;
            background: linear-gradient(145deg, #5a5a5a, #4a4a4a);
            background-size: cover;
            border-radius: 6px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-size: 12px;
            font-weight: 500;
            text-align: center;
            line-height: 1.2;
            transition: all 0.1s ease;
            cursor: pointer;
            border: 1px solid #3a3a3a;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 2px 4px rgba(0, 0, 0, 0.3);
        }

        .keycap.escape-key {
            background: linear-gradient(145deg, #ff7e5f, #e56a4a);
            border-color: #cc573a;
        }

        .keycap.enter-key {
            background: linear-gradient(145deg, #ff7e5f, #e56a4a);
            border-color: #cc573a;
        }

        .keycap.rotate {
            background: linear-gradient(145deg, #ff7e5f, #e56a4a);
            border-color: #cc573a;
            border-radius: 50%;
        }

        .keycap.active {
            background: #ff7e5f;
            border-color: #ff7e5f;
            transform: scale(0.95);
            box-shadow: 0 0 15px rgba(255, 126, 95, 0.6);
        }

        .active-cover {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(255, 126, 95, 0.3);
            border-radius: 6px;
            z-index: 2;
            opacity: 0;
            transition: opacity 0.1s;
        }

        .active-cover.visible {
            opacity: 1;
        }

        .controls {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 15px;
            margin-top: 30px;
        }

        .mode-label {
            color: #ddd;
            font-size: 14px;
            font-weight: 500;
        }

        /* Toggle Switch */
        .toggle-switch {
            position: relative;
            width: 60px;
            height: 30px;
            background: #5a5a5a;
            border-radius: 15px;
            cursor: pointer;
            transition: all 0.3s ease;
            border: 2px solid #5a5a5a;
        }

        .toggle-switch.active {
            background: #ff7e5f;
            border-color: #ff7e5f;
        }

        .toggle-slider {
            position: absolute;
            top: 2px;
            left: 2px;
            width: 22px;
            height: 22px;
            background: white;
            border-radius: 50%;
            transition: all 0.3s ease;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        }

        .toggle-switch.active .toggle-slider {
            transform: translateX(30px);
        }

        /* Test Type Selector */
        .test-type-selector {
            display: flex;
            background: rgba(80, 80, 80, 0.3);
            border-radius: 12px;
            padding: 4px;
            border: 1px solid rgba(255, 126, 95, 0.2);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }

        .test-type-btn {
            flex: 1;
            padding: 10px 20px;
            background: transparent;
            border: none;
            border-radius: 8px;
            color: #ddd;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .test-type-btn:hover {
            background: rgba(100, 100, 100, 0.4);
            color: #fff;
        }

        .test-type-btn.active {
            background: linear-gradient(135deg, #ff7e5f, #e56a4a);
            color: white;
            box-shadow: 0 2px 8px rgba(255, 126, 95, 0.3);
        }

        .test-type-btn:not(:last-child) {
            margin-right: 4px;
        }

        /* Disabled test type selector */
        .test-type-selector.disabled {
            opacity: 0.5;
            pointer-events: none;
        }
        
        .test-type-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }
        
        .test-type-btn:disabled:hover {
            background: transparent;
            color: #ddd;
        }
        
        .test-type-btn:disabled.active {
            opacity: 0.7;
        }

        /* Keyboard Analytics Panel - NEW */
        .keyboard-analytics {
            display: none;
            background: rgba(40, 40, 40, 0.95);
            padding: 30px;
            border-radius: 15px;
            margin: 30px auto;
            max-width: 1200px;
            animation: slideIn 0.5s ease-out;
        }

        body.keyboard-only .keyboard-analytics {
            display: block;
        }

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

        .analytics-title {
            color: #ff7e5f;
            font-size: 1.8em;
            font-weight: 700;
            text-align: center;
            margin-bottom: 30px;
            text-shadow: 0 0 10px rgba(255, 126, 95, 0.3);
        }

        .analytics-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            grid-template-rows: auto auto;
            gap: 25px;
            margin-bottom: 25px;
        }

        .analytics-card {
            background: rgba(60, 60, 60, 0.4);
            border-radius: 12px;
            padding: 20px;
            border: 1px solid rgba(255, 126, 95, 0.2);
        }

        .card-title {
            color: #fff;
            font-size: 1.1em;
            font-weight: 600;
            margin-bottom: 15px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .card-icon {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: #ff7e5f;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
        }

        .live-stats {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 15px;
        }

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

        .live-stat-value {
            font-size: 2em;
            font-weight: 700;
            color: #ff7e5f;
            margin-bottom: 5px;
        }

        .live-stat-label {
            color: #aaa;
            font-size: 0.9em;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .chart-container {
            height: 150px;
            position: relative;
            background: rgba(80, 80, 80, 0.2);
            border-radius: 8px;
            overflow: hidden;
        }

        .chart-canvas {
            width: 100%;
            height: 100%;
        }

        .top-keys-list {
            max-height: 120px;
            overflow-y: auto;
        }

        .top-key-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 12px;
            margin: 4px 0;
            background: rgba(80, 80, 80, 0.3);
            border-radius: 6px;
            border-left: 3px solid #ff7e5f;
        }

        .key-name {
            font-weight: 600;
            color: #fff;
        }

        .key-count {
            color: #ff7e5f;
            font-weight: 700;
        }

        .progress-bar {
            width: 60px;
            height: 4px;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 2px;
            overflow: hidden;
        }

        .progress-fill {
            height: 100%;
            background: #ff7e5f;
            transition: width 0.3s ease;
        }

        .hand-balance {
            display: flex;
            align-items: center;
            gap: 15px;
            margin-top: 10px;
        }

        .hand-indicator {
            flex: 1;
            text-align: center;
        }

        .hand-percentage {
            font-size: 1.5em;
            font-weight: 700;
            color: #ff7e5f;
        }

        .hand-label {
            color: #aaa;
            font-size: 0.9em;
        }

        .balance-bar {
            flex: 2;
            height: 12px;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 6px;
            overflow: hidden;
            position: relative;
        }

        .balance-fill-left {
            position: absolute;
            left: 0;
            top: 0;
            height: 100%;
            background: linear-gradient(90deg, #4CAF50, #66BB6A);
            transition: width 0.5s ease;
        }

        .balance-fill-right {
            position: absolute;
            right: 0;
            top: 0;
            height: 100%;
            background: linear-gradient(90deg, #FF9800, #FFB74D);
            transition: width 0.5s ease;
        }

        /* Heatmap styles */
        .heatmap-container {
            margin-top: 10px;
        }

        .heatmap-row {
            display: flex;
            gap: 2px;
            margin: 2px 0;
            justify-content: center;
        }

        .heatmap-key {
            width: 20px;
            height: 20px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 3px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 8px;
            color: #fff;
            transition: all 0.3s ease;
        }

        .heatmap-key.heat-1 { background: rgba(255, 126, 95, 0.3); }
        .heatmap-key.heat-2 { background: rgba(255, 126, 95, 0.5); }
        .heatmap-key.heat-3 { background: rgba(255, 126, 95, 0.7); }
        .heatmap-key.heat-4 { background: rgba(255, 126, 95, 0.9); }
        .heatmap-key.heat-5 { background: rgba(255, 126, 95, 1); }

        /* Test Results Summary */
        .results-summary {
            background: rgba(40, 40, 40, 0.95);
            padding: 40px;
            border-radius: 15px;
            margin: 30px auto;
            max-width: 1600px;
            transition: all 0.3s;
        }

        .results-container {
            display: flex;
            flex-direction: column;
        }

        .shareable-result-card {
            display: flex;
            gap: 30px;
            align-items: flex-start;
        }


        .results-left {
            flex: 0 0 250px;
        }

        .results-right {
            flex: 1;
        }

        .big-stats {
            margin-bottom: 25px;
        }

        .big-wpm {
            font-size: 6em;
            font-weight: 800;
            color: #ff7e5f;
            line-height: 0.9;
            margin-bottom: 5px;
        }

        .big-wpm-label {
            color: #aaa;
            font-size: 20px;
            margin-bottom: 15px;
        }

        .big-acc {
            font-size: 3em;
            font-weight: 700;
            color: #fff;
            margin-bottom: 5px;
        }

        .big-acc-label {
            color: #aaa;
            font-size: 16px;
            margin-bottom: 20px;
        }

        .test-info {
            color: #bbb;
            font-size: 16px;
            margin-bottom: 20px;
        }

        .test-info span {
            color: #ff7e5f;
            font-weight: 600;
        }

        .graph-container {
            background: rgba(60, 60, 60, 0.3);
            border-radius: 10px;
            padding: 20px;
            margin-bottom: 20px;
            height: 280px;
            position: relative;
        }

        .graph-title {
            color: #ddd;
            font-size: 16px;
            margin-bottom: 15px;
            text-align: center;
        }

        .wpm-graph {
            width: 100%;
            height: 200px;
            position: relative;
        }

        .detail-stats {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 20px;
            margin-top: 20px;
        }

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

        .detail-stat-label {
            color: #aaa;
            font-size: 14px;
            margin-bottom: 5px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .detail-stat-value {
            color: #ff7e5f;
            font-size: 28px;
            font-weight: 700;
        }

        .characters-breakdown {
            font-size: 22px;
            color: #fff;
        }

        .char-correct { color: #4CAF50; }
        .char-incorrect { color: #f44336; }
        .char-extra { color: #ff9800; }
        .char-missed { color: #9e9e9e; }

        body.test-active .results-summary {
            opacity: 0.4;
            filter: brightness(0.5);
        }

        body.keyboard-only .results-summary {
            display: none;
        }

        .summary-title {
            color: #fff;
            font-size: 1.4em;
            font-weight: 600;
            text-align: center;
            margin-bottom: 15px;
        }

        .test-result {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 15px;
            margin: 5px 0;
            background: rgba(60, 60, 60, 0.5);
            border-radius: 8px;
            font-size: 0.9em;
            border: 2px solid #ff7e5f;
            background: rgba(255, 126, 95, 0.1);
        }

        .result-stats {
            display: flex;
            gap: 20px;
        }

        .result-stat {
            color: #ddd;
        }

        .result-stat strong {
            color: #ff7e5f;
        }
        body.keyboard-only #wordsDisplay,
        body.keyboard-only .stats-container {
            display: none;
        }

        /* Modal Styles */
        .modal-backdrop {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.7);
            z-index: 999;
            display: none;
            backdrop-filter: blur(5px);
        }

        .results-summary {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 1000;
            display: none;
            max-height: 90vh;
            overflow: hidden;
            padding-bottom: 20px;
        }

        .results-summary.show {
            animation: modalIn 0.6s ease-out;
        }

        @keyframes modalIn {
            from {
                opacity: 0;
                transform: translate(-50%, -60%) scale(0.9);
            }
            to {
                opacity: 1;
                transform: translate(-50%, -50%) scale(1);
            }
        }

        body.keyboard-only .header {
            margin-bottom: 20px;
        }

        /* History Browser Modal */
        .history-backdrop {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.7);
            z-index: 1099;
            display: none;
            backdrop-filter: blur(5px);
        }

        .history-browser-modal {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: rgba(40, 40, 40, 0.98);
            padding: 35px;
            border-radius: 20px;
            z-index: 1100;
            display: none;
            max-width: 700px;
            width: 90%;
            max-height: 80vh;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 126, 95, 0.1);
            border: 1px solid rgba(255, 126, 95, 0.1);
        }

        .history-browser-modal.show {
            animation: modalIn 0.6s ease-out;
            display: flex;
            flex-direction: column;
        }

        .history-browser-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 25px;
        }

        .history-browser-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
            overflow-y: auto;
            padding-right: 6px;
        }

        .history-browser-item {
            display: flex;
            align-items: center;
            gap: 20px;
            background: rgba(60, 60, 60, 0.3);
            border: 1px solid rgba(255, 126, 95, 0.1);
            border-radius: 10px;
            padding: 14px 18px;
            cursor: pointer;
            transition: all 0.2s;
            text-align: left;
        }

        .history-browser-item:hover {
            background: rgba(255, 126, 95, 0.1);
            border-color: rgba(255, 126, 95, 0.4);
        }

        .history-browser-item.history-browser-best {
            border-color: rgba(255, 215, 0, 0.4);
        }

        .history-browser-wpm {
            color: #ff7e5f;
            font-weight: 800;
            font-size: 22px;
            min-width: 60px;
        }

        .history-browser-meta {
            flex: 1;
            color: #ddd;
            font-size: 14px;
        }

        .history-browser-meta .history-browser-mode {
            color: #aaa;
            text-transform: uppercase;
            font-size: 11px;
            letter-spacing: 0.5px;
        }

        .history-browser-date {
            color: #888;
            font-size: 12px;
        }

        .history-browser-best-tag {
            background: #ffd700;
            color: #1a1a1a;
            font-size: 10px;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            padding: 2px 8px;
            border-radius: 8px;
        }

        .history-browser-empty {
            color: #888;
            text-align: center;
            padding: 30px;
        }

        /* History Detail Modal (viewing a single past result) */
        .history-detail-modal {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 1101;
            display: none;
            max-height: 90vh;
            overflow: hidden;
            background: rgba(40, 40, 40, 0.95);
            padding: 40px;
            border-radius: 15px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
        }

        .history-detail-modal.show {
            animation: modalIn 0.6s ease-out;
            display: block;
        }

        .modal-close-btn {
            background: rgba(80, 80, 80, 0.4);
            border: 1px solid #5a5a5a;
            color: #fff;
            width: 34px;
            height: 34px;
            border-radius: 50%;
            font-size: 20px;
            line-height: 1;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .modal-close-btn:hover {
            background: rgba(255, 80, 80, 0.3);
            border-color: rgba(255, 80, 80, 0.6);
        }

        .history-detail-modal .test-controls {
            justify-content: center;
        }

        .history-detail-close {
            padding: 0;
            position: absolute;
            right: 0;
            top: 50%;
            transform: translateY(-50%);
        }

        /* Floating Keyboard Overlay */
        .keyboard-overlay {
            position: fixed;
            bottom: 24px;
            right: 24px;
            width: 340px;
            z-index: 1200;
            background: rgba(20, 20, 20, 0.85);
            backdrop-filter: blur(16px);
            border-radius: 16px;
            border: 1px solid rgba(255, 255, 255, 0.08);
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            padding: 6px;
            user-select: none;
        }

        .keyboard-overlay-header {
            display: flex;
            align-items: center;
            gap: 14px;
            padding: 4px 10px;
            background: rgba(255, 255, 255, 0.03);
            border-radius: 8px;
            margin-bottom: 6px;
            font-size: 11px;
            font-weight: 500;
            cursor: move;
            border: 1px solid rgba(255, 255, 255, 0.05);
            height: 24px;
        }

        .keyboard-overlay-header:hover {
            border-color: rgba(255, 126, 95, 0.3);
        }

        .keyboard-overlay-stat {
            color: #ff7e5f;
            white-space: nowrap;
        }

        .keyboard-overlay-stat span {
            color: #fff;
            margin-left: 3px;
        }

        .keyboard-overlay-close {
            margin-left: auto;
            background: rgba(255, 82, 82, 0.85);
            border: none;
            color: #fff;
            width: 18px;
            height: 18px;
            border-radius: 50%;
            font-size: 13px;
            line-height: 1;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

        .keyboard-overlay-close:hover {
            background: rgba(255, 52, 52, 0.95);
        }

        .keyboard-overlay-body {
            position: relative;
            width: 100%;
            overflow: hidden;
        }

        .keyboard-overlay-widget {
            position: relative;
            transform-origin: top left;
        }

        .overlay-key {
            position: absolute;
            background: rgba(255, 255, 255, 0.12);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 3px;
            transition: background 0.08s ease, transform 0.08s ease;
        }

        .overlay-key.pressed {
            background: rgba(255, 126, 95, 0.85) !important;
            border-color: #ff7e5f !important;
            box-shadow: 0 0 8px rgba(255, 126, 95, 0.6);
        }

        /* Typing Test - Minimalist and Wide */
        #wordsDisplay {
            font-size: 1.5em;
            line-height: 1.6;
            text-align: center;
            color: #e0e0e0;
            margin: 40px auto 20px;
            min-height: 120px;
            font-weight: 400;
            padding: 20px;
            max-width: 1400px;
            transition: all 0.3s;
            overflow-x: hidden; /* Prevent horizontal scrolling */
            white-space: normal; /* Allow wrapping */
        }
        
        /* Container for word rows to ensure proper layout */
        .words-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 100%;
        }

        /* Positioned via JS to align exactly under the first .stat-box's left edge. */
        .custom-mode-hint {
            display: none;
            position: absolute;
            color: #ff7e5f;
            font-size: 13px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 1px;
        }
        
        .word-row {
            display: flex;
            flex-wrap: nowrap;
            justify-content: center;
            width: 100%;
            margin-bottom: 10px;
            white-space: nowrap;
        }

        .word-row.custom {
            flex-wrap: wrap;
            white-space: normal;
        }

        .word {
            display: inline-block;
            margin: 0 6px;
            padding: 6px 8px;
            border-radius: 8px;
            transition: all 0.3s;
            position: relative;
            white-space: nowrap;
            max-width: 300px; /* Prevent extremely long words from breaking layout */
            overflow: hidden;
            text-overflow: ellipsis;
            flex-shrink: 0;
        }
        
        /* Allow long words to break in custom mode */
        .word-row.custom .word {
            word-break: break-word;
            overflow-wrap: break-word;
        }

        .word.future {
            opacity: 0.7;
            color: #b0b0b0;
        }

        .word.active {
            background: rgba(80, 80, 80, 0.3);
            color: #ffffff;
            opacity: 1;
            text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
        }

        .word.completed {
            color: #a0a0a0;
            opacity: 0.9;
        }

        .char {
            display: inline-block;
            position: relative;
            transition: color 0.2s;
            color: #e0e0e0;
        }

        .char.correct {
            color: #ffffff;
        }

        .char.incorrect {
            color: #ff6b6b;
        }

        .char.current {
            position: relative;
            color: #ffffff;
            scroll-margin: 0;
        }

        .char.current::after {
            content: '';
            position: absolute;
            bottom: -6px;
            left: 0;
            width: 100%;
            height: 3px;
            background: #ff7e5f;
            animation: blink 1.4s infinite;
            border-radius: 2px;
        }

        .char.ghost {
            position: relative;
        }

        .char.ghost::before {
            content: '';
            position: absolute;
            top: -2px;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(255, 126, 95, 0.4);
            border-radius: 4px;
            z-index: -1;
            animation: ghostPulse 2s infinite;
            box-shadow: 0 0 8px rgba(255, 126, 95, 0.3);
        }

        @keyframes ghostPulse {
            0%, 100% { opacity: 0.3; }
            50% { opacity: 0.6; }
        }

        @keyframes blink {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.6; }
        }

        /* Stats Container */
        .stats-container {
            display: flex;
            justify-content: center;
            gap: 40px;
            margin: 20px auto 40px;
            max-width: 800px;
        }

        .stat-box {
            background: rgba(80, 80, 80, 0.4);
            padding: 20px 35px;
            border-radius: 12px;
            text-align: center;
            min-width: 160px;
            transition: transform 0.3s;
        }

        .stat-box:hover {
            transform: translateY(-5px);
        }

        .stat-value {
            font-size: 3em;
            font-weight: 800;
            color: #ff7e5f;
            margin-top: 10px;
            text-shadow: 0 0 10px rgba(255, 126, 95, 0.4);
        }

        .stat-label {
            color: #ddd;
            font-size: 1em;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .test-controls {
            display: flex;
            justify-content: center;
            gap: 25px;
            margin-top: 20px;
            margin-bottom: 10px;
            position: relative;
        }

        .session-history {
            margin-top: 20px;
        }

        .session-history-title {
            color: #aaa;
            font-size: 14px;
            margin-bottom: 10px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .session-history-list {
            display: flex;
            gap: 10px;
            overflow-x: auto;
            overflow-y: visible;
            padding-top: 10px;
            padding-bottom: 6px;
        }

        .session-history-item {
            flex: 0 0 auto;
            background: rgba(60, 60, 60, 0.3);
            border-radius: 8px;
            padding: 8px 14px;
            text-align: center;
            min-width: 70px;
        }

        .session-history-item.session-history-current {
            background: rgba(255, 126, 95, 0.15);
            border: 1px solid rgba(255, 126, 95, 0.5);
        }

        .session-history-item.session-history-best {
            background: rgba(255, 215, 0, 0.12);
            border: 1px solid rgba(255, 215, 0, 0.5);
            position: relative;
        }

        .session-history-badge {
            position: absolute;
            top: -9px;
            left: 50%;
            transform: translateX(-50%);
            background: #ffd700;
            color: #1a1a1a;
            font-size: 9px;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            padding: 1px 6px;
            border-radius: 8px;
        }

        .session-history-wpm {
            color: #ff7e5f;
            font-weight: 700;
            font-size: 18px;
        }

        .session-history-acc {
            color: #ddd;
            font-size: 12px;
            margin-top: 2px;
        }

        .session-history-mode {
            color: #888;
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-top: 2px;
        }

        .session-history-empty {
            color: #777;
            font-size: 13px;
            padding: 8px 0;
        }

        .test-btn {
            background: #5a5a5a;
            color: white;
            border: none;
            padding: 14px 30px;
            border-radius: 30px;
            cursor: pointer;
            font-size: 16px;
            transition: all 0.3s;
            font-weight: 600;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        }

        .test-btn:hover {
            background: #6a6a6a;
            transform: translateY(-3px);
            box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
        }
        
        .test-btn:active {
            transform: translateY(1px);
        }
        
        .instructions {
            text-align: center;
            color: #ddd;
            margin-top: 20px;
            padding: 20px;
            background: rgba(80, 80, 80, 0.3);
            border-radius: 12px;
            max-width: 800px;
            margin: 30px auto;
            font-size: 1em;
            transition: all 0.3s;
        }

        #startTestBtn {
            display: none;
        }

        body.test-active .instructions {
            opacity: 0.4;
            filter: brightness(0.5);
        }

        body.test-active .test-controls {
            display: none;
        }

        /* Make words brighter during test */
        body.test-active #wordsDisplay {
            opacity: 1;
            filter: brightness(1.2);
        }

        /* Focus overlay */
        .focus-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.2);
            z-index: 999;
            display: none;
            pointer-events: none;
        }

        /* Graph tooltip */
        .graph-tooltip {
            position: fixed;
            background: rgba(40, 40, 40, 0.95);
            color: #fff;
            padding: 8px 12px;
            border-radius: 6px;
            font-size: 14px;
            font-weight: 600;
            pointer-events: none;
            z-index: 1001;
            border: 1px solid rgba(255, 126, 95, 0.3);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
            display: none;
        }

        /* Settings Modal Backdrop */
        .settings-backdrop {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.7);
            z-index: 1099;
            display: none;
            backdrop-filter: blur(5px);
        }

        /* Settings Modal */
        .settings-modal {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: rgba(40, 40, 40, 0.98);
            padding: 45px;
            border-radius: 20px;
            z-index: 1100;
            display: none;
            max-width: 650px;
            width: 90%;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 126, 95, 0.1);
            text-align: center;
            border: 1px solid rgba(255, 126, 95, 0.1);
        }

        .settings-modal.show {
            animation: modalIn 0.6s ease-out;
        }

        .settings-header {
            text-align: center;
            margin-bottom: 35px;
        }

        .settings-title {
            color: #ff7e5f;
            font-size: 2.2em;
            font-weight: 700;
            margin: 0;
            text-shadow: 0 0 15px rgba(255, 126, 95, 0.4);
        }

        .settings-content {
            display: flex;
            flex-direction: column;
            gap: 35px;
        }

        .setting-group {
            display: flex;
            flex-direction: column;
            gap: 15px;
            padding: 25px;
            background: rgba(60, 60, 60, 0.3);
            border-radius: 12px;
            border: 1px solid rgba(255, 126, 95, 0.1);
            transition: all 0.3s ease;
        }

        .setting-group:hover {
            border-color: rgba(255, 126, 95, 0.3);
            background: rgba(70, 70, 70, 0.3);
        }

        .setting-separator {
            height: 1px;
            background: rgba(255, 126, 95, 0.2);
            margin: 20px 0;
        }

        .setting-label {
            color: #fff;
            font-size: 20px;
            font-weight: 600;
            text-align: left;
            margin-bottom: 5px;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
        }

        .setting-controls {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 20px;
        }

        .value-controls {
            display: flex;
            align-items: center;
            gap: 20px;
        }

        .control-btn {
            background: rgba(80, 80, 80, 0.6);
            border: 2px solid rgba(255, 126, 95, 0.2);
            border-radius: 10px;
            padding: 12px 18px;
            color: #fff;
            cursor: pointer;
            font-size: 18px;
            font-weight: 600;
            transition: all 0.3s ease;
            min-width: 50px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }

        .control-btn:hover {
            background: rgba(100, 100, 100, 0.7);
            border-color: #ff7e5f;
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(255, 126, 95, 0.2);
        }

        .control-btn:active {
            transform: translateY(0);
        }

        .control-value {
            color: #ff7e5f;
            font-size: 22px;
            font-weight: 700;
            min-width: 65px;
            text-align: center;
            background: rgba(255, 126, 95, 0.1);
            padding: 8px 12px;
            border-radius: 8px;
            border: 1px solid rgba(255, 126, 95, 0.2);
        }
        
        /* Remove number input arrows */
        .control-value::-webkit-outer-spin-button,
        .control-value::-webkit-inner-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }
        
        .control-value[type=number] {
            -moz-appearance: textfield;
        }

        .toggle-switch {
            position: relative;
            width: 65px;
            height: 32px;
            background: rgba(80, 80, 80, 0.6);
            border-radius: 16px;
            cursor: pointer;
            transition: all 0.3s ease;
            border: 2px solid rgba(255, 126, 95, 0.2);
            box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
        }

        .toggle-switch.active {
            background: linear-gradient(135deg, #ff7e5f, #e56a4a);
            border-color: #ff7e5f;
            box-shadow: 0 0 20px rgba(255, 126, 95, 0.3);
        }

        .toggle-slider {
            position: absolute;
            top: 2px;
            left: 2px;
            width: 24px;
            height: 24px;
            background: white;
            border-radius: 50%;
            transition: all 0.3s ease;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
        }

        .toggle-switch.active .toggle-slider {
            transform: translateX(31px);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
        }





        /* Ghost Progress Indicator */
        .ghost-progress {
            background: rgba(40, 40, 40, 0.9);
            padding: 15px 20px;
            border-radius: 10px;
            margin: 20px auto;
            max-width: 600px;
            text-align: center;
            border: 1px solid rgba(76, 175, 80, 0.3);
        }

        .ghost-status {
            color: #4CAF50;
            font-size: 16px;
            font-weight: 600;
            margin-bottom: 10px;
        }

        .ghost-bar {
            width: 100%;
            height: 12px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 6px;
            position: relative;
            overflow: hidden;
        }

        .ghost-fill {
            height: 100%;
            background: linear-gradient(90deg, #ff7e5f, #e56a4a);
            border-radius: 6px;
            transition: width 0.3s ease;
            position: relative;
        }

        .ghost-target {
            position: absolute;
            top: 0;
            width: 3px;
            height: 100%;
            background: #ff7e5f;
            border-radius: 2px;
            box-shadow: 0 0 8px rgba(255, 126, 95, 0.6);
        }

        .ghost-fill.behind {
            background: linear-gradient(90deg, #ff9800, #ffb74d);
        }

        .ghost-status.behind {
            color: #ff9800;
        }
