 body {
            background-color: #121212;
            color: #ffffff;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
            min-height: 100vh;
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            overflow-x: hidden;
        }

        body, #timer {
            cursor: pointer; 
        }
 
        body.no-scroll {
            overflow: hidden !important;
            touch-action: none !important; 
        }

        body.solving-mode header,
        body.solving-mode .scramble-section,
        body.solving-mode .hint,
        body.solving-mode .stats-container,
        body.solving-mode #times-container,
        body.solving-mode footer {
            display: none !important;
        }

        body.solving-mode {
            justify-content: center; 
        }


        body.solving-mode #timer {
            font-size: 10vw; 
        }


        @media (max-width: 600px) {
            body.solving-mode #timer { font-size: 25vw; }
        }
        /* ------------------------------------------------------ */

        header {
            width: 100%;
            background-color: #0f141e;
            padding: 1rem 2rem;
            box-sizing: border-box;
            border-bottom: 1px solid #1e293b;
            margin-bottom: 2rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 1rem;
        }
        header, 
        .scramble-section, 
        .stats-container, 
        #times-container, 
        footer, 
        .hint {
            cursor: default; 
        }

        .header-title {
            font-size: 1.2rem;
            font-weight: bold;
            color: #ffffff;
            margin: 0;
            letter-spacing: 0.5px;
            white-space: nowrap;
        }

        .header-controls {
            display: flex;
            gap: 1rem;
            align-items: center;
            flex-wrap: wrap;
            justify-content: flex-end;
        }

        select {
            background: #1a1a1a;
            color: #fff;
            border: 1px solid #444;
            padding: 0.5rem;
            border-radius: 4px;
            font-family: inherit;
        }

        .toggle-container {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-size: 0.9rem;
            color: #aaa;
            white-space: nowrap;
        }

        .scramble-section {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 100%;
            max-width: 900px;
            padding: 0 1rem;
            box-sizing: border-box;
        }

        .scramble-label {
            font-size: 0.9rem;
            color: #888;
            text-transform: uppercase;
            letter-spacing: 2px;
            margin-bottom: 0.5rem;
        }

        .scramble-container {
            display: flex;
            align-items: center;
            gap: 1rem;
            width: 100%;
            justify-content: center;
        }

        #scramble {
            font-size: 1.5rem;
            letter-spacing: 2px;
            text-align: center;
            color: #4da6ff;
            line-height: 1.4;
            flex-grow: 1;
        }

        button {
            background: #2a2a2a;
            color: #fff;
            border: 1px solid #444;
            padding: 0.5rem 1rem;
            border-radius: 4px;
            cursor: pointer;
            font-family: inherit;
            transition: background 0.2s, border-color 0.2s;
            white-space: nowrap;
        }

        button, 
        select, 
        #scramble-hint-icon {
            cursor: pointer;
        }

        button:hover { background: #3a3a3a; }
        button:disabled { background: #1a1a1a; color: #555; cursor: not-allowed; border-color: #222; }

        .btn-danger:hover { background: #4a1a1a; border-color: #ff5252; color: #ffdddd; }

        .scramble-label-container {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            margin-bottom: 0.5rem;
        }

        .hint-wrapper {
            position: relative;
            display: inline-flex;
            align-items: center;
        }

        #scramble-hint-icon {
            cursor: pointer;
            color: #888;
            font-size: 1.1rem;
            transition: color 0.2s;
            user-select: none;
        }

        #scramble-hint-icon:hover {
            color: #fff;
        }

        #scramble-hint-popup {
            display: none; /* Hidden by default */
            position: absolute;
            bottom: 150%;
            left: 50%;
            transform: translateX(-50%);
            background: #1a1a1a;
            color: #ccc;
            padding: 0.75rem;
            border: 1px solid #444;
            border-radius: 6px;
            font-size: 0.8rem;
            width: max-content;
            max-width: 220px;
            text-align: center;
            box-shadow: 0 4px 12px rgba(0,0,0,0.6);
            z-index: 100;
            line-height: 1.4;
            text-transform: none;
            letter-spacing: normal;
        }

        #scramble-hint-popup::before {
            content: '';
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            border-width: 6px;
            border-style: solid;
            border-color: #444 transparent transparent transparent;
        }
        #scramble-hint-popup::after {
            content: '';
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            border-width: 5px;
            border-style: solid;
            border-color: #1a1a1a transparent transparent transparent;
        }

        #scramble-hint-popup.show {
            display: block;
        }



        #scramble-draw {
        display: none; 
        
   
        position: absolute; 
        right: 2rem; 
        top: 6rem; 
        z-index: 10;
        
  
        background: #1a1a1a;
        padding: 1rem;
        border: 1px solid #444;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
        
   
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: 3px;
        width: 325px; 
        
  
        opacity: 0.7; 
        transition: opacity 0.3s ease, transform 0.3s ease;
        }

        #scramble-draw:hover {
            opacity: 1; 
            transform: scale(1.05); 
        }

        .cube-face {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            grid-template-rows: repeat(3, 1fr);
            gap: 1.5px; 
            background: #111; 
            border: 1px solid #111;
            border-radius: 4px; 
            overflow: hidden; 
            aspect-ratio: 1; 
        }

        .sticker {
            background: white;
            border-radius: 1px; 
        }

  
        #face-U { grid-column: 2; grid-row: 1; }
        #face-L { grid-column: 1; grid-row: 2; }
        #face-F { grid-column: 2; grid-row: 2; }
        #face-R { grid-column: 3; grid-row: 2; }
        #face-B { grid-column: 4; grid-row: 2; }
        #face-D { grid-column: 2; grid-row: 3; }

  
        @media (max-width: 1000px) {

            #btn-toggle-draw.show-on-mobile {
                display: inline-block;
                margin: 1rem;
            }
            
            #scramble-draw {
                position: inherit;
                right: inherit;
                top: auto;
                margin: 0.5rem auto 7px auto;
                width: 280px;
            }
        }

        #btn-toggle-draw {
            display: none; 
            margin-top: 1rem;
            background: transparent;
            border: 1px solid #444;
            color: #aaa;
            font-size: 0.8rem;
            padding: 0.4rem 0.8rem;
            border-radius: 4px;
            cursor: pointer;
            transition: background 0.2s;
        }

        #btn-toggle-draw:hover {
            background: #2a2a2a;
            color: #fff;
        }

   
        #scramble-draw.force-hide {
            display: none !important;
        }


        #timer {
            font-size: clamp(5rem, 15vw, 10rem); 
            font-weight: bold;
            font-variant-numeric: tabular-nums;
            margin-bottom: 0.5rem;
            transition: color 0.1s;
            text-align: center;
            width: 100%;
            padding: 0 1rem;
            box-sizing: border-box;
        }


        .ready { color: #00e676 !important; }
        .waiting { color: #ff9800 !important; }
        .stopped { color: #51ff00 !important; }
        .inspecting { color: #fdd835 !important; }

        .main-time-gap {
            font-size: 0.35em; 
            margin-left: 2%; 
            vertical-align: baseline; 
            font-weight: normal;
        }
        .main-time-gap.plus { color: #ff5252; } 
        .main-time-gap.minus { color: #00e676; } 

        .hint {
            color: #666;
            margin-bottom: 2rem;
            text-align: center;
            padding: 0 1rem;
            font-size: 0.9rem;
            line-height: 1.5;
        }

        .stats-container {
            display: flex;
            gap: 1.5rem;
            margin-bottom: 2rem;
            background: #1a1a1a;
            padding: 1.5rem;
            border-radius: 8px;
            border: 1px solid #333;
            flex-wrap: wrap;
            justify-content: center;
            width: 90%;
            max-width: 900px;
            box-sizing: border-box;
        }

        .stat-box {
            text-align: center;
            min-width: 100px;
            flex: 1 1 auto;
        }

        .stat-best-box {
            border-left: 1px solid #333;
            padding-left: 1.5rem;
        }

        .stat-label {
            font-size: 0.75rem;
            color: #aaa;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .stat-value {
            font-size: 1.6rem;
            font-weight: bold;
            color: #00e676;
        }

        #times-container {
            width: 90%;
            max-width: 800px;
            background: #1e1e1e;
            border-radius: 8px;
            padding: 1.5rem;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            margin-bottom: 2rem;
        }

        .history-controls {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem;
            border-bottom: 1px solid #333;
            padding-bottom: 1rem;
            gap: 1rem;
            flex-wrap: wrap;
        }

        .history-buttons {
            display: flex;
            gap: 0.5rem;
            flex-wrap: wrap;
        }

        #times-list {
            list-style: none;
            padding: 0;
            margin: 0;
            max-height: 400px;
            overflow-y: auto;
        }

        #times-list li {
            display: flex;
            flex-direction: column;
            padding: 0.75rem 0;
            border-bottom: 1px solid #333;
        }

        .solve-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 1.2rem;
            margin-bottom: 0.5rem;
            gap: 1rem;
            flex-wrap: wrap;
        }

        .solve-info {
            display: flex;
            align-items: center;
            flex-wrap: wrap; 
            gap: 0.5rem;
        }

        .solve-time {
            color: #fff;
            font-weight: bold;
        }

        .solve-time.plus-two { color: #fdd835; }
        .solve-time.dnf { color: #ff5252; text-decoration: line-through; }

        .time-gap {
            font-size: 0.9rem;
            font-weight: bold;
        }
        
        .time-gap.plus { color: #ff5252; } 
        .time-gap.minus { color: #00e676; } 

        .penalty-controls {
            display: flex;
            gap: 0.5rem;
        }

        .btn-penalty {
            padding: 0.3rem 0.6rem;
            font-size: 0.8rem;
            border-radius: 3px;
            background: transparent;
            color: #888;
            border: 1px solid #444;
        }
        
        .btn-penalty.active {
            background: #444;
            color: #fff;
            border-color: #666;
        }

        .solve-scramble {
            font-size: 0.8rem;
            color: #666;
            word-break: break-all;
            margin-top: 0.2rem;
            line-height: 1.3;
        }

        footer {
            margin-top: auto;
            padding: 2rem;
            color: #666;
            font-size: 0.85rem;
            text-align: center;
            letter-spacing: 1px;
        }

  
        @media (max-width: 768px) {
            header {
                flex-direction: column;
                padding: 1rem;
                text-align: center;
            }

            .header-controls {
                justify-content: center;
                width: 100%;
            }

            select {
                flex-grow: 1; 
            }

            #scramble {
                font-size: 1.2rem;
            }

            .stats-container {
                gap: 1rem;
                padding: 1rem;
            }

            .stat-box {
                min-width: 40%;
            }

       
            .stat-best-box {
                border-left: none;
                padding-left: 0;
                border-top: 1px solid #333;
                padding-top: 1rem;
                width: 100%; 
            }

            #times-container {
                padding: 1rem;
            }

            .history-controls {
                flex-direction: column;
                align-items: flex-start;
            }

            .history-buttons {
                width: 100%;
                justify-content: space-between;
            }
            
            .history-buttons button {
                flex-grow: 1; 
            }

            .solve-header {
                flex-direction: column;
                align-items: flex-start;
            }

            .penalty-controls {
                width: 50%;
                justify-content: flex-end; 
            }
        }