:root {
    --bg-color: #f5f7fa;
    --panel-bg: #ffffff;
    --text-color: #333;
    --primary-color: #3b82f6;
    --hover-bg: #eef2f7;
}

[data-theme="dark"] {
    --bg-color: #1f2937;
    --panel-bg: #2d3748;
    --text-color: #f5f5f5;
    --primary-color: #60a5fa;
    --hover-bg: #374151;
}

body {
    display: flex;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    background: var(--bg-color);
    color: var(--text-color);
    transition: background 0.3s, color 0.3s;
}

.records {
    width: 20vw;
    height: 90vh;
    margin-right: 20px;
    background: var(--panel-bg);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 20px;
    overflow-y: auto;
    transition: background 0.3s;
}

.records h2 {
    font-size: 1.3em;
    margin-bottom: 15px;
    color: var(--text-color);
}

.records p {
    font-size: 1em;
    margin: 8px 0;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

.records p:hover {
    background: var(--hover-bg);
    cursor: pointer;
}

.mainmenu {
    flex: 1;
    background: var(--panel-bg);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    transition: background 0.3s;
}

.mainmenu h1, .mainmenu h3 {
    color: var(--text-color);
}

select {
    padding: 10px 14px;
    font-size: 1em;
    border-radius: 8px;
    border: 1px solid #ccc;
    margin-bottom: 20px;
    outline: none;
    transition: border 0.2s, box-shadow 0.2s;
}

select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

button {
    padding: 10px 20px;
    font-size: 1em;
    margin: 5px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    background: var(--primary-color);
    color: white;
    transition: background 0.2s, transform 0.1s;
}

button:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

#main {
    font-size: 2em;
    font-family: 'Courier New', Courier, monospace;
    margin-top: 30px;
    word-break: break-word;
    color: var(--text-color);
}

.records::-webkit-scrollbar {
    width: 8px;
}

.records::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.records::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.records::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

#darkModeToggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    background: var(--panel-bg);
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    transition: background 0.3s, transform 0.2s;
}

[data-theme="light"] #darkModeToggle {
    background: #3e4753;
    color: #f5f5f5;
}

[data-theme="dark"] #darkModeToggle {
    background: #9da3ad;
    color: #1f2937;
}

#darkModeToggle:hover {
    transform: scale(1.1);
}

#themeIcon {
    pointer-events: none;
}
.mobileControls {
    margin-top: 150px;
    width: 100%;
    display: flex;
    flex-direction: column; 
    text-align: center;
    gap: 10px;
}

.mobileControls div {
    display: flex;
    justify-content: center;
    gap: 10px;
}
.mobileControls button {
    height: 100px;
    width: 150px;
    font-size: 20px;
}

.mobileControls p {
    margin: 0;
    color: var(--text-color);
    font-size: 28px;
    justify-content: center;
    align-self: center;
}

#solution, #difficulty {
    white-space: pre-wrap;     /* preserves spaces and allows line breaks */
    word-break: break-word;    /* breaks long sequences */
    overflow-wrap: break-word; /* ensures wrapping in older browsers */
    text-align: center;        /* optional: center the text */
    max-width: 100%;           /* prevents horizontal overflow */
}


#label1 {
    color: var(--text-color);
}
@media (max-width: 1200px) {
    body {
        flex-direction: column; /* stack vertically */
        padding: 10px;
    }

    .mainmenu {
        width: 100%;
        order: 1; /* appear first */
        padding: 20px;
    }

    .records {
        width: 100%;
        height: auto;
        margin: 0;
        order: 2; /* appear after main menu */
        margin-top: 20px;
    }
}

@media (max-width: 650px) {
    .mainmenu {
        padding: 15px;  /* smaller padding */
    }

    .mainmenu h1 {
        font-size: 1.8em; /* scale down the title */
    }

    .mainmenu h3.label1 {
        font-size: 1em; /* smaller label */
        text-align: center;
    }

    select {
        width: 100%; /* full-width dropdown */
        font-size: 0.9em;
    }

    button {
        width: 100%; /* stack buttons vertically */
        font-size: 0.9em;
        margin: 5px 0;
    }

    #main {
        font-size: 1.5em; /* smaller main string */
        word-break: break-word;
        text-align: center;
    }

    .mobileControls {
        margin-top: 20px;
        gap: 8px;
    }

    .mobileControls div {
        flex-direction: column; /* stack buttons vertically */
        gap: 5px;
    }

    .mobileControls button {
        width: 100%;  /* buttons take full width */
        height: 60px;
        font-size: 16px;
    }

    .mobileControls p {
        font-size: 20px;
    }
}


