:root {
    --primary-color: #242739;
    --accent-color: #f29718;
    --secondary-color: #5fb3ff;
    --success-color: #72c891;
    --warning-color: #ffb454;
    --error-color: #ff5370;
    --text-color: #bfbdb6;
    --background-color: #1e1e2e;
    --card-background: #2d3142;
    --border-color: #414e5e;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

body {
    font-family: "Arial", sans-serif;
    background: var(--background-color);
    color: var(--text-color);
    position: fixed;
    width: 100%;
}

#app {
    position: relative;
    width: 100vw;
    height: 100vh;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
    padding: 8px;
    box-sizing: border-box;
    overflow-y: hidden;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    scroll-behavior: smooth;
}

.screen.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
}

.screen.overlay.active {
    opacity: 1;
    visibility: visible;
    background: rgba(0, 0, 0, 0.8);
}

.container {
    background: var(--background-color);
    padding: 20px;
    text-align: center;
    width: 100vw;
    height: 100vh;
    margin: 0;
    overflow-y: auto;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.game-title {
    background: var(--card-background);
    color: var(--accent-color);
    border-radius: 16px;
    margin: 0;
    border: 2px solid var(--border-color);
}

.game-description {
    font-size: 0.9rem;
    color: var(--text-color);
    margin-bottom: 16px;
    line-height: 1.4;
    padding: 0;
}

.category-selection {
    margin-bottom: 16px;
}

.category-selection h2 {
    color: var(--text-color);
    margin-bottom: 12px;
    font-size: 1.3rem;
    font-weight: 600;
}

.categories.all-categories {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

/* Style for main welcome screen categories (6 categories) */
.categories {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 32px;
}

/* Style for all categories screen (8 categories) */
.all-categories {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.category-btn {
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-color);
    font-weight: 600;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.category-btn:hover {
    background: var(--primary-color);
    color: var(--accent-color);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(242, 151, 24, 0.3);
    border-color: var(--accent-color);
}

.category-btn.selected {
    background: var(--primary-color);
    color: var(--accent-color);
    border-color: var(--accent-color);
    box-shadow: 0 8px 25px rgba(242, 151, 24, 0.4);
    transform: translateY(-2px);
}

.view-all-btn {
    background: var(--secondary-color);
    color: var(--primary-color);
    border: none;
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 8px;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.2);
}

.view-all-btn:hover {
    background: var(--accent-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(95, 179, 255, 0.3);
}

.game-settings label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: var(--text-color);
    font-size: 1.1rem;
}

.game-settings select {
    width: 100%;
    padding: 8px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1.1rem;
    background: var(--card-background);
    color: var(--text-color);
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.game-settings select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(242, 151, 24, 0.1);
    outline: none;
}

.radio-group {
    display: flex;
    flex-direction: row;
    gap: 12px;
    margin-bottom: 12px;
    justify-content: center;
}

.radio-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--card-background);
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 500;
    min-width: 60px;
}

.radio-label:hover {
    background: var(--primary-color);
    border-color: var(--accent-color);
}

.radio-label input[type="radio"] {
    margin-right: 8px;
    accent-color: var(--accent-color);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.radio-label input[type="radio"]:checked + span {
    color: var(--accent-color);
    font-weight: 600;
}

.radio-label:has(input[type="radio"]:checked) {
    background: var(--primary-color);
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(242, 151, 24, 0.1);
}

.word-variation {
    margin-top: 24px;
    text-align: left;
    padding: 8px 16px;
}

.word-variation label {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 8px;
    border-radius: 8px;
    background: var(--card-background);
    color: var(--text-color);
}

.word-variation label:hover {
    background: var(--primary-color);
    color: var(--accent-color);
}

.word-variation input[type="checkbox"] {
    margin-right: 8px;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

.randomization-info {
    background: var(--card-background);
    border-radius: 16px;
    padding: 16px;
    margin: 24px 0;
    font-size: 1rem;
    color: var(--text-color);
    border-left: 8px solid var(--accent-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.randomization-mode-description {
    font-size: 0.8rem;
    color: var(--text-color);
    opacity: 0.7;
    margin-top: 0.25rem;
    font-style: italic;
}

#randomization-description {
    margin: 8px 0;
    font-size: 0.8rem;
    color: var(--accent-color);
    font-weight: 500;
}

.randomization-stats {
    margin-top: 8px;
    color: var(--text-color);
    opacity: 0.8;
}

.randomization-stats small {
    font-size: 0.75rem;
}

#word-count {
    font-weight: bold;
    color: var(--accent-color);
}

.start-btn {
    background: var(--accent-color);
    color: var(--primary-color);
    border: none;
    border-radius: 16px;
    padding: 12px 16px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 12px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    letter-spacing: 0.5px;
}

.start-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(242, 151, 24, 0.4);
    background: var(--secondary-color);
}

.start-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.secondary-btn {
    background: var(--card-background);
    color: var(--text-color);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 10px 16px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 12px;
    width: 100%;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.2);
}

