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

:root {
    --bg-dark: #0f0519;
    --bg-card: #1a0b2e;
    --primary: #ff006e;
    --secondary: #fb5607;
    --accent: #ffbe0b;
    --purple: #8338ec;
    --pink: #ff006e;
    --text: #f8f9fa;
    --text-dim: #adb5bd;
    --border: #2d1b4e;
}

body {
    font-family: 'Rajdhani', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ===== ANIMATED BACKGROUND ===== */
.stars, .stars2, .stars3 {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.stars {
    background: transparent url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="2" height="2"><circle cx="1" cy="1" r="0.5" fill="%23ff006e" opacity="0.8"/></svg>') repeat;
    animation: stars 100s linear infinite;
}

.stars2 {
    background: transparent url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="3" height="3"><circle cx="1.5" cy="1.5" r="0.7" fill="%238338ec" opacity="0.6"/></svg>') repeat;
    animation: stars 150s linear infinite;
}

.stars3 {
    background: transparent url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4"><circle cx="2" cy="2" r="0.8" fill="%23ffbe0b" opacity="0.4"/></svg>') repeat;
    animation: stars 200s linear infinite;
}

@keyframes stars {
    from { transform: translateY(0); }
    to { transform: translateY(-1000px); }
}

/* ===== NAVIGATION ===== */
.top-nav {
    position: relative;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 3rem;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 5, 25, 0.9);
    backdrop-filter: blur(10px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    overflow: hidden;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.logo-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 2px;
    background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-btn:hover {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 20px rgba(255, 0, 110, 0.6);
    transform: translateY(-2px);
}

/* ===== PAGE MANAGEMENT ===== */
.page {
    display: none;
    min-height: 100vh;
}

.page.active {
    display: block;
}

/* ===== HERO HEADER ===== */
.hero-header {
    position: relative;
    z-index: 10;
    padding: 3rem 3rem 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hero-logo-section {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.hero-logo-icon {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: float 3s ease-in-out infinite;
}

.hero-logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(255, 0, 110, 0.5));
}

.hero-main-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: 4px;
    background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-transform: uppercase;
}

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

/* ===== HERO SECTION ===== */
.hero {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    padding: 2rem 3rem 6rem;
    max-width: 1400px;
    margin: 0 auto;
    align-items: center;
}

.hero-visual {
    display: flex;
    justify-content: center;
    align-items: center;
    animation: slideInLeft 1s ease-out;
    order: 1;
}

.hero-content {
    animation: slideInRight 1s ease-out;
    order: 2;
}

.hero-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 5rem;
    font-weight: 900;
    line-height: 0.9;
    margin-bottom: 2rem;
    text-transform: uppercase;
    letter-spacing: -2px;
}

.gradient {
    background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
}

.hero-subtitle {
    font-size: 1.2rem;
    line-height: 1.6;
    color: var(--text-dim);
    margin-bottom: 3rem;
    max-width: 500px;
}

.play-btn {
    padding: 1.2rem 3rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    color: white;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 10px 40px rgba(255, 0, 110, 0.4);
    letter-spacing: 2px;
}

.play-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 15px 50px rgba(255, 0, 110, 0.6);
}

.play-icon {
    font-size: 1rem;
}

/* ===== 3D TRIANGLE (PYRAMID) ===== */
.triangle-container {
    position: relative;
    width: 400px;
    height: 400px;
    perspective: 1000px;
}

.triangle {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform-style: preserve-3d;
    animation: rotateTriangle 20s infinite linear;
}

.triangle-face {
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

.triangle-face.front {
    border-width: 0 150px 260px 150px;
    border-color: transparent transparent rgba(255, 0, 110, 0.3) transparent;
    transform: translateZ(87px) translateX(-50%) translateY(-50%);
    left: 50%;
    top: 50%;
    filter: drop-shadow(0 0 20px rgba(255, 0, 110, 0.6));
}

.triangle-face.back {
    border-width: 0 150px 260px 150px;
    border-color: transparent transparent rgba(251, 86, 7, 0.3) transparent;
    transform: rotateY(180deg) translateZ(87px) translateX(-50%) translateY(-50%);
    left: 50%;
    top: 50%;
    filter: drop-shadow(0 0 20px rgba(251, 86, 7, 0.6));
}

.triangle-face.left {
    border-width: 0 150px 260px 150px;
    border-color: transparent transparent rgba(131, 56, 236, 0.3) transparent;
    transform: rotateY(-120deg) translateZ(87px) translateX(-50%) translateY(-50%);
    left: 50%;
    top: 50%;
    filter: drop-shadow(0 0 20px rgba(131, 56, 236, 0.6));
}

.triangle-face.right {
    border-width: 0 150px 260px 150px;
    border-color: transparent transparent rgba(255, 190, 11, 0.3) transparent;
    transform: rotateY(120deg) translateZ(87px) translateX(-50%) translateY(-50%);
    left: 50%;
    top: 50%;
    filter: drop-shadow(0 0 20px rgba(255, 190, 11, 0.6));
}

.triangle-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255, 0, 110, 0.3), transparent 70%);
    transform: translate(-50%, -50%);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes rotateTriangle {
    from { transform: translate(-50%, -50%) rotateX(0deg) rotateY(0deg); }
    to { transform: translate(-50%, -50%) rotateX(360deg) rotateY(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== SELECTION PAGE ===== */
.selection-content {
    position: relative;
    z-index: 10;
    padding: 3rem;
    max-width: 1600px;
    margin: 0 auto;
}

.selection-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 4rem;
    font-weight: 900;
    text-align: center;
    margin-bottom: 3rem;
    letter-spacing: 4px;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
}

.game-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.game-card:hover::before {
    transform: scaleX(1);
}

.game-card:hover {
    transform: translateY(-8px);
    border-color: var(--primary);
    box-shadow: 0 20px 60px rgba(255, 0, 110, 0.3);
}

.game-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.game-badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

.game-badge.level-1 {
    background: linear-gradient(135deg, rgba(255, 0, 110, 0.2), rgba(251, 86, 7, 0.2));
    color: var(--primary);
    border: 1px solid var(--primary);
}

.game-badge.level-2 {
    background: linear-gradient(135deg, rgba(131, 56, 236, 0.2), rgba(255, 190, 11, 0.2));
    color: var(--accent);
    border: 1px solid var(--accent);
}

.game-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
}

.game-description {
    color: var(--text-dim);
    line-height: 1.5;
    font-size: 0.95rem;
}

/* ===== GAME PAGE ===== */
.game-content {
    position: relative;
    z-index: 10;
    padding: 2rem 3rem;
    max-width: 900px;
    margin: 0 auto;
}

.game-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 12px;
}

