/* Learn2Win - Complete CSS with All Fixes */

/* CSS Variables for consistency */
:root {
    --success-green: #00ff88;
    --error-red: #ff4444;
    --warning-orange: #ffa500;
    --ghost-orange: #ff6b35;
    --primary-gradient: linear-gradient(45deg, #00ff88, #00ffff);
    --title-blue: #00a3ff;
    --title-blue-light: #4db8ff;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    background-color: #121212;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #1f1f1f 0%, #121212 50%, #1f1f1f 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    color: white;
    min-height: 100vh;
    padding: 10px;
    overflow-x: hidden;
}

/* Body scroll lock when modals are open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding-bottom: 20px;
}

/* Header */
.header {
    text-align: center;
    padding: 20px 0;
}

/* Game Title with Blue Shining Effect */
.game-title {
    font-size: clamp(1.5em, 5vw, 2.5em);
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    background: linear-gradient(45deg, var(--title-blue), var(--title-blue-light), var(--title-blue));
    background-size: 200% 200%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    position: relative;
    animation: titleShine 3s ease-in-out infinite;
}

@keyframes titleShine {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Add a glow effect to the title */
.game-title::before {
    content: '🖥️ Learn2Win';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, var(--title-blue), var(--title-blue-light));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: blur(15px);
    opacity: 0.5;
    z-index: -1;
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

.header p {
    font-size: clamp(0.8em, 2vw, 0.9em);
    opacity: 0.9;
}

/* Glass card effect */
.glass-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 20px;
    margin-bottom: 20px;
}

/* Game Board - Responsive */
.board-container {
    display: flex;
    justify-content: center;
    margin: 20px auto;
    position: relative;
    width: 100%;
    max-width: 600px;
    aspect-ratio: 1;
}

.game-board {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 20px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
    border: 3px solid rgba(255,255,255,0.3);
}

.board-space {
    position: absolute;
    /* Use min() to ensure spaces get smaller on smaller screens */
    width: min(8%, 48px);
    height: min(8%, 48px);
    border-radius: 8px;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.4em, 1.2vw, 0.6em);
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-align: center;
    line-height: 1.1;
    padding: 2px;
    box-sizing: border-box;
}

.board-space:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

/* Improve board space touch targets on mobile */
@media (max-width: 768px) {
    .board-space {
        width: min(8%, 45px);  /* CHANGED: Same 8% but max 45px instead of 40px */
        height: min(8%, 45px);
        font-size: 0;  /* Hide text on smaller screens */
        border-width: 1.5px;
        padding: 0;
    }
    
    .board-space.corner-space {
        font-size: clamp(0.8em, 2vw, 1.2em);
    }
}

/* Special space types - FIXED: Reduced pulsing */
.board-space.corner-space {
    /* Inherit size from .board-space */
    background: #FF6F61;
    border-color: #FF6F61;
    font-size: clamp(1.2em, 3vw, 1.8em);
    font-weight: 900;
    box-shadow: 
        0 0 15px rgba(255, 111, 97, 0.6),
        inset 0 0 15px rgba(255, 255, 255, 0.2);
    background-image: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.3) 0%, 
        transparent 50%, 
        rgba(0, 0, 0, 0.05) 100%);
    overflow: hidden;
    z-index: 2;
    animation: pulseGlowSubtle 3s ease-in-out infinite;
}

/* Subtler pulse animation */
@keyframes pulseGlowSubtle {
    0%, 100% { 
        box-shadow: 
            0 0 15px rgba(255, 111, 97, 0.6),
            inset 0 0 15px rgba(255, 255, 255, 0.2);
    }
    50% { 
        box-shadow: 
            0 0 20px rgba(255, 111, 97, 0.8),
            inset 0 0 18px rgba(255, 255, 255, 0.25);
    }
}

.board-space.corner-space::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, 
        transparent 30%, 
        rgba(255, 255, 255, 0.5) 50%, 
        transparent 70%);
    transform: rotate(45deg);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.board-space.corner-space:hover {
    transform: scale(1.1);
    box-shadow: 
        0 0 30px rgba(255, 111, 97, 1),
        inset 0 0 30px rgba(255, 255, 255, 0.4);
}