.secondary-btn:hover {
    background: var(--primary-color);
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(242, 151, 24, 0.3);
}

/* Game Screen Styles */
#game-screen {
    align-items: center;
    padding: 4px 0;
}

.game-container {
    background: var(--background-color);
    padding: 20px;
    text-align: center;
    width: 100vw;
    height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-sizing: border-box;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 12px;
}

.timer,
.score,
.word-progress {
    color: var(--text-color);
    font-size: 1.2rem;
    font-weight: bold;
}

.word-progress {
    font-size: 0.8rem;
    opacity: 0.8;
}

.card-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
}

.game-card {
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 280px;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transform: rotate(0deg);
    transition: all 0.3s ease;
}

.card-content {
    text-align: center;
    padding: 16px 12px;
}

.card-content span {
    font-size: 1.6rem;
    font-weight: bold;
    color: var(--text-color);
    word-wrap: break-word;
    line-height: 1.2;
}

.game-instructions {
    text-align: center;
    color: var(--text-color);
    padding: 8px;
    font-size: 0.9rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin: 8px 0;
}

.game-instructions p {
    margin: 4px 0;
}

.game-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 0;
}

.control-btn {
    flex: 1;
    padding: 12px 8px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-color);
    background: var(--card-background);
    min-height: 56px;
}

.control-btn.correct {
    background: var(--success-color);
    color: var(--primary-color);
    border-color: var(--success-color);
}

.control-btn.correct:hover {
    background: var(--success-color);
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(114, 200, 145, 0.4);
}

.control-btn.skip {
    background: var(--warning-color);
    color: var(--primary-color);
    border-color: var(--warning-color);
}

.control-btn.skip:hover {
    background: var(--warning-color);
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 180, 84, 0.4);
}

.control-btn.pause {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    color: #333;
}

.control-btn.pause:hover {
    background: var(--secondary-color);
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(95, 179, 255, 0.4);
}

/* Results Screen */
.final-score {
    margin: 12px 0;
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.final-score h2 {
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 4px;
}

.results-breakdown {
    display: none;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 16px 0;
}

.stat {
    text-align: center;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    border-color: var(--accent-color);
}

.stat-label {
    display: block;
    font-weight: 600;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 4px;
    font-size: 0.8rem;
}

.stat span:last-child {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--text-color);
}

.word-stats {
    display: none;
    margin: 16px 0;
    text-align: center;
}

.quick-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--primary-color);
    border: 2px solid var(--accent-color);
    border-radius: 12px;
    padding: 12px;
    margin: 12px 0;
    box-shadow: 0 4px 15px rgba(242, 151, 24, 0.2);
}

.stat-item {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    color: var(--text-color);
    padding: 8px;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.stat-number {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--accent-color);
    margin-bottom: 4px;
}

.stat-desc {
    font-size: 0.9rem;
    color: var(--text-color);
    margin-top: 4px;
    font-weight: 500;
}

