/* Atoms Game - Enhanced Edition Styles */

:root {
    --primary-bg: #1a1a2e;
    --secondary-bg: #16213e;
    --accent-color: #0f3460;
    --highlight-color: #e94560;
    --text-light: #ffffff;
    --text-dim: #cccccc;
    --border-color: #2a2a4e;
    --success-color: #00ff88;
    --warning-color: #ffaa00;
    --danger-color: #ff4444;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary-bg) 0%, var(--secondary-bg) 100%);
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Container */
#game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Screens */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    animation: fadeIn 0.3s ease-in;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Main Menu */
#main-menu {
    justify-content: center;
    align-items: center;
    text-align: center;
}

#main-menu h1 {
    font-size: 4rem;
    margin-bottom: 1rem;
    background: linear-gradient(45deg, var(--highlight-color), var(--success-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(233, 69, 96, 0.5);
}

#main-menu p {
    font-size: 1.2rem;
    color: var(--text-dim);
    margin-bottom: 3rem;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 300px;
}

/* Buttons */
button {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-light);
    background: linear-gradient(135deg, var(--accent-color), var(--secondary-bg));
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

button:hover::before {
    width: 300px;
    height: 300px;
}

button:hover {
    transform: translateY(-2px);
    border-color: var(--highlight-color);
    box-shadow: 0 5px 20px rgba(233, 69, 96, 0.4);
}

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

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button.primary {
    background: linear-gradient(135deg, var(--highlight-color), #ff6b6b);
}

button.success {
    background: linear-gradient(135deg, var(--success-color), #00cc70);
}

button.small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Mode Selection */
#mode-selection {
    padding: 2rem;
    justify-content: center;
    align-items: center;
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
    width: 100%;
}

.mode-card {
    background: var(--secondary-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-card:hover {
    transform: translateY(-5px);
    border-color: var(--highlight-color);
    box-shadow: 0 10px 30px rgba(233, 69, 96, 0.3);
}

.mode-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--highlight-color);
}

.mode-card p {
    color: var(--text-dim);
    font-size: 0.95rem;
}

/* Level Selection */
#level-selection {
    padding: 2rem;
    overflow-y: auto;
}

#level-selection h2 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2rem;
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.level-card {
    background: var(--secondary-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.level-card:hover {
    transform: scale(1.05);
    border-color: var(--highlight-color);
}

.level-card.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.level-card.completed {
    border-color: var(--success-color);
}

.level-number {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.level-stars {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.star {
    color: #666;
    font-size: 1.2rem;
}

.star.filled {
    color: #ffd700;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

/* Game Screen */
#game-screen {
    padding: 1rem;
}

#game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--secondary-bg);
    border-radius: 8px;
    margin-bottom: 1rem;
}

#game-status {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
}

#game-controls {
    display: flex;
    gap: 0.5rem;
}

/* Game Board */
#game-board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

#game-canvas {
    background: var(--accent-color);
    border: 3px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-width: 90vw;
    max-height: 70vh;
    cursor: pointer;
    transition: box-shadow 0.3s ease;
}

#game-canvas:hover {
    box-shadow: 0 10px 50px rgba(233, 69, 96, 0.3);
}

#game-canvas:active {
    transform: scale(0.995);
}

/* Turn Indicator */
#turn-indicator {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.5rem;
    background: rgba(26, 26, 46, 0.95);
    border: 2px solid var(--border-color);
    border-radius: 25px;
    font-weight: bold;
    font-size: 1.1rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 10;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.05); }
}

/* Special Boxes Legend */
#special-boxes-legend {
    padding: 1rem;
    background: var(--secondary-bg);
    border-radius: 8px;
    margin-top: 1rem;
}

#special-boxes-legend h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-dim);
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.legend-icon {
    font-size: 1.2rem;
}

/* Victory/Defeat Screens */
#victory-screen, #defeat-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
}

#victory-screen h2 {
    font-size: 3rem;
    color: var(--success-color);
    margin-bottom: 1rem;
    animation: bounceIn 0.6s ease-out;
}

#defeat-screen h2 {
    font-size: 3rem;
    color: var(--danger-color);
    margin-bottom: 1rem;
    animation: shakeX 0.6s ease-out;
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes shakeX {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-width: 400px;
    margin: 2rem auto;
    padding: 1.5rem;
    background: var(--secondary-bg);
    border-radius: 8px;
}

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

.result-stat-label {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.result-stat-value {
    font-size: 1.5rem;
    font-weight: bold;
}

.stars-display {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 2rem 0;
}

.star-big {
    font-size: 3rem;
    color: #666;
    animation: starPop 0.5s ease-out backwards;
}

.star-big.filled {
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
}

.star-big:nth-child(1) { animation-delay: 0.2s; }
.star-big:nth-child(2) { animation-delay: 0.4s; }
.star-big:nth-child(3) { animation-delay: 0.6s; }

@keyframes starPop {
    0% { transform: scale(0) rotate(0deg); }
    50% { transform: scale(1.3) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

.result-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Instructions */
#instructions {
    padding: 2rem;
    overflow-y: auto;
    max-width: 800px;
    margin: 0 auto;
}

#instructions h2 {
    margin-bottom: 1.5rem;
}

#instructions h3 {
    color: var(--highlight-color);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

#instructions p, #instructions ul {
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 1rem;
}

#instructions ul {
    list-style-position: inside;
    padding-left: 1rem;
}

/* Settings */
#settings {
    padding: 2rem;
    max-width: 600px;
    margin: 0 auto;
}

.settings-section {
    background: var(--secondary-bg);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.settings-section h3 {
    margin-bottom: 1rem;
    color: var(--highlight-color);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-label {
    font-size: 1rem;
}

.setting-control input[type="range"] {
    width: 150px;
}

.setting-control input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Pause Menu */
#pause-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(26, 26, 46, 0.98);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    z-index: 100;
    min-width: 300px;
    text-align: center;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
}

#pause-menu.active {
    display: block;
}

#pause-menu h3 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
}

#pause-menu .menu-buttons {
    width: 100%;
}

/* Loading Screen */
#loading-screen {
    justify-content: center;
    align-items: center;
    background: var(--primary-bg);
}

.loader {
    width: 60px;
    height: 60px;
    border: 5px solid var(--border-color);
    border-top-color: var(--highlight-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--primary-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--highlight-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    #main-menu h1 {
        font-size: 2.5rem;
    }
    
    .levels-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
    
    #game-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    #game-status {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .mode-grid {
        grid-template-columns: 1fr;
    }
    
    .result-buttons {
        flex-direction: column;
    }
}

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

/* Focus styles for keyboard navigation */
button:focus, .level-card:focus, .mode-card:focus {
    outline: 3px solid var(--highlight-color);
    outline-offset: 2px;
}
