/* Match Sticks Game - Ember Glow Aesthetic */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Crimson+Pro:wght@300;400;500&display=swap');

:root {
    --ember-bright: #ff7a8a;
    --ember-core: #d9485a;
    --ember-deep: #8f2436;
    --ember-glow: rgba(217, 72, 90, 0.4);
    --ash-dark: #0a0a0f;
    --ash-medium: #151520;
    --ash-light: #1e1e2a;
    --smoke: #2a2a3a;
    --coal: #111118;
    --cream: #f5e6d3;
    --cream-dim: #c4b5a4;
    --board-dot: rgba(220, 225, 240, 0.08);
    --board-dot-soft: rgba(180, 188, 210, 0.05);
}

body {
    background: var(--coal);
}

.game-wrapper {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    padding-top: 80px;
    background: var(--coal);
    position: relative;
    overflow: hidden;
}

/* Subtle animated grain texture */
.game-wrapper::before {
    content: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.03;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(/%23noise)'/%3E%3C/svg%3E");
}

/* Floating ambient dots */
.game-wrapper::after {
    content: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image:
        radial-gradient(1px 1px at 20% 30%, rgba(220, 228, 240, 0.45), transparent),
        radial-gradient(1px 1px at 40% 70%, rgba(210, 218, 235, 0.38), transparent),
        radial-gradient(1px 1px at 60% 20%, rgba(220, 228, 240, 0.4), transparent),
        radial-gradient(1.5px 1.5px at 15% 80%, rgba(210, 218, 235, 0.34), transparent),
        radial-gradient(1px 1px at 90% 40%, rgba(195, 205, 225, 0.3), transparent);
    animation: floatEmbers 24s ease-in-out infinite;
    opacity: 0.45;
}

@keyframes floatEmbers {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.6; }
    25% { transform: translateY(-10px) rotate(1deg); opacity: 0.4; }
    50% { transform: translateY(-5px) rotate(-1deg); opacity: 0.7; }
    75% { transform: translateY(-15px) rotate(0.5deg); opacity: 0.5; }
}

.game-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    position: relative;
    z-index: 1;
}

.game-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
}

.game-info h1 {
    font-family: 'Cinzel', serif;
    color: var(--cream);
    font-size: 2.2rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    text-shadow:
        0 0 40px var(--ember-glow),
        0 0 80px rgba(217, 72, 90, 0.28),
        0 2px 4px rgba(0, 0, 0, 0.8);
    position: relative;
}

.game-info h1::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--ember-core), transparent);
}

.attempt-counter {
    margin: 0;
    font-family: 'Crimson Pro', serif;
    font-size: 1rem;
    letter-spacing: 0.06em;
    color: var(--cream-dim);
    text-align: center;
}

.attempt-pill {
    display: inline-block;
    min-width: 1.7em;
    padding: 2px 9px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--ember-core) 0%, var(--ember-deep) 100%);
    color: #fff4e6;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(217, 72, 90, 0.45);
    box-shadow: 0 0 14px rgba(217, 72, 90, 0.35);
}

.counter-sep {
    color: #8d7d6b;
    margin: 0 6px;
}

.diff-btn {
    padding: 12px 28px;
    border: 1px solid var(--smoke);
    background: linear-gradient(180deg, var(--ash-light) 0%, var(--ash-medium) 100%);
    color: var(--cream-dim);
    font-family: 'Crimson Pro', serif;
    font-size: 1.1rem;
    font-weight: 400;
    letter-spacing: 0.1em;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.diff-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, transparent 0%, rgba(217, 72, 90, 0.12) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.diff-btn:hover {
    border-color: var(--ember-core);
    color: var(--cream);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(217, 72, 90, 0.18);
}

.diff-btn:hover::before {
    opacity: 1;
}

.diff-btn.active {
    background: linear-gradient(180deg, var(--ember-core) 0%, var(--ember-deep) 100%);
    border-color: var(--ember-bright);
    color: var(--ash-dark);
    font-weight: 500;
    box-shadow:
        0 0 20px var(--ember-glow),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Game Area */
.game-area {
    width: 100%;
    aspect-ratio: 1;
    max-width: 500px;
    background:
        radial-gradient(ellipse at center, #1b1f2d 0%, #0f111a 72%),
        var(--coal);
    border-radius: 14px;
    box-shadow:
        0 0 0 1px rgba(203, 214, 235, 0.12),
        0 0 60px rgba(18, 24, 40, 0.65),
        inset 0 0 110px rgba(0, 0, 0, 0.55),
        0 20px 60px rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.game-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at center, rgba(230, 238, 255, 0.06) 0%, rgba(230, 238, 255, 0) 60%),
        repeating-radial-gradient(circle at center, transparent 0 14px, rgba(198, 208, 230, 0.04) 14px 15px);
    z-index: 0;
    pointer-events: none;
}

.game-area::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(var(--board-dot) 1.1px, transparent 1.1px),
        radial-gradient(var(--board-dot-soft) 0.9px, transparent 0.9px);
    background-size: 22px 22px, 22px 22px;
    background-position: 0 0, 11px 11px;
    opacity: 0.85;
    pointer-events: none;
    z-index: 0;
}

#gameCanvas {
    max-width: 100%;
    max-height: 100%;
    position: relative;
    z-index: 1;
}

