:root {
    --primary: #FF006E;
    --secondary: #FB5607;
    --accent: #FFBE0B;
    --purple: #8338EC;
    --blue: #3A86FF;
    --dark: #1a1a1a;
    --light: #f8f9fa;
    --gray: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
}

* {
    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%, #2d2d2d 100%);
    color: var(--light);
    min-height: 100vh;
    padding-bottom: 80px;
}

header {
    text-align: center;
    padding: 1rem;
    background: linear-gradient(45deg, var(--primary), var(--purple));
    box-shadow: 0 4px 20px rgba(255, 0, 110, 0.3);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

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 Controls */
.game-controls {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 1rem;
    margin-bottom: 1rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.control-group label {
    font-weight: bold;
    color: var(--accent);
}

.control-group select {
    background: var(--dark);
    color: var(--light);
    border: 2px solid var(--purple);
    border-radius: 8px;
    padding: 0.5rem;
    font-size: 1rem;
}

.control-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(255, 0, 110, 0.5);
}

button {
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 0.7rem 1.2rem;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 0, 110, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 0, 110, 0.4);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.game-stats {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: bold;
}

.game-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Grid Styles */
.grid-container {
    display: inline-block;
    background: var(--light);
    border: 3px solid var(--purple);
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 8px 30px rgba(131, 56, 236, 0.4);
    margin: 0 auto;
    display: block;
    width: fit-content;
}

.game-grid {
    display: grid;
    gap: 2px;
    background: var(--gray);
    padding: 2px;
}

.grid-cell {
    width: 40px;
    height: 40px;
    border: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    color: #333;
}

.grid-cell:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(255, 190, 11, 0.7);
}

.grid-cell.sea {
    background: #333;
    color: white;
}

.grid-cell.uncertain {
    background: #999;
    color: white;
}

.grid-cell.numbered {
    background: var(--accent);
    color: #333;
    font-weight: bold;
    cursor: default;
}

.grid-cell.numbered:hover {
    transform: none;
    box-shadow: none;
}

.grid-cell.error {
    background: var(--danger) !important;
    animation: shake 0.5s ease-in-out;
}

.grid-cell.hint {
    animation: pulse 1s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

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

/* Status Message */
.status-message {
    text-align: center;
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 10px;
    font-weight: bold;
    font-size: 1.1rem;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-message.success {
    background: linear-gradient(45deg, var(--success), #20c997);
    color: white;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.status-message.error {
    background: linear-gradient(45deg, var(--danger), #e74c3c);
    color: white;
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
}

.status-message.info {
    background: linear-gradient(45deg, var(--blue), #17a2b8);
    color: white;
    box-shadow: 0 4px 15px rgba(58, 134, 255, 0.3);
}

/* Rules Section */
.rules-content {
    display: grid;
    gap: 1.5rem;
}

.rule-item {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 1.5rem;
    border-left: 4px solid var(--accent);
}

.rule-item h3 {
    color: var(--accent);
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

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

.rule-item li {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
}

.rule-item li:before {
    content: "▶";
    position: absolute;
    left: 0;
    color: var(--primary);
}

/* Stats Section */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border-radius: 15px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.stat-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(45deg, var(--primary), var(--purple));
    border-radius: 50%;
}

.stat-info h3 {
    font-size: 0.9rem;
    color: var(--gray);
    margin-bottom: 0.5rem;
}

.stat-info span {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--accent);
}

.reset-stats {
    background: linear-gradient(45deg, var(--danger), #e74c3c);
    margin-top: 1rem;
}

/* FAQ Section */
.faq-container {
    display: grid;
    gap: 1rem;
}

.faq-item {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

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

.faq-question:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: none;
    box-shadow: none;
}

.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(--light);
    line-height: 1.6;
    opacity: 0.9;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.faq-answer:not([hidden]) {
    max-height: 200px;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(45deg, var(--dark), #2d2d2d);
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0;
    border-top: 2px solid var(--purple);
    box-shadow: 0 -4px 20px rgba(131, 56, 236, 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:hover,
.nav-item.active {
    color: var(--accent);
    background: rgba(255, 190, 11, 0.1);
    transform: translateY(-2px);
}

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

.nav-item span {
    font-size: 0.8rem;
    font-weight: bold;
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 80px;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .control-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .game-stats {
        justify-content: space-between;
    }
    
    .game-actions {
        justify-content: center;
    }
    
    .grid-cell {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-icon {
        font-size: 2rem;
        width: 50px;
        height: 50px;
    }
    
    .stat-info span {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    main {
        padding: 0.5rem;
    }
    
    .grid-cell {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }
    
    .game-controls {
        padding: 0.5rem;
    }
    
    .rule-item,
    .faq-item {
        margin: 0 -0.5rem;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s ease-in-out infinite;
}

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

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .grid-cell {
        border-width: 2px;
    }
    
    .grid-cell.sea {
        background: #000;
    }
    
    .grid-cell.uncertain {
        background: #666;
    }
}
