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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(circle at top, #1f2937 0, #020617 55%, #000 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #e5e7eb;
}

#app {
    width: 100%;
    height: 100vh;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Auth Screen */
.auth-container {
    background: rgba(15, 23, 42, 0.96);
    border-radius: 15px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.55);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.auth-container h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #a855f7;
    font-size: 28px;
}

.auth-tabs {
    display: flex;
    margin-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
    color: #999;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #4b5563;
    border-radius: 8px;
    font-size: 14px;
    background: #020617;
    color: #e5e7eb;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.auth-form input:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.6);
}

.error-message {
    color: #e74c3c;
    font-size: 14px;
    margin-top: 10px;
    display: none;
}

.error-message.show {
    display: block;
}

/* Game Screen */
.game-container {
    background: rgba(15, 23, 42, 0.96);
    height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.header {
    background: linear-gradient(120deg, #0f172a 0%, #4c1d95 40%, #be185d 100%);
    color: #e5e7eb;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info h2 {
    margin-bottom: 5px;
}

.user-info p {
    font-size: 14px;
    opacity: 0.8;
}

.nav-buttons {
    display: flex;
    gap: 10px;
}

.btn-nav {
    padding: 8px 16px;
    background: rgba(15, 23, 42, 0.55);
    color: #e5e7eb;
    border: 1px solid rgba(148, 163, 184, 0.6);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-nav:hover {
    background: rgba(30, 64, 175, 0.8);
}

.btn-logout {
    padding: 8px 16px;
    background: #e74c3c;
    color: #f9fafb;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: #c0392b;
}

/* Account Panel */
.account-panel {
    display: grid;
    grid-template-columns: minmax(240px, 360px) 1fr;
    gap: 24px;
    padding: 24px 40px 10px;
    align-items: center;
}

.account-balance {
    background: rgba(15, 23, 42, 0.85);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.account-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 12px;
    color: rgba(226, 232, 240, 0.8);
}

.account-value {
    font-size: 40px;
    font-weight: 700;
    margin: 8px 0 4px;
    color: #f8fafc;
}

.account-sub {
    font-size: 14px;
    color: rgba(226, 232, 240, 0.7);
}

.btn-toggle-add {
    margin-top: 16px;
    width: 100%;
}

.add-money-actions {
    display: none;
    margin-top: 12px;
    gap: 10px;
    flex-direction: column;
}

.add-money-actions.open {
    display: flex;
}

.add-money-actions .btn-primary,
.add-money-actions .btn-secondary {
    width: 100%;
}

.account-actions {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 16px;
    padding: 20px 24px;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.account-actions h3 {
    margin-bottom: 12px;
}

.invite-btn {
    margin-top: 0;
}

.btn-secondary {
    padding: 10px 14px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: #cbd5f5;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.btn-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.affiliate-link label {
    display: block;
    font-size: 13px;
    margin-bottom: 8px;
    color: rgba(226, 232, 240, 0.8);
}

.affiliate-link-row {
    display: flex;
    gap: 10px;
}

.affiliate-link-row input {
    flex: 1;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(2, 6, 23, 0.8);
    color: #e5e7eb;
}

.btn-small {
    padding: 10px 16px;
    background: rgba(79, 70, 229, 0.85);
    color: #f8fafc;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}

.btn-small:hover {
    background: rgba(99, 102, 241, 0.95);
}

.info-message {
    margin-top: 8px;
    font-size: 13px;
    color: #a7f3d0;
}

/* Game Area */
.game-area {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-section {
    display: none;
    width: 100%;
}

.game-section.active {
    display: block;
}

/* Setup Screen */
.setup-form {
    background: rgba(15, 23, 42, 0.9);
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    margin: 0 auto;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #e5e7eb;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #4b5563;
    border-radius: 8px;
    font-size: 14px;
    background: #020617;
    color: #e5e7eb;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.6);
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 40%, #ec4899 100%);
    color: #f9fafb;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.btn-primary:hover {
    transform: translateY(-1px) scale(1.01);
    box-shadow: 0 10px 25px rgba(236, 72, 153, 0.45);
}

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

.btn-large {
    padding: 15px 30px;
    font-size: 18px;
    width: auto;
}

.btn-success {
    background: #27ae60;
}

.btn-success:hover {
    background: #229954;
}

.btn-danger {
    background: #e74c3c;
}

.btn-danger:hover {
    background: #c0392b;
}

/* Play Screen */
.game-info {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.info-box {
    background: radial-gradient(circle at left, #4f46e5 0%, #7c3aed 35%, #db2777 100%);
    color: #f9fafb;
    padding: 16px 32px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    width: 100%;
    max-width: 900px;
}

.info-box p {
    margin: 0;
    font-size: 16px;
    white-space: nowrap;
}

.mine-grid {
    display: grid;
    gap: 10px;
    margin: 30px auto;
    width: min(430px, 90vw);
    height: min(430px, 90vw);
    background: rgba(15, 23, 42, 0.95);
    padding: 20px;
    border-radius: 15px;
}

.mine-grid.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(0.4);
}

.mine-grid.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.mine-grid.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.mine-grid.grid-5 {
    grid-template-columns: repeat(5, 1fr);
}

.cell {
    background: white;
    border: 1px solid #4b5563;
    border-radius: 10px;
    cursor: crosshair;
    width: 100%;
    aspect-ratio: 1;
    font-size: 2.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
    font-weight: bold;
}

.cell:hover {
    transform: scale(1.06);
    border-color: #8b5cf6;
    box-shadow: 0 0 16px rgba(139, 92, 246, 0.45);
}

.cell.revealed {
    cursor: not-allowed;
    background: #020617;
    border-color: #4b5563;
}

.cell.safe {
    background: rgba(22, 163, 74, 0.15);
    border-color: #22c55e;
    color: #22c55e;
}

.cell.mine {
    background: rgba(220, 38, 38, 0.18);
    border-color: #f87171;
    color: #f97373;
}

.game-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
}

.game-actions button {
    min-width: 200px;
}

.game-message {
    text-align: center;
    margin-top: 20px;
    font-size: 18px;
    font-weight: 500;
    color: #93c5fd;
    min-height: 25px;
}

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

.setup-form.setup-inline {
    margin-top: 20px;
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
    background: transparent;
    padding: 0;
    box-shadow: none;
}

.setup-form.setup-inline h2 {
    margin: 0;
    font-size: 20px;
    white-space: nowrap;
}

.setup-form.setup-inline .form-group {
    margin-bottom: 0;
    min-width: 140px;
}

.setup-form.setup-inline .btn-primary {
    margin-top: 0;
    align-self: stretch;
}

@media (max-width: 768px) {
    .setup-form.setup-inline {
        flex-direction: column;
        align-items: stretch;
    }
}

.setup-form.setup-inline input:disabled,
.setup-form.setup-inline select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Game Over Screen */
.gameover-container {
    display: none;
}

.gameover-container h2 {
    margin-bottom: 20px;
    color: #333;
}

.gameover-container p {
    margin-bottom: 10px;
    font-size: 16px;
    color: #666;
}

.final-prize {
    font-size: 28px !important;
    font-weight: bold;
    color: #27ae60;
    margin: 20px 0 !important;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #020617;
    padding: 40px;
    border-radius: 15px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
}

.modal-content.modal-large {
    max-width: 900px;
}

.close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
    transition: color 0.3s;
}

.close:hover {
    color: #333;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #e5e7eb;
}

/* Tables */
.leaderboard-table,
.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.leaderboard-table th,
.history-table th {
    background: #111827;
    color: #e5e7eb;
    padding: 12px;
    text-align: left;
    font-weight: 500;
}

.leaderboard-table td,
.history-table td {
    padding: 12px;
    border-bottom: 1px solid #1f2933;
}

.leaderboard-table tr:hover,
.history-table tr:hover {
    background: rgba(15, 23, 42, 0.8);
}

#stats-content {
    background: #020617;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #1f2937;
}

#stats-content p {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    font-size: 16px;
}

#stats-content p strong {
    color: #e5e7eb;
}

/* Responsive */
@media (max-width: 768px) {
    .auth-container {
        padding: 20px;
        max-width: 90%;
    }
    
    .game-container {
        height: auto;
    }
    
    .header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .nav-buttons {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .game-area {
        padding: 20px;
    }
    
    .setup-form {
        max-width: 100%;
    }
    
    .mine-grid {
        max-width: 100%;
    }
    
    .modal-content {
        margin: 20px;
        max-height: 90vh;
    }
    
    .modal-content.modal-large {
        max-width: 95%;
    }
}