/* Player Pieces */
.player-piece {
    position: absolute;
    width: min(4%, 24px);
    height: min(4%, 24px);
    min-width: 20px;
    min-height: 20px;
    border-radius: 50%;
    border: 3px solid white;
    transition: all 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(10px, 2vw, 12px);
    font-weight: bold;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.player-piece.player {
    background: var(--success-green);
    color: #000;
}

.player-piece.ghost {
    background: var(--ghost-orange);
    color: white;
}

/* Center Control Area */
.board-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(33%, 200px);
    height: min(33%, 200px);
    border-radius: 20px;
    background: rgba(0,0,0,0.3);
    border: 3px solid rgba(255,255,255,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.dice {
    width: 30%;
    aspect-ratio: 1;
    min-width: 40px;
    min-height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.3em, 4vw, 2em);
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-normal);
    margin-bottom: 10px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    border: 3px solid rgba(255,255,255,0.3);
}

.dice:hover:not(.disabled) {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    border-color: rgba(255,255,255,0.5);
}

.dice.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #666;
}

.dice.rolling {
    animation: roll 0.8s ease-out;
}

@keyframes roll {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(360deg) scale(1.2); }
    100% { transform: rotate(720deg) scale(1); }
}

.turn-indicator {
    font-size: clamp(0.6em, 1.5vw, 0.8em);
    opacity: 0.9;
    margin-top: 10px;
    padding: 5px 10px;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
}

.turn-indicator.player-turn {
    color: var(--success-green);
    border: 1px solid var(--success-green);
}

.turn-indicator.ghost-turn {
    color: var(--ghost-orange);
    border: 1px solid var(--ghost-orange);
}

/* Players Section */
.players-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.player-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 15px;
    text-align: center;
    position: relative;
    border: 2px solid transparent;
    transition: all var(--transition-normal);
}

.player-card.active {
    border-color: var(--success-green);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.4);
}

.player-card.ghost {
    border-color: var(--ghost-orange);
}

.player-card.ghost.active {
    border-color: var(--ghost-orange);
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.4);
}

.player-name {
    font-size: clamp(1em, 2.5vw, 1.2em);
    font-weight: bold;
    margin-bottom: 10px;
}

.player-stats {
    display: flex;
    justify-content: space-around;
    font-size: clamp(0.8em, 2vw, 0.9em);
}

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

.stat-value {
    font-size: clamp(1.2em, 3vw, 1.5em);
    font-weight: bold;
    color: var(--success-green);
}

.ghost .stat-value {
    color: var(--ghost-orange);
}

.consecutive-rolls {
    margin-top: 10px;
    font-size: 0.8em;
    opacity: 0.8;
}

/* Mastery Progress - Updated for 9 categories */
.mastery-section {
    margin-bottom: 30px;
}

.mastery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
}

@media (min-width: 600px) {
    .mastery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.mastery-category {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 15px 10px;
    text-align: center;
    position: relative;
    border: 2px solid rgba(255,255,255,0.2);
    transition: all var(--transition-normal);
}

.mastery-category.earned {
    border-color: var(--success-green);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.4);
    background: rgba(0, 255, 136, 0.1);
}

.mastery-icon {
    font-size: clamp(1.5em, 4vw, 2em);
    margin-bottom: 5px;
    opacity: 0.5;
    transition: all var(--transition-normal);
}

.mastery-category.earned .mastery-icon {
    opacity: 1;
    transform: scale(1.2);
}

.mastery-name {
    font-size: clamp(0.7em, 1.8vw, 0.85em);
    font-weight: bold;
}

.mastery-progress {
    font-size: clamp(0.65em, 1.6vw, 0.75em);
    margin-top: 5px;
    opacity: 0.8;
    color: var(--success-green);
}

.mastery-token {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 1.2em;
    color: var(--success-green);
    display: none;
}

.mastery-category.earned .mastery-token {
    display: block;
}

/* Game Controls - FIXED: Consistent styling with 10px border-radius */
.game-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 20px 0;
}

.control-btn {
    background: var(--primary-gradient);
    border: none;
    color: #000;
    padding: 12px 30px;
    border-radius: 10px !important;
    font-size: clamp(0.9em, 2.5vw, 1em);
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 10px;
    min-height: 48px;
    min-width: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Add consistent hover effect to ALL control buttons */
.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 136, 0.3);
}

