/* ===========================================
   MAZE CRAFTER - A Backtracking Adventure
   Dark Fantasy Theme with Neon Accents
   =========================================== */

:root {
    /* Core Colors - Dark Cavern Theme */
    --bg-deep: #0a0a0f;
    --bg-dark: #12121a;
    --bg-medium: #1a1a2e;
    --bg-light: #252540;
    
    /* Accent Colors - Mystical */
    --accent-primary: #00ff9f;
    --accent-secondary: #ff006e;
    --accent-gold: #ffd700;
    --accent-blue: #00d4ff;
    --accent-purple: #9d4edd;
    
    /* Text Colors */
    --text-bright: #ffffff;
    --text-normal: #e0e0e0;
    --text-dim: #808090;
    
    /* Game Elements */
    --wall-color: #2a2a4a;
    --wall-highlight: #3a3a6a;
    --path-color: #0d0d15;
    --player-glow: #00ff9f;
    --enemy-glow: #ff006e;
    --exit-glow: #ffd700;
    
    /* Shadows */
    --glow-primary: 0 0 20px rgba(0, 255, 159, 0.5);
    --glow-secondary: 0 0 20px rgba(255, 0, 110, 0.5);
    --glow-gold: 0 0 30px rgba(255, 215, 0, 0.6);
}

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

body {
    font-family: 'Fira Code', monospace;
    background: var(--bg-deep);
    color: var(--text-normal);
    min-height: 100vh;
    overflow: hidden;
}

/* ===========================================
   GAME CONTAINER
   =========================================== */

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    background: 
        radial-gradient(ellipse at 50% 0%, rgba(157, 78, 221, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 100%, rgba(0, 255, 159, 0.05) 0%, transparent 40%),
        radial-gradient(ellipse at 0% 100%, rgba(255, 0, 110, 0.05) 0%, transparent 40%),
        var(--bg-deep);
}

/* ===========================================
   SCREENS
   =========================================== */

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* ===========================================
   TITLE SCREEN
   =========================================== */

#title-screen {
    background: 
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0v60M0 30h60' stroke='%23ffffff' stroke-width='0.5' opacity='0.03'/%3E%3C/svg%3E"),
        radial-gradient(ellipse at center, var(--bg-medium) 0%, var(--bg-deep) 70%);
}

.title-content {
    text-align: center;
    z-index: 10;
}

.game-title {
    font-family: 'Cinzel', serif;
    font-size: 5rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 1rem;
}

.title-maze {
    display: block;
    color: var(--accent-primary);
    text-shadow: 
        0 0 10px var(--accent-primary),
        0 0 30px var(--accent-primary),
        0 0 60px rgba(0, 255, 159, 0.5);
    letter-spacing: 0.3em;
    animation: titlePulse 3s ease-in-out infinite;
}

.title-crafter {
    display: block;
    color: var(--accent-secondary);
    text-shadow: 
        0 0 10px var(--accent-secondary),
        0 0 30px var(--accent-secondary);
    letter-spacing: 0.2em;
    font-size: 0.6em;
}

@keyframes titlePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-dim);
    margin-bottom: 3rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
}

.menu-btn {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    font-weight: 600;
    padding: 1rem 3rem;
    border: 2px solid var(--accent-primary);
    background: transparent;
    color: var(--accent-primary);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.menu-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 159, 0.2), transparent);
    transition: left 0.5s ease;
}

.menu-btn:hover {
    background: rgba(0, 255, 159, 0.1);
    box-shadow: var(--glow-primary);
    transform: translateY(-2px);
}

.menu-btn:hover::before {
    left: 100%;
}

.menu-btn.secondary {
    border-color: var(--text-dim);
    color: var(--text-dim);
}

.menu-btn.secondary:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.maze-size-selector {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: center;
}

.maze-size-selector label {
    color: var(--text-dim);
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
}

.maze-size-selector select {
    font-family: 'Fira Code', monospace;
    font-size: 1rem;
    padding: 0.5rem 1rem;
    background: var(--bg-medium);
    border: 1px solid var(--accent-purple);
    color: var(--text-bright);
    cursor: pointer;
    outline: none;
}

.maze-size-selector select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(0, 255, 159, 0.3);
}

/* Floating Runes Animation */
.floating-runes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.floating-runes::before,
.floating-runes::after {
    content: '⬡ ⬢ ◈ ◇ ✧ ⬡ ⬢ ◈';
    position: absolute;
    font-size: 2rem;
    color: var(--accent-purple);
    opacity: 0.1;
    white-space: nowrap;
    animation: floatRunes 20s linear infinite;
}

