:root {
    /* Light theme (default) */
    --bg-color: #f5f5f5;
    --text-color: #333;
    --card-front-bg: #e9f7ef;
    --card-back-bg: #eaf2f8;
    --settings-bg: white;
    --border-color: #ccc;
    --button-bg: #4CAF50;
    --button-hover-bg: #45a049;
    --button-text: white;
    --timer-color-1: #4CAF50;
    --timer-color-2: #ddd;
    --timer-icon-bg: white;
}

@media (prefers-color-scheme: dark) {
    :root.system-theme {
        /* Dark theme */
        --bg-color: #222;
        --text-color: #eee;
        --card-front-bg: #2c3e50;
        --card-back-bg: #34495e;
        --settings-bg: #333;
        --border-color: #555;
        --button-bg: #222;
        --button-hover-bg: #27ae60;
        --button-text: white;
        --timer-color-1: #2ecc71;
        --timer-color-2: #555;
        --timer-icon-bg: #333;
    }
}

:root.dark-theme {
    /* Dark theme */
    --bg-color: #222;
    --text-color: #eee;
    --card-front-bg: #2c3e50;
    --card-back-bg: #34495e;
    --settings-bg: #333;
    --border-color: #555;
    --button-bg: #2ecc71;
    --button-hover-bg: #27ae60;
    --button-text: white;
    --timer-color-1: #2ecc71;
    --timer-color-2: #555;
    --timer-icon-bg: #333;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    max-height: 800px;
    position: relative;
    overflow: hidden;
}

.controls-top {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 15px;
    z-index: 10;
}

.settings-toggle, .fullscreen-toggle {
    font-size: 24px;
    cursor: pointer;
}

.fullscreen-toggle {
    transition: transform 0.3s ease;
}

.fullscreen-toggle.active {
    transform: rotate(180deg);
}

.settings-panel {
    position: absolute;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100%;
    background-color: var(--settings-bg);
    padding: 20px;
    transition: right 0.3s ease, background-color 0.3s ease;
    z-index: 5;
}

.settings-panel.active {
    right: 0;
}

.setting {
    margin-bottom: 15px;
    transition: opacity 0.3s ease;
}

.setting label {
    display: block;
    margin-bottom: 5px;
}

.setting select, .setting input[type="number"] {
    width: 100%;
    padding: 8px;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
}

.checkbox-item input[type="checkbox"] {
    margin-right: 8px;
}

.checkbox-item label {
    margin-bottom: 0;
}

.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 15px;
    border-radius: 10px;
    background: var(--border-color);
    outline: none;
    margin-top: 10px;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: var(--button-bg);
    cursor: pointer;
    transition: background 0.3s ease;
}

.slider::-moz-range-thumb {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: var(--button-bg);
    cursor: pointer;
    transition: background 0.3s ease;
    border: none;
}

.slider::-webkit-slider-thumb:hover,
.slider::-moz-range-thumb:hover {
    background: var(--button-hover-bg);
}

button {
    padding: 8px 16px;
    background-color: var(--button-bg);
    color: var(--button-text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: var(--button-hover-bg);
}

.flashcard {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card-front, .card-back {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    font-size: 96px;
    text-align: center;
    word-wrap: break-word;
    overflow: hidden;
}

.card-front {
    background-color: var(--card-front-bg);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s ease;
}

.card-back {
    background-color: var(--card-back-bg);
    transform: translateY(100%);
    transition: transform 0.5s ease, background-color 0.3s ease;
}

.card-back.revealed {
    transform: translateY(0);
}

.timer {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: 4px solid var(--timer-color-1);
    border-top: 4px solid transparent;
    border-right: 4px solid var(--timer-color-1);
    border-bottom: 4px solid var(--timer-color-1);
    border-left: 4px solid var(--timer-color-1);
    -webkit-animation: spin calc(var(--duration) * 1s) linear infinite;
    animation: spin calc(var(--duration) * 1s) linear infinite;
    -webkit-animation-play-state: running;
    animation-play-state: running;
    cursor: pointer;
}

.timer.paused {
    -webkit-animation-play-state: paused;
    animation-play-state: paused;
}

.timer-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background-color: var(--timer-icon-bg);
    border-radius: 50%;
    z-index: 2;
    opacity: 1;
    transition: background-color 0.3s ease, background-image 0.2s ease;
    background-image: url('pause.svg');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    /* Counter-rotate to stay still while parent rotates */
    animation: counter-spin calc(var(--duration) * 1s) linear infinite;
    animation-play-state: running;
}

.timer.paused .timer-icon {
    background-image: url('play.svg');
    animation-play-state: paused;
}

@-webkit-keyframes spin {
    0% { -webkit-transform: translateX(-50%) rotate(0deg); }
    100% { -webkit-transform: translateX(-50%) rotate(360deg); }
}

@keyframes spin {
    0% { transform: translateX(-50%) rotate(0deg); }
    100% { transform: translateX(-50%) rotate(360deg); }
}

@keyframes counter-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(-360deg); }
}