/* Add press effect for better feedback */
.control-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 255, 136, 0.2);
}

/* Focus states for accessibility */
.control-btn:focus,
.option-btn:focus,
.terminal-btn:focus,
.flashcard-btn:focus,
button:focus {
    outline: 2px solid var(--success-green);
    outline-offset: 2px;
}

@media (max-width: 600px) {
    .game-controls .control-btn {
        flex: 1 1 45%;
        min-width: 140px;
        font-size: 0.85em;
        padding: 12px 20px;
        letter-spacing: 0.5px;
    }
    
    .terminal-btn {
        font-size: 0.85em;
    }
}

@media (max-width: 600px) {
    .board-container {
        max-width: 95vw;
    }
    
    .board-space {
        width: min(8%, 42px);  /* CHANGED: Now 8% instead of 6.5% */
        height: min(8%, 42px);
        border-width: 1px;
        border-radius: 4px;
    }
    
    .board-space.corner-space {
        font-size: clamp(0.7em, 1.8vw, 1em);
    }
    
    .game-board {
        border-width: 2px;
        border-radius: 15px;
    }
}

@media (max-width: 480px) {
    .game-controls .control-btn {
        flex: 1 1 100%;
        min-width: 100%;
        margin: 5px 0;
        font-size: 0.9em;
    }
}

/* Challenge Section - FIXED: Smooth transitions */
.challenge-section {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 20px;
}

.challenge-section.visible {
    visibility: visible;
    opacity: 1;
}

.challenge-modal {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: clamp(20px, 5vw, 30px);
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.challenge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.challenge-title {
    font-size: clamp(1em, 3vw, 1.3em);
    color: var(--success-green);
}

.challenge-difficulty {
    padding: 5px 15px;
    border-radius: 20px;
    font-size: clamp(0.7em, 2vw, 0.8em);
    font-weight: bold;
}

.difficulty-special {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #000;
}

.challenge-question {
    background: rgba(0,0,0,0.3);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    font-size: clamp(0.9em, 2.5vw, 1.1em);
    line-height: 1.5;
}

.challenge-options {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.option-btn {
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    padding: 15px 20px;
    border-radius: 10px !important;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-align: left;
    font-size: clamp(0.9em, 2.5vw, 1em);
}

.option-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
}

.option-btn:active {
    transform: scale(0.98);
}

.option-btn.selected {
    background: rgba(255, 193, 7, 0.3);
    border-color: #ffc107;
}

.option-btn.correct {
    background: rgba(0, 255, 136, 0.3);
    border-color: var(--success-green);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.4);
}

.option-btn.incorrect {
    background: rgba(255, 68, 68, 0.3);
    border-color: var(--error-red);
}

.explanation-section {
    background: rgba(0,0,0,0.2);
    border-radius: 15px;
    padding: 20px;
    margin-top: 30px;
    display: none;
}

.explanation-section.show {
    display: block;
    animation: fadeIn var(--transition-normal);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.explanation-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.explanation-result {
    font-size: 1.2em;
    font-weight: bold;
    margin-right: 15px;
}

.explanation-result.correct {
    color: var(--success-green);
}

.explanation-result.incorrect {
    color: var(--error-red);
}

.continue-btn {
    background: var(--primary-gradient);
    color: #000;
    font-weight: bold;
    padding: 10px 30px;
    border: none;
    border-radius: 10px !important;
    cursor: pointer;
    transition: all var(--transition-normal);
    margin-top: 15px;
}

.continue-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 136, 0.3);
}

.retry-section {
    background: rgba(255, 68, 68, 0.1);
    border: 2px solid rgba(255, 68, 68, 0.3);
    border-radius: 15px;
    padding: 20px;
    margin-top: 20px;
    text-align: center;
}

/* Notification System - Fixed Z-Index */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 255, 136, 0.9);
    color: #000;
    padding: 15px 20px;
    border-radius: 10px;
    font-weight: bold;
    z-index: 4000;
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    max-width: 90%;
    font-size: clamp(0.8em, 2vw, 1em);
}

.notification.show {
    transform: translateX(0);
}