.floating-runes::before {
    top: 20%;
    left: -50%;
}

.floating-runes::after {
    bottom: 30%;
    right: -50%;
    animation-delay: -10s;
    animation-direction: reverse;
}

@keyframes floatRunes {
    0% { transform: translateX(0); }
    100% { transform: translateX(100vw); }
}

/* ===========================================
   HOW TO PLAY SCREEN
   =========================================== */

.how-to-content {
    max-width: 700px;
    padding: 2rem;
}

.how-to-content h2 {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    color: var(--accent-primary);
    text-align: center;
    margin-bottom: 2rem;
    text-shadow: 0 0 20px rgba(0, 255, 159, 0.5);
}

.instructions {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.instruction-block {
    background: rgba(26, 26, 46, 0.8);
    border: 1px solid var(--bg-light);
    border-left: 3px solid var(--accent-purple);
    padding: 1.2rem;
    border-radius: 0 8px 8px 0;
}

.instruction-block h3 {
    font-size: 1.1rem;
    color: var(--text-bright);
    margin-bottom: 0.5rem;
}

.instruction-block p {
    color: var(--text-dim);
    line-height: 1.6;
}

kbd {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: var(--bg-dark);
    border: 1px solid var(--accent-blue);
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    color: var(--accent-blue);
    margin: 0 0.2rem;
}

/* ===========================================
   GENERATION SCREEN
   =========================================== */

.generation-content {
    text-align: center;
}

.generation-content h2 {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    color: var(--accent-primary);
    margin-bottom: 2rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

#maze-gen-canvas {
    border: 2px solid var(--accent-purple);
    box-shadow: 
        0 0 20px rgba(157, 78, 221, 0.3),
        inset 0 0 50px rgba(0, 0, 0, 0.5);
    background: var(--bg-dark);
}

.gen-info {
    margin-top: 1.5rem;
}

#gen-status {
    display: block;
    color: var(--text-dim);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.gen-progress {
    width: 300px;
    height: 6px;
    background: var(--bg-dark);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto;
}

#gen-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-blue));
    transition: width 0.1s ease;
    box-shadow: 0 0 10px var(--accent-primary);
}

/* ===========================================
   GAME SCREEN
   =========================================== */

#game-screen {
    flex-direction: column;
    padding: 1rem;
}

.game-header {
    display: flex;
    gap: 3rem;
    margin-bottom: 1rem;
    padding: 1rem 2rem;
    background: rgba(26, 26, 46, 0.9);
    border: 1px solid var(--bg-light);
    border-radius: 8px;
}

.game-header > div {
    text-align: center;
}

.game-header .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.3rem;
}

.game-header .value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.game-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#game-canvas {
    border: 3px solid var(--wall-highlight);
    box-shadow: 
        0 0 30px rgba(157, 78, 221, 0.2),
        inset 0 0 100px rgba(0, 0, 0, 0.8);
    background: var(--bg-dark);
}

