:root {
    --primary: #FF006E;
    --secondary: #FB5607;
    --accent: #FFBE0B;
    --purple: #8338EC;
    --blue: #3A86FF;
    --dark: #1a1a1a;
    --darker: #0f0f0f;
    --light: #f5f5f5;
    --gray: #666;
    --success: #00ff88;
    --danger: #ff4757;
    --warning: #ffa502;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--dark) 0%, var(--darker) 100%);
    color: var(--light);
    min-height: 100vh;
    overflow-x: hidden;
    padding-bottom: 80px;
}

header {
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 2px solid var(--primary);
    box-shadow: 0 0 20px rgba(255, 0, 110, 0.3);
}

header h1 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    text-shadow: 0 0 10px var(--primary);
    background: linear-gradient(45deg, var(--primary), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

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

.btn.primary {
    background: linear-gradient(45deg, var(--primary), var(--purple));
    color: white;
    box-shadow: 0 0 20px rgba(255, 0, 110, 0.4);
}

.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(255, 0, 110, 0.6);
}

.btn.secondary {
    background: linear-gradient(45deg, var(--blue), var(--purple));
    color: white;
    box-shadow: 0 0 20px rgba(58, 134, 255, 0.4);
}

.btn.secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(58, 134, 255, 0.6);
}

.btn.danger {
    background: linear-gradient(45deg, var(--danger), var(--secondary));
    color: white;
    box-shadow: 0 0 20px rgba(255, 71, 87, 0.4);
}

.btn.danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(255, 71, 87, 0.6);
}

.btn.info {
    background: linear-gradient(45deg, var(--accent), var(--secondary));
    color: var(--dark);
    box-shadow: 0 0 20px rgba(255, 190, 11, 0.4);
}

.btn.info:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(255, 190, 11, 0.6);
}

main {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.section {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.section.active {
    display: block;
}

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

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(26, 26, 26, 0.8);
    padding: 1rem;
    border-radius: 15px;
    margin-bottom: 1rem;
    border: 2px solid var(--primary);
    box-shadow: 0 0 20px rgba(255, 0, 110, 0.2);
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.label {
    font-size: 0.8rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status {
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 10px;
    font-size: 0.9rem;
}

.status.playing {
    background: var(--warning);
    color: var(--dark);
}

.status.completed {
    background: var(--success);
    color: var(--dark);
}

.status.invalid {
    background: var(--danger);
    color: white;
}

.game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1rem 0;
    background: rgba(26, 26, 26, 0.8);
    border-radius: 15px;
    padding: 1rem;
    border: 2px solid var(--blue);
    box-shadow: 0 0 20px rgba(58, 134, 255, 0.2);
}

#game-canvas {
    max-width: 100%;
    height: auto;
    border: 2px solid var(--accent);
    border-radius: 10px;
    background: var(--darker);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    cursor: crosshair;
}

.game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    background: rgba(26, 26, 26, 0.8);
    padding: 1rem;
    border-radius: 15px;
    border: 2px solid var(--purple);
    box-shadow: 0 0 20px rgba(131, 56, 236, 0.2);
}

.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.difficulty-selector label {
    font-weight: 600;
    color: var(--accent);
    text-shadow: 0 0 5px var(--accent);
}

.difficulty-selector select {
    padding: 0.5rem;
    border: 2px solid var(--accent);
    border-radius: 10px;
    background: var(--darker);
    color: var(--light);
    font-size: 0.9rem;
}