.notification.error {
    background: rgba(255, 68, 68, 0.9);
    color: white;
}

/* Ghost Activity - FIXED: Completely hidden */
.ghost-activity {
    display: none !important;
}

/* Standardize Modal Backdrops */
.audio-panel,
.terminal-modal,
.terminal-menu,
.flashcard-modal,
.flashcard-menu,
.win-modal,
.start-modal,
.study-guide-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 20px;
}

/* Win and Start modals should be above others */
.win-modal,
.start-modal {
    z-index: 3500;
}

/* Win Modal */
.win-content {
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    border: 3px solid var(--success-green);
    border-radius: 30px;
    padding: clamp(30px, 5vw, 50px);
    text-align: center;
    box-shadow: 0 0 50px rgba(0, 255, 136, 0.5);
}

.win-title {
    font-size: clamp(2em, 5vw, 3em);
    color: var(--success-green);
    margin-bottom: 20px;
    animation: pulse 1s ease-in-out infinite alternate;
}

.win-modal .win-content .control-btn {
    margin: 0 auto;
    display: block;
}

/* Loss modal styling */
.win-modal#loss-modal .win-title {
    color: var(--ghost-orange) !important;
}

@keyframes pulse {
    from { text-shadow: 0 0 20px rgba(0, 255, 136, 0.5); }
    to { text-shadow: 0 0 40px rgba(0, 255, 136, 1); }
}

/* Start Modal */
.start-content {
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    border: 3px solid var(--success-green);
    border-radius: 30px;
    padding: 40px;
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.difficulty-selection {
    margin-top: 30px;
}

.difficulty-options {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.difficulty-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px !important;
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-width: 120px;
}

.difficulty-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.difficulty-btn:active {
    transform: scale(0.98);
}

.difficulty-icon {
    font-size: 2em;
}

.difficulty-name {
    font-size: 1.2em;
    font-weight: bold;
    color: white;
}

.difficulty-desc {
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.7);
}

/* Rules Modal Styles */
.rules-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 20px;
}

.rules-content {
    background: #1a1a1a;
    border: 2px solid var(--success-green);
    border-radius: 20px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.3);
}

.rules-header {
    background: #2a2a2a;
    padding: 20px 30px;
    border-bottom: 2px solid rgba(0, 255, 136, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 20px 20px 0 0;
}

.rules-header h2 {
    margin: 0;
    color: var(--success-green);
    font-size: 28px;
}

.rules-close {
    background: transparent;
    border: none;
    color: var(--error-red);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-normal);
}

.rules-close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
    color: #ff6666;
}

.rules-body {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    color: #e0e0e0;
    line-height: 1.8;
}

.rules-body::-webkit-scrollbar {
    width: 10px;
}

.rules-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
}

.rules-body::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 136, 0.3);
    border-radius: 5px;
}

.rules-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 136, 0.5);
}

.rules-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