/* Game Controls */
.game-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.control-btn {
    padding: 14px 32px;
    border: none;
    background: linear-gradient(180deg, var(--ash-light) 0%, var(--ash-medium) 100%);
    color: var(--cream);
    font-family: 'Crimson Pro', serif;
    font-size: 1.05rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--smoke);
    position: relative;
    overflow: hidden;
}

.control-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, var(--ember-glow) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.5s ease, height 0.5s ease;
    pointer-events: none;
}

.control-btn:hover {
    border-color: var(--ember-core);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(217, 72, 90, 0.22);
}

.control-btn:hover::after {
    width: 200%;
    height: 200%;
}

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

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 10, 0.92);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.modal-content {
    background:
        radial-gradient(ellipse at 50% 0%, rgba(217, 72, 90, 0.1) 0%, transparent 50%),
        linear-gradient(180deg, var(--ash-light) 0%, var(--ash-dark) 100%);
    padding: 48px 40px;
    border-radius: 8px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow:
        0 0 0 1px rgba(217, 72, 90, 0.28),
        0 0 80px rgba(217, 72, 90, 0.18),
        0 40px 80px rgba(0, 0, 0, 0.8);
    position: relative;
    overflow: hidden;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--ember-core), transparent);
}

.modal-content h2 {
    font-family: 'Cinzel', serif;
    color: var(--cream);
    font-size: 2rem;
    font-weight: 600;
    margin: 0 0 24px 0;
    letter-spacing: 0.12em;
    text-shadow: 0 0 30px var(--ember-glow);
}

.instructions {
    color: var(--cream-dim);
    margin-bottom: 32px;
    line-height: 2;
    font-family: 'Crimson Pro', serif;
    font-size: 1.1rem;
}

.instructions p {
    margin: 10px 0;
}

.red-text {
    color: var(--ember-core);
    font-weight: 500;
    text-shadow: 0 0 10px var(--ember-glow);
}

.green-text {
    color: #4ade80;
    font-weight: 500;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.4);
}

.difficulty-select h3 {
    font-family: 'Cinzel', serif;
    color: var(--ember-bright);
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 20px;
}

.diff-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.start-btn {
    padding: 16px 36px;
    border: 1px solid var(--ember-core);
    background: linear-gradient(180deg, rgba(217, 72, 90, 0.18) 0%, rgba(143, 36, 54, 0.12) 100%);
    color: var(--cream);
    font-family: 'Crimson Pro', serif;
    font-size: 1.15rem;
    font-weight: 400;
    letter-spacing: 0.15em;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

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

.start-btn:hover {
    background: linear-gradient(180deg, var(--ember-core) 0%, var(--ember-deep) 100%);
    border-color: var(--ember-bright);
    transform: scale(1.02);
    box-shadow:
        0 0 30px var(--ember-glow),
        0 10px 40px rgba(217, 72, 90, 0.32);
}

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

/* Responsive */
@media (max-width: 600px) {
    .game-wrapper {
        padding: 10px;
        padding-top: 70px;
    }

    .game-info h1 {
        font-size: 1.6rem;
        letter-spacing: 0.1em;
    }

    .attempt-counter {
        font-size: 0.9rem;
        letter-spacing: 0.04em;
    }

    .diff-btn {
        padding: 10px 20px;
        font-size: 1rem;
    }

    .game-area {
        max-width: 100%;
        border-radius: 6px;
    }

    .modal-content {
        padding: 32px 24px;
    }

    .modal-content h2 {
        font-size: 1.6rem;
    }

    .instructions {
        font-size: 1rem;
        line-height: 1.8;
    }

    .control-btn {
        width: auto;
        padding: 12px 24px;
    }
}
