:root {
    --primary-dark: #0f172a;
    --secondary-dark: #1e293b;
    --accent-fire: #ef4444;
    --accent-water: #3b82f6;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --grid-gap: 8px;
    --cell-size: 70px;
}

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

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--primary-dark);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.game-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 20%, rgba(239, 68, 68, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.15) 0%, transparent 40%);
    z-index: -1;
}

.game-layout {
    display: flex;
    gap: 40px;
    max-width: 1400px;
    width: 95%;
    padding: 20px;
    align-items: flex-start;
}

.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header-area {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 0 20px;
}

h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    background: linear-gradient(to right, var(--accent-fire), var(--accent-water));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.new-game-button {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--accent-water), var(--accent-fire));
    border: none;
    border-radius: 8px;
    color: white;
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.new-game-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.game-board-wrapper {
    padding: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    margin-bottom: 30px;
}

.game-board {
    position: relative;
}

.grid {
    display: grid;
    grid-template-columns: repeat(6, var(--cell-size));
    grid-template-rows: repeat(6, var(--cell-size));
    gap: var(--grid-gap);
    padding: var(--grid-gap);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.cell:hover:not(.barrier):not(:has(.element-content)) {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.1);
}

.barrier {
    background: rgba(0, 0, 0, 0.4);
    cursor: not-allowed;
    position: relative;
}

.barrier::after {
    content: '';
    position: absolute;
    width: 60%;
    height: 60%;
    background: repeating-linear-gradient(45deg,
            transparent,
            transparent 5px,
            rgba(255, 255, 255, 0.1) 5px,
            rgba(255, 255, 255, 0.1) 10px);
    border-radius: 4px;
}

.nexus-point {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 15px white, 0 0 30px var(--accent-fire), 0 0 45px var(--accent-water);
    z-index: 10;
    pointer-events: none;
}

/* Element Styles */
.element-content {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 15px currentColor;
}

.element-fire {
    color: var(--accent-fire);
    background: radial-gradient(circle at 30% 30%, #fca5a5, var(--accent-fire));
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
}

.element-water {
    color: var(--accent-water);
    background: radial-gradient(circle at 30% 30%, #93c5fd, var(--accent-water));
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.6);
}

/* Player Info */
.player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 20px;
}

.player {
    flex: 1;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.player.active {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.player1.active {
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.2);
}

.player2.active {
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.2);
}

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

.player h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.score {
    font-size: 1.5rem;
    font-weight: bold;
    font-family: 'Orbitron', sans-serif;
}

.tags-container {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.tag {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.player1 .tag {
    background-color: var(--accent-fire);
    box-shadow: 0 0 5px rgba(239, 68, 68, 0.5);
}

.player2 .tag {
    background-color: var(--accent-water);
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.5);
}

/* Timer */
.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.timer-ring {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid var(--secondary-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    background: var(--glass-bg);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    position: relative;
}

.timer-ring::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 4px solid transparent;
    border-top-color: var(--text-primary);
    animation: spin 1s linear infinite;
    opacity: 0.3;
}

.current-player {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Rules Panel */
.rules-panel {
    width: 350px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 25px;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.rules-panel h2 {
    font-family: 'Orbitron', sans-serif;
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 15px;
}

.rule-section {
    margin-bottom: 25px;
}

.rule-section h3 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.rules-content ul {
    list-style: none;
}

.rules-content li {
    margin-bottom: 8px;
    padding-left: 15px;
    position: relative;
    font-size: 0.95rem;
    line-height: 1.5;
}

.rules-content li::before {
    content: '›';
    position: absolute;
    left: 0;
    color: var(--text-secondary);
    font-weight: bold;
}

.element-list {
    display: flex;
    gap: 10px;
}

.element-item {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.2);
}

.fire-item {
    color: var(--accent-fire);
}

.water-item {
    color: var(--accent-water);
}

.barrier-info {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

/* Animations */
@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    70% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

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

@keyframes crush {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.5;
        filter: brightness(2);
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.crushed .element-content {
    animation: crush 0.5s ease-out forwards;
}

.winning-cell {
    background: rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3) !important;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Responsive */
@media (max-width: 1100px) {
    .game-layout {
        flex-direction: column;
        align-items: center;
    }

    .rules-panel {
        width: 100%;
        max-width: 600px;
        position: static;
    }
}

@media (max-width: 600px) {
    :root {
        --cell-size: 50px;
    }

    .player-info {
        flex-direction: column;
    }

    .timer-container {
        order: -1;
        margin-bottom: 20px;
    }
}