.rules-section h3 {
    color: #ffeb3b;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.rules-section ol,
.rules-section ul {
    margin-left: 20px;
}

.rules-section li {
    margin-bottom: 10px;
}

.rules-section strong {
    color: var(--success-green);
}

.rules-categories {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.rule-category {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    font-weight: bold;
}

/* Responsive design for rules modal */
@media (max-width: 768px) {
    .rules-header h2 {
        font-size: 20px;
    }
    
    .rules-body {
        padding: 20px;
    }
    
    .rules-categories {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

@media (max-width: 600px) {
    .rules-content {
        width: 95%;
    }
    
    .rules-header {
        padding: 15px 20px;
    }
    
    .rules-body {
        padding: 15px;
    }
}

/* Study Guide Modal - follows your modal pattern */
.study-guide-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 20px;
}

.study-guide-container {
    background: #1a1a1a;
    border: 2px solid var(--success-green);
    border-radius: 20px;
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.3);
}

.study-guide-header {
    background: #2a2a2a;
    padding: 20px 30px;
    border-bottom: 2px solid rgba(0, 255, 136, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 20px 20px 0 0;
}

.study-guide-header h2 {
    margin: 0;
    color: var(--success-green);
    font-size: 28px;
}

.study-guide-close {
    background: transparent;
    border: none;
    color: var(--error-red);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-normal);
}

.study-guide-close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
    color: #ff6666;
}

/* Update your .study-guide-nav styles with these: */

.study-guide-nav {
    display: flex;
    gap: 8px;
    padding: 15px 20px;
    flex-wrap: wrap;
    border-bottom: 1px solid rgba(0, 255, 136, 0.1);
    background: rgba(0, 0, 0, 0.3);
    justify-content: center;
}

/* On wide screens, force 2 rows of 5 buttons each */
@media (min-width: 900px) {
    .study-guide-nav {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 10px;
        padding: 20px 30px;
    }
}

.nav-category-btn {
    padding: 8px 14px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px !important;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    cursor: pointer;
    transition: all var(--transition-normal);
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    min-height: 40px;
    text-align: center;
}

.nav-category-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.nav-category-btn.active {
    background: linear-gradient(45deg, var(--category-color, #00ff88), var(--category-color-light, #00ff8888));
    border-color: var(--category-color, #00ff88);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Medium screens - 3 or 4 columns */
@media (min-width: 768px) and (max-width: 899px) {
    .study-guide-nav {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
}

/* Small screens - flexible wrap */
@media (max-width: 767px) {
    .study-guide-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        padding: 10px;
    }
    
    .nav-category-btn {
        font-size: 12px;
        padding: 6px 10px;
        flex: 1 1 auto;
        min-width: 120px;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .nav-category-btn {
        font-size: 11px;
        padding: 5px 8px;
        min-width: 100px;
    }
}

.study-guide-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    color: #e0e0e0;
    line-height: 1.8;
}

.study-guide-content::-webkit-scrollbar {
    width: 10px;
}

.study-guide-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
}

.study-guide-content::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 136, 0.3);
    border-radius: 5px;
}

.study-guide-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 136, 0.5);
}

.study-guide-welcome {
    text-align: center;
    padding: 40px;
}

.study-guide-welcome h1 {
    color: var(--success-green);
    margin-bottom: 20px;
}

.study-guide-welcome h3 {
    color: #ffeb3b;
    margin-top: 30px;
}

.study-guide-welcome ul {
    text-align: left;
    max-width: 600px;
    margin: 20px auto;
}