.player-indicator {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.action-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 2px solid var(--purple);
    color: var(--purple);
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: var(--purple);
    color: white;
    box-shadow: 0 0 20px rgba(131, 56, 236, 0.6);
}

/* ===== GAME BOARD ===== */
.game-board {
    display: grid;
    gap: 12px;
    margin: 2rem auto;
    max-width: 600px;
}

.game-board.size-3 { grid-template-columns: repeat(3, 1fr); }
.game-board.size-4 { grid-template-columns: repeat(4, 1fr); }
.game-board.size-5 { grid-template-columns: repeat(5, 1fr); }
.game-board.size-6 { grid-template-columns: repeat(6, 1fr); }
.game-board.size-7 { grid-template-columns: repeat(7, 1fr); }
.game-board.size-9 { grid-template-columns: repeat(9, 1fr); }

.cell {
    aspect-ratio: 1;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: var(--text);
}

.cell:hover:not(.occupied):not(.blocked) {
    background: rgba(255, 0, 110, 0.1);
    border-color: var(--primary);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 0, 110, 0.3);
}

.cell.occupied {
    cursor: not-allowed;
}

.cell.blocked {
    background: rgba(131, 56, 236, 0.05);
    border-color: var(--purple);
    cursor: not-allowed;
    color: var(--purple);
}

.cell.x {
    color: var(--primary);
    text-shadow: 0 0 10px rgba(255, 0, 110, 0.8);
}

.cell.o {
    color: var(--secondary);
    text-shadow: 0 0 10px rgba(251, 86, 7, 0.8);
}

.cell.obstacle {
    background: rgba(131, 56, 236, 0.2);
    color: var(--purple);
}

/* ===== GAME STATUS ===== */
.game-status {
    text-align: center;
    padding: 1.5rem;
    margin-top: 2rem;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    border-radius: 12px;
    animation: fadeIn 0.5s ease;
}

.game-status.win {
    background: linear-gradient(135deg, rgba(255, 0, 110, 0.2), rgba(251, 86, 7, 0.2));
    color: var(--primary);
    border: 2px solid var(--primary);
}

.game-status.draw {
    background: rgba(131, 56, 236, 0.1);
    color: var(--purple);
    border: 2px solid var(--purple);
}

.hidden {
    display: none !important;
}

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

/* ===== NUMBER/LETTER INPUT ===== */
.number-input, .letter-input {
    margin: 2rem auto;
    text-align: center;
}

.number-input p, .letter-input p {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.number-buttons, .letter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    max-width: 400px;
    margin: 0 auto;
}

.num-btn, .let-btn {
    width: 50px;
    height: 50px;
    background: var(--bg-card);
    border: 2px solid var(--primary);
    color: var(--primary);
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.num-btn:hover, .let-btn:hover {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255, 0, 110, 0.5);
}

.num-btn:disabled, .let-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .hero-logo-section {
        flex-direction: column;
        gap: 1rem;
    }
    
    .hero-main-title {
        font-size: 3rem;
    }
    
    .hero {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .hero-visual {
        order: 1;
    }
    
    .hero-content {
        order: 2;
    }
    
    .hero-title {
        font-size: 4rem;
    }
    
    .hero-subtitle {
        margin: 0 auto 2rem;
    }
    
    .triangle-container {
        width: 300px;
        height: 300px;
    }
}

@media (max-width: 768px) {
    .top-nav {
        padding: 1rem;
    }
    
    .logo-text {
        display: none;
    }
    
    .hero-logo-icon {
        width: 70px;
        height: 70px;
    }
    
    .hero-main-title {
        font-size: 2rem;
    }
    
    .hero {
        padding: 3rem 1.5rem;
    }
    
    .hero-title {
        font-size: 3rem;
    }
    
    .selection-title {
        font-size: 2.5rem;
    }
    
    .games-grid {
        grid-template-columns: 1fr;
    }
    
    .cell {
        font-size: 1.5rem;
    }
    
    .triangle-container {
        width: 250px;
        height: 250px;
    }
}

/* ===== LOGO FALLBACK ===== */
#robotLogo {
    display: block;
}

/* If image fails to load, show triangle icon as fallback */
.hero-logo-icon::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 40px solid transparent;
    border-right: 40px solid transparent;
    border-bottom: 70px solid var(--primary);
    opacity: 0;
    transition: opacity 0.3s;
}

.hero-logo-icon:has(img[src=""])::before,
.hero-logo-icon:not(:has(img))::before {
    opacity: 1;
}