.word-review {
    margin: 16px 0;
    text-align: left;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.word-section {
    display: flex;
    flex-direction: column;
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.word-section h3 {
    color: var(--text-color);
    margin-bottom: 0;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 8px;
    border-radius: 0;
    background: var(--primary-color);
}

.word-section:first-child h3 {
    background: var(--success-color);
    color: var(--primary-color);
}

.word-section:last-child h3 {
    background: var(--warning-color);
    color: var(--primary-color);
}

.word-section ul {
    list-style: none;
    max-height: 120px;
    overflow-y: auto;
    background: var(--background-color);
    border-radius: 0;
    padding: 8px;
    flex: 1;
    margin: 0;
}

.word-section:first-child ul {
    border-left: 6px solid var(--success-color);
}

.word-section:last-child ul {
    border-left: 6px solid var(--warning-color);
}

.word-section li {
    padding: 6px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    transition: all 0.3s ease;
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    background: var(--card-background);
    color: var(--text-color);
}

.word-section li:hover {
    background: var(--primary-color);
    transform: translateX(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.word-section li:last-child {
    border-bottom: none;
}

.word-section:first-child li::before {
    content: "✓";
    color: var(--success-color);
    font-weight: bold;
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

.word-section:last-child li::before {
    content: "⏭";
    color: var(--warning-color);
    font-weight: bold;
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

.word-section li.empty-state {
    text-align: center;
    opacity: 0.6;
    cursor: default;
}

.word-section li.empty-state:hover {
    background: transparent;
    transform: none;
}

.word-text {
    font-weight: 500;
    color: var(--text-color);
}

.category-badge {
    background: var(--accent-color);
    color: var(--primary-color);
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    margin-left: 0.5rem;
    font-weight: bold;
    text-transform: capitalize;
    opacity: 0.9;
}

.word-section:first-child .category-badge {
    background: var(--success-color);
}

.word-section:last-child .category-badge {
    background: var(--warning-color);
}

.correct-word:hover .word-text {
    color: var(--success-color);
}

.skipped-word:hover .word-text {
    color: var(--warning-color);
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 0;
}

/* Pause Screen */
.pause-container {
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 24px 16px;
    text-align: center;
    max-width: 350px;
    width: 95%;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    transform: scale(0.8) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0;
}

.screen.overlay.active .pause-container {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.pause-container h2 {
    color: var(--accent-color);
    margin-bottom: 16px;
    font-size: 1.8rem;
    font-weight: 700;
}

/* Animations */
@keyframes cardFlip {
    0% {
        transform: rotateY(0deg);
    }
    50% {
        transform: rotateY(90deg);
    }
    100% {
        transform: rotateY(0deg);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes countdown-pulse {
    0% {
        transform: scale(1);
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    }
    50% {
        transform: scale(1.15);
        text-shadow: 0 0 10px rgba(242, 151, 24, 0.8);
    }
    100% {
        transform: scale(1);
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    }
}

@keyframes urgent-glow {
    0% {
        box-shadow: 0 0 20px rgba(255, 83, 112, 0.3);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 83, 112, 0.7);
    }
    100% {
        box-shadow: 0 0 20px rgba(255, 83, 112, 0.3);
    }
}

@keyframes timer-warning {
    0% {
        background-color: rgba(255, 83, 112, 0.1);
    }
    50% {
        background-color: rgba(255, 83, 112, 0.3);
    }
    100% {
        background-color: rgba(255, 83, 112, 0.1);
    }
}

.game-card.flipping {
    animation: cardFlip 0.6s ease-in-out;
}

.game-card.correct {
    background: var(--success-color);
    border: 3px solid var(--success-color);
    color: var(--primary-color);
}

.game-card.skip {
    background: var(--warning-color);
    border: 3px solid var(--warning-color);
    color: var(--primary-color);
}

/* Countdown urgency effects */
.timer.urgent {
    animation: timer-warning 1s infinite;
    border-radius: 10px;
    padding: 0.5rem;
    background: var(--error-color);
    color: var(--primary-color);
}

.game-card.countdown-urgent {
    animation: urgent-glow 0.5s infinite;
    border-color: var(--error-color);
}

/* Settings Screen */
/* Settings */
.settings-section {
    margin: 24px 0;
    padding: 20px;
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.settings-section h2 {
    color: var(--text-color);
    margin-bottom: 12px;
    font-size: 1.3rem;
    font-weight: 600;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