/* Study Guide Content Styling */
.study-guide-content h1 {
    color: var(--success-green);
    border-bottom: 2px solid rgba(0, 255, 136, 0.3);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.study-guide-content h3 {
    color: #ffeb3b;
    margin-top: 30px;
    margin-bottom: 15px;
}

.study-guide-content h4 {
    color: #64b5f6;
    margin-top: 20px;
    margin-bottom: 10px;
}

.study-guide-content code {
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: var(--success-green);
}

.study-guide-content pre {
    background: rgba(0, 0, 0, 0.5);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 15px 0;
    border: 1px solid rgba(0, 255, 136, 0.2);
}

.study-guide-content pre code {
    background: none;
    padding: 0;
    color: #e0e0e0;
}

.study-guide-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.study-guide-content li {
    margin-bottom: 8px;
}

/* Special boxes for tips and remember sections */
.remember-box, .tip-box {
    padding: 20px;
    border-radius: 10px !important;
    margin: 20px 0;
}

.remember-box {
    background: rgba(255, 68, 68, 0.1);
    border: 2px solid rgba(255, 68, 68, 0.3);
}

.remember-box h4 {
    color: var(--error-red);
    margin-top: 0;
}

.tip-box {
    background: rgba(255, 235, 59, 0.1);
    border: 2px solid rgba(255, 235, 59, 0.3);
}

.tip-box h4 {
    color: #ffeb3b;
    margin-top: 0;
}

/* Study Guide Responsive Design */
@media (max-width: 768px) {
    .study-guide-nav {
        gap: 5px;
        padding: 10px;
    }
    
    .study-guide-nav {
        padding: 10px;
        gap: 5px;
    }
    
    .nav-category-btn {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .study-guide-content {
        padding: 20px;
    }
    
    .study-guide-header h2 {
        font-size: 20px;
    }
}

@media (max-width: 600px) {
    .study-guide-container {
        padding: 0;
    }
    
    .study-guide-header {
        padding: 15px 20px;
    }
    
    .study-guide-content {
        padding: 15px;
    }
    
    .nav-category-btn {
        flex: 1 1 45%;
        min-width: 120px;
    }
}

/* Audio Panel */
.audio-content {
    background: #1a1a1a;
    border: 2px solid var(--success-green);
    border-radius: 20px;
    padding: 35px 30px 30px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.audio-header,
.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.audio-header h3,
.menu-header h3 {
    color: var(--success-green);
    margin: 0;
}

.audio-close,
.terminal-close,
.flashcard-close,
.menu-close {
    background: transparent;
    border: none;
    color: var(--error-red);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    transition: all var(--transition-normal);
}

.audio-close:hover,
.terminal-close:hover,
.flashcard-close:hover,
.menu-close:hover {
    color: #ff6666;
}

.audio-categories {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

@media (max-width: 500px) {
    .audio-categories {
        grid-template-columns: 1fr;
    }
}

.audio-cat-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 15px;
    border-radius: 10px !important;
    cursor: pointer;
    transition: all var(--transition-normal);
    font-size: 1em;
    text-align: center;
    font-weight: bold;
}

.audio-cat-btn:hover {
    background: rgba(0, 255, 136, 0.2);
    border-color: var(--success-green);
}

.audio-player {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

#study-audio {
    width: 100%;
    margin-bottom: 10px;
}

#audio-status {
    color: var(--success-green);
    font-size: 0.9em;
}

/* Terminal Menu */
.terminal-menu-content {
    background: #1a1a1a;
    border: 2px solid var(--success-green);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
}

.terminal-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.terminal-option {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 20px;
    border-radius: 10px !important;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-align: left;
    color: white;
}

.terminal-option:hover {
    background: rgba(0, 255, 136, 0.1);
    border-color: var(--success-green);
    transform: translateY(-2px);
    color: var(--success-green);
}

.terminal-option:active {
    transform: scale(0.98);
}

.option-desc {
    display: block;
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 8px;
}

/* Terminal Challenge Modal */
.terminal-window {
    background: #1a1a1a;
    border: 2px solid var(--success-green);
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.3);
}

.terminal-header {
    background: #2a2a2a;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--success-green);
    color: var(--success-green);
    font-weight: bold;
}

.terminal-body {
    padding: 20px;
}

.terminal-question {
    background: rgba(255, 165, 0, 0.1);
    border: 1px solid var(--warning-orange);
    padding: 15px;
    margin-bottom: 20px;
    color: var(--warning-orange);
    font-size: 1.1em;
    border-radius: 5px;
}

.terminal-prompt {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: #0a0a0a;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #333;
}

.prompt-symbol {
    color: var(--success-green);
    font-family: 'Courier New', monospace;
    font-weight: bold;
}

.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    outline: none;
    font-family: 'Courier New', monospace;
    font-size: 16px;
}

.terminal-feedback {
    min-height: 30px;
    margin-bottom: 20px;
    font-family: monospace;
}

.terminal-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.terminal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px !important;
    cursor: pointer;
    font-weight: bold;
    transition: all var(--transition-normal);
    min-height: 44px;
}

.terminal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.terminal-btn:active {
    transform: scale(0.98);
}