.rules-content, .stats-grid {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

.rule-item {
    background: rgba(26, 26, 26, 0.8);
    padding: 1.5rem;
    border-radius: 15px;
    border-left: 4px solid var(--primary);
    box-shadow: 0 0 20px rgba(255, 0, 110, 0.1);
}

.rule-item h3 {
    margin-bottom: 1rem;
    color: var(--accent);
    text-shadow: 0 0 5px var(--accent);
}

.rule-item ul {
    list-style: none;
    padding-left: 0;
}

.rule-item li {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    padding-left: 1.5rem;
}

.rule-item li::before {
    content: '🌉';
    position: absolute;
    left: 0;
    top: 0.5rem;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.stat-card {
    background: rgba(26, 26, 26, 0.8);
    padding: 1.5rem;
    border-radius: 15px;
    text-align: center;
    border: 2px solid var(--blue);
    box-shadow: 0 0 20px rgba(58, 134, 255, 0.2);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 30px rgba(58, 134, 255, 0.4);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--gray);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-actions {
    margin-top: 2rem;
    text-align: center;
}

.faq-container {
    margin-top: 1rem;
}

.faq-item {
    background: rgba(26, 26, 26, 0.8);
    border-radius: 15px;
    margin-bottom: 1rem;
    border: 2px solid var(--purple);
    box-shadow: 0 0 20px rgba(131, 56, 236, 0.1);
    overflow: hidden;
}

.faq-question {
    width: 100%;
    padding: 1.5rem;
    background: transparent;
    border: none;
    color: var(--light);
    text-align: left;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.faq-question:hover {
    background: rgba(131, 56, 236, 0.1);
    color: var(--purple);
    text-shadow: 0 0 5px var(--purple);
}

.faq-icon {
    font-size: 1.5rem;
    color: var(--accent);
    transition: transform 0.3s ease;
}

.faq-question[aria-expanded="true"] .faq-icon {
    transform: rotate(45deg);
}

.faq-answer {
    padding: 0 1.5rem 1.5rem;
    color: var(--gray);
    line-height: 1.6;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-around;
    padding: 1rem;
    border-top: 2px solid var(--primary);
    box-shadow: 0 0 20px rgba(255, 0, 110, 0.3);
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--gray);
    transition: all 0.3s ease;
    padding: 0.5rem;
    border-radius: 10px;
    min-width: 60px;
}

.nav-item i {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.nav-item span {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-item.active,
.nav-item:hover {
    color: var(--primary);
    text-shadow: 0 0 5px var(--primary);
    background: rgba(255, 0, 110, 0.1);
}

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, var(--dark) 0%, var(--darker) 100%);
    margin: 10% auto;
    padding: 2rem;
    border: 2px solid var(--primary);
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 0 30px rgba(255, 0, 110, 0.5);
}

.close {
    color: var(--gray);
    float: right;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
    position: absolute;
    top: 1rem;
    right: 1.5rem;
}

.close:hover {
    color: var(--primary);
    text-shadow: 0 0 5px var(--primary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

footer {
    background: rgba(26, 26, 26, 0.95);
    text-align: center;
    padding: 1rem;
    color: var(--gray);
    font-size: 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 2rem;
}

@media (min-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .header-controls {
        gap: 1rem;
    }
    
    .btn {
        font-size: 0.9rem;
        padding: 0.75rem 1.5rem;
    }
    
    #game-canvas {
        width: 500px;
        height: 500px;
    }
    
    .game-info {
        flex-direction: row;
    }
    
    .info-item {
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .bottom-nav {
        position: relative;
        display: none;
    }
    
    body {
        padding-bottom: 0;
    }
    
    .section {
        padding: 2rem 0;
    }
}

@media (min-width: 1024px) {
    main {
        padding: 2rem;
    }
    
    .rules-content {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
    
    #game-canvas {
        width: 600px;
        height: 600px;
    }
}

.island-complete {
    filter: drop-shadow(0 0 10px var(--success));
}

.bridge-single {
    stroke: var(--accent);
    stroke-width: 3;
    filter: drop-shadow(0 0 5px var(--accent));
}

.bridge-double {
    stroke: var(--primary);
    stroke-width: 2;
    filter: drop-shadow(0 0 8px var(--primary));
}

.island-text {
    fill: var(--light);
    text-anchor: middle;
    dominant-baseline: central;
    font-weight: bold;
    font-size: 16px;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.island-circle {
    fill: var(--blue);
    stroke: var(--accent);
    stroke-width: 2;
    filter: drop-shadow(0 0 10px var(--blue));
}

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

.pulse {
    animation: pulse 0.5s ease-in-out;
}