.game-footer {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.game-btn {
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    padding: 0.7rem 1.5rem;
    background: var(--bg-medium);
    border: 1px solid var(--accent-blue);
    color: var(--accent-blue);
    cursor: pointer;
    transition: all 0.3s ease;
}

.game-btn:hover {
    background: rgba(0, 212, 255, 0.1);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

.game-btn.danger {
    border-color: var(--accent-secondary);
    color: var(--accent-secondary);
}

.game-btn.danger:hover {
    background: rgba(255, 0, 110, 0.1);
    box-shadow: 0 0 15px rgba(255, 0, 110, 0.3);
}

/* ===========================================
   BATTLE SCREEN
   =========================================== */

#battle-screen {
    background: rgba(10, 10, 15, 0.95);
}

.battle-container {
    text-align: center;
    max-width: 800px;
    padding: 2rem;
}

.battle-header h2 {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    color: var(--accent-secondary);
    text-shadow: 0 0 30px rgba(255, 0, 110, 0.5);
    animation: battlePulse 1s ease-in-out infinite;
}

@keyframes battlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.battle-subtitle {
    color: var(--text-dim);
    margin-top: 0.5rem;
}

.battle-arena {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    margin: 2rem 0;
}

.player-side,
.enemy-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.character {
    font-size: 4rem;
    animation: float 3s ease-in-out infinite;
}

.player-char {
    filter: drop-shadow(0 0 20px var(--accent-primary));
}

.enemy-char {
    filter: drop-shadow(0 0 20px var(--accent-secondary));
    animation-delay: -1.5s;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.char-label {
    font-size: 0.9rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Tic-Tac-Toe Board */
.ttt-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 15px;
    background: var(--bg-dark);
    border: 2px solid var(--accent-purple);
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(157, 78, 221, 0.3);
}

.ttt-cell {
    width: 80px;
    height: 80px;
    background: var(--bg-medium);
    border: 1px solid var(--bg-light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ttt-cell:hover:not(.taken) {
    background: var(--bg-light);
    border-color: var(--accent-blue);
    transform: scale(1.05);
}

.ttt-cell.taken {
    cursor: not-allowed;
}

.ttt-cell.x {
    color: var(--accent-primary);
    text-shadow: 0 0 15px var(--accent-primary);
}

.ttt-cell.o {
    color: var(--accent-secondary);
    text-shadow: 0 0 15px var(--accent-secondary);
}

.ttt-cell.winning {
    animation: winPulse 0.5s ease-in-out infinite;
    background: rgba(255, 215, 0, 0.2);
    border-color: var(--accent-gold);
}

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

/* Battle Info */
.battle-info {
    margin-top: 1.5rem;
}

#battle-status {
    font-size: 1.2rem;
    color: var(--text-bright);
}

.ai-thinking {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    color: var(--accent-secondary);
}

.ai-thinking.active {
    display: flex;
}

.thinking-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent-secondary);
    border-radius: 50%;
    animation: thinkingBounce 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkingBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* Minimax Visualization */
.minimax-viz {
    margin-top: 2rem;
    padding: 1rem;
    background: rgba(26, 26, 46, 0.8);
    border: 1px solid var(--bg-light);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.minimax-viz h4 {
    color: var(--accent-blue);
    margin-bottom: 1rem;
}

.viz-content {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: left;
    font-family: 'Fira Code', monospace;
}

.viz-content .move-analysis {
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--bg-light);
}

.viz-content .move-analysis:last-child {
    border-bottom: none;
}

.viz-content .best-move {
    color: var(--accent-primary);
    font-weight: 600;
}

/* ===========================================
   VICTORY SCREEN
   =========================================== */

#victory-screen {
    background: 
        radial-gradient(ellipse at center, rgba(255, 215, 0, 0.1) 0%, transparent 50%),
        var(--bg-deep);
}

.victory-content {
    text-align: center;
    z-index: 10;
}

.victory-title {
    font-family: 'Cinzel', serif;
    font-size: 3.5rem;
    color: var(--accent-gold);
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
    margin-bottom: 2rem;
    animation: victoryPulse 2s ease-in-out infinite;
}

@keyframes victoryPulse {
    0%, 100% { transform: scale(1); text-shadow: 0 0 30px rgba(255, 215, 0, 0.5); }
    50% { transform: scale(1.05); text-shadow: 0 0 50px rgba(255, 215, 0, 0.8); }
}

.stats {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.stat {
    background: rgba(26, 26, 46, 0.9);
    padding: 1.5rem 2rem;
    border-radius: 8px;
    border: 1px solid var(--accent-gold);
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--accent-gold);
}

.victory-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Confetti Animation */
.confetti {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

/* ===========================================
   BATTLE RESULT OVERLAY
   =========================================== */

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

.overlay.active {
    opacity: 1;
    visibility: visible;
}

.result-content {
    text-align: center;
    padding: 3rem;
    background: var(--bg-medium);
    border: 2px solid var(--accent-gold);
    border-radius: 12px;
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.3);
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.overlay.active .result-content {
    transform: scale(1);
}

.result-content h2 {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.result-content h2.victory {
    color: var(--accent-primary);
}

.result-content h2.defeat {
    color: var(--accent-secondary);
}

.result-content p {
    color: var(--text-dim);
    margin-bottom: 2rem;
}

/* ===========================================
   SCROLLBAR
   =========================================== */

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

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

::-webkit-scrollbar-thumb {
    background: var(--bg-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-purple);
}

/* ===========================================
   RESPONSIVE
   =========================================== */

@media (max-width: 768px) {
    .game-title {
        font-size: 3rem;
    }
    
    .battle-arena {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .ttt-cell {
        width: 60px;
        height: 60px;
        font-size: 2rem;
    }
    
    .stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    .game-header {
        gap: 1.5rem;
        padding: 0.8rem 1rem;
    }
}