.terminal-btn.run {
    background: linear-gradient(45deg, var(--success-green), #00cc66);
    color: #000;
}

.terminal-btn.hint {
    background: linear-gradient(45deg, var(--warning-orange), #ff8c00);
    color: #000;
}

.terminal-btn.answer {
    background: linear-gradient(45deg, #00bcd4, #0097a7);
    color: white;
}

.terminal-btn.skip {
    background: linear-gradient(45deg, #666, #888);
    color: white;
}

.terminal-btn.back {
    background: linear-gradient(45deg, #666, #888) !important;
    color: white !important;
}

/* Flash Card Menu */
.flashcard-menu-content {
    background: #1a1a1a;
    border: 2px solid var(--success-green);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
}

.flashcard-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.flashcard-option {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 20px;
    border-radius: 10px !important;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-align: left;
    color: white;
}

.flashcard-option:hover {
    background: rgba(0, 255, 136, 0.1);
    border-color: var(--success-green);
    transform: translateY(-2px);
    color: var(--success-green);
}

.flashcard-option:active {
    transform: scale(0.98);
}

/* Flash Card Modal */
.flashcard-container {
    background: #1a1a1a;
    border: 2px solid var(--success-green);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    text-align: center;
}

.flashcard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.flashcard-header h3 {
    color: var(--success-green);
    margin: 0;
}

.flashcard-progress {
    color: var(--success-green);
    margin-bottom: 20px;
    font-size: 0.9em;
}

/* Flash card with opacity transition - FIXED */
.flashcard {
    width: 100%;
    height: 300px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s, opacity 0.2s ease;
    cursor: pointer;
    margin-bottom: 30px;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.flashcard-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.1), rgba(0, 255, 136, 0.05));
    border-color: var(--success-green);
}

.flashcard-content {
    font-size: 1.2em;
    line-height: 1.5;
}

.flashcard-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.flashcard-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px !important;
    cursor: pointer;
    font-weight: bold;
    transition: all var(--transition-normal);
    font-size: 1em;
    flex: 0 1 auto;
    min-height: 44px;
}

/* Hard button - red */
.flashcard-btn:first-child {
    background: linear-gradient(45deg, var(--error-red), #ff6666);
    color: white;
}

/* Easy button - green */
.flashcard-btn:nth-child(2) {
    background: linear-gradient(45deg, var(--success-green), #00cc66);
    color: #000;
}

/* Back button - gray - FIXED consistency */
.flashcard-btn.back {
    background: linear-gradient(45deg, #666, #888) !important;
    color: white !important;
}

.flashcard-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.flashcard-btn:active {
    transform: scale(0.98);
}

/* Review Modal - End Game Flash Cards */
.review-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3600;
    padding: 20px;
    opacity: 0;
    transition: opacity var(--transition-normal);
    z-index: 3700; /* Higher than win/loss modals */
}

.review-modal.show {
    opacity: 1;
}

.review-content {
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    border: 3px solid var(--success-green);
    border-radius: 30px;
    padding: 40px;
    text-align: center;
    max-width: 500px;
    width: 100%;
    animation: fadeIn var(--transition-normal);
}

.review-content h2 {
    color: var(--success-green);
    margin-bottom: 20px;
    font-size: 2em;
}

.review-content p {
    color: white;
    font-size: 1.2em;
    margin-bottom: 30px;
}

.review-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.review-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 10px !important;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-normal);
    min-width: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.review-btn.primary {
    background: var(--primary-gradient);
    color: #000;
}

/* Secondary button - gray - FIXED consistency */
.review-btn.secondary {
    background: linear-gradient(45deg, #666, #888) !important;
    color: white !important;
}

.review-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

/* Loading State */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--success-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Small screens */
@media (max-width: 600px) {
    body {
        padding: 5px;
    }

    .game-container {
        padding: 5px;
    }

    .header {
        padding: 10px 0;
    }

    .glass-card {
        padding: 15px;
    }

    .board-container {
        margin: 10px auto;
    }

    .board-space {
        font-size: 0.4em;
    }

    .board-center {
        width: 40%;
    }

    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .terminal-window,
    .audio-content,
    .flashcard-container,
    .flashcard-menu-content,
    .terminal-menu-content {
        width: 95%;
        padding: 20px;
    }
    
    .flashcard {
        height: 250px;
    }
    
    .terminal-options,
    .flashcard-options {
        grid-template-columns: 1fr;
    }
    
    .terminal-controls {
        flex-wrap: wrap;
    }
    
    .terminal-btn {
        flex: 1 1 30%;
        min-width: 100px;
        font-size: 0.9em;
        padding: 8px 12px;
    }

    .review-content {
        padding: 30px 20px;
    }
    
    .review-content h2 {
        font-size: 1.5em;
    }
    
    .review-content p {
        font-size: 1em;
    }
    
    .review-buttons {
        flex-direction: column;
        gap: 15px;
    }
    
    .review-btn {
        width: 100%;
    }

    .flashcard-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .flashcard-btn {
        width: 100%;
    }
}

/* Very small screens */
@media (max-width: 400px) {
    .mastery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .board-space {
        border-width: 1px;
    }

    .player-piece {
        border-width: 2px;
    }
}