/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

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

.url-info {
    margin-top: 15px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.url-info small {
    line-height: 1.4;
    display: block;
}

.url-info code {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    margin: 0 2px;
}

/* Navigation tabs */
.tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.tab-button {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-button:hover {
    background: #e9ecef;
}

.tab-button.active {
    background: white;
    color: #667eea;
    border-bottom-color: #667eea;
}

/* Tab content */
.tab-content {
    display: none;
    padding: 30px;
}

.tab-content.active {
    display: block;
}

.game-section {
    max-width: 600px;
    margin: 0 auto;
}

.game-section h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    color: #333;
}

.game-section p {
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1rem;
}

/* Forms */
.fairness-form {
    margin-bottom: 30px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-group input::placeholder {
    color: #adb5bd;
}

/* Calculate button */
.calculate-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

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

/* Results section */
.result-section {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #667eea;
    display: none;
}

.result-section.show {
    display: block;
    animation: slideIn 0.3s ease;
}

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

.result-item {
    margin-bottom: 15px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.result-item:last-child {
    margin-bottom: 0;
}

.result-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-value {
    font-family: 'Courier New', monospace;
    color: #667eea;
    font-size: 1.1rem;
    word-break: break-all;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.result-value.number {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    color: #28a745;
}

.result-value.upgrade-status {
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    margin-top: 5px;
}

.result-value.upgrade-status.success {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.result-value.upgrade-status.failed {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

.result-value.array {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
}

.mine-cell {
    background: #dc3545;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: 600;
    min-width: 40px;
    text-align: center;
}

/* Grid visualization for mines */
.mines-grid {
    display: grid;
    gap: 2px;
    margin-top: 15px;
    justify-content: center;
    background: #e9ecef;
    padding: 10px;
    border-radius: 8px;
}

.grid-cell {
    width: 30px;
    height: 30px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    border-radius: 4px;
}

.grid-cell.mine {
    background: #dc3545;
    color: white;
}

.grid-cell.safe {
    background: #28a745;
    color: white;
}

/* Error styles */
.error {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.error .result-value {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading .calculate-btn {
    background: #6c757d;
    cursor: not-allowed;
}

.loading .calculate-btn::after {
    content: "...";
    animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
    0%, 20% {
        color: rgba(255, 255, 255, 0);
        text-shadow: 0.25em 0 0 rgba(255, 255, 255, 0),
                     0.5em 0 0 rgba(255, 255, 255, 0);
    }
    40% {
        color: white;
        text-shadow: 0.25em 0 0 rgba(255, 255, 255, 0),
                     0.5em 0 0 rgba(255, 255, 255, 0);
    }
    60% {
        text-shadow: 0.25em 0 0 white,
                     0.5em 0 0 rgba(255, 255, 255, 0);
    }
    80%, 100% {
        text-shadow: 0.25em 0 0 white,
                     0.5em 0 0 white;
    }
}

/* Code Editor Styles */
.code-controls {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.function-tabs {
    display: flex;
    background: #f8f9fa;
    border-radius: 10px 10px 0 0;
    margin-bottom: 0;
    border: 1px solid #e9ecef;
    border-bottom: none;
}

.function-tab-button {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.function-tab-button:first-child {
    border-radius: 10px 0 0 0;
}

.function-tab-button:last-child {
    border-radius: 0 10px 0 0;
}

.function-tab-button:hover {
    background: #e9ecef;
}

.function-tab-button.active {
    background: white;
    color: #667eea;
    border-bottom-color: #667eea;
}

.function-content {
    display: none;
    border: 1px solid #e9ecef;
    border-radius: 0 0 10px 10px;
    background: white;
}

.function-content.active {
    display: block;
}

.function-content h3 {
    padding: 15px 20px;
    margin: 0;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    color: #333;
    font-size: 1.1rem;
}

.code-section {
    padding: 20px;
}

.code-section label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
}

.code-editor {
    width: 100%;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    background: #f8f9fa;
    color: #333;
    resize: vertical;
    min-height: 300px;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

.code-editor:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.code-info {
    margin: 20px 0;
    padding: 20px;
    background: #e7f3ff;
    border: 1px solid #b8daff;
    border-radius: 10px;
}

.code-info h3 {
    margin-top: 0;
    color: #004085;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-top: 15px;
}

.info-item {
    padding: 12px;
    background: white;
    border: 1px solid #b8daff;
    border-radius: 6px;
    border-left: 4px solid #667eea;
}

.warning-box {
    margin: 20px 0;
    padding: 20px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 10px;
    border-left: 4px solid #f39c12;
}

.warning-box h3 {
    margin-top: 0;
    color: #856404;
}

.warning-box ul {
    margin: 10px 0 0 20px;
    color: #856404;
}

.warning-box li {
    margin-bottom: 8px;
}

/* Weapon display styles */
.weapon-display {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0 30px 0;
    box-shadow: 0 8px 16px rgba(238, 90, 36, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.weapon-icon {
    font-size: 3rem;
    margin-right: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.weapon-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.weapon-info span {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 5px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.weapon-info small {
    opacity: 0.9;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: 15px;
    }
    
    header {
        padding: 20px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .tab-content {
        padding: 20px;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    .tab-button {
        flex: 1 1 50%;
        min-width: 50%;
    }
    
    .function-tabs {
        flex-direction: column;
    }
    
    .function-tab-button {
        border-radius: 0 !important;
        border-bottom: 1px solid #e9ecef;
    }
    
    .function-tab-button:first-child {
        border-radius: 10px 10px 0 0 !important;
    }
    
    .function-tab-button:last-child {
        border-bottom: none;
    }
    
    .function-content {
        border-radius: 0 0 10px 10px;
    }
    
    .code-controls {
        flex-direction: column;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .weapon-display {
        flex-direction: column;
        text-align: center;
        padding: 15px;
    }
    
    .weapon-icon {
        margin-right: 0;
        margin-bottom: 10px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .tab-button {
        flex: 1 1 100%;
        min-width: 100%;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .calculate-btn {
        font-size: 1rem;
    }
}